summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2013-04-11 18:47:18 -0500
committerWesley Wolfe <weswolf@aol.com>2013-04-13 00:30:56 -0500
commit94f43d8c361295fabea3f3375f488336b66b57c2 (patch)
tree58a3940ddd2248d262ac8ae7acff46d29b06d425 /src
parenta2d9f33ca38660bb6bd698f598e8a6cfddc4e702 (diff)
downloadcraftbukkit-94f43d8c361295fabea3f3375f488336b66b57c2.tar
craftbukkit-94f43d8c361295fabea3f3375f488336b66b57c2.tar.gz
craftbukkit-94f43d8c361295fabea3f3375f488336b66b57c2.tar.lz
craftbukkit-94f43d8c361295fabea3f3375f488336b66b57c2.tar.xz
craftbukkit-94f43d8c361295fabea3f3375f488336b66b57c2.zip
Add MobEffect from mc-dev for diff visibility
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/MobEffect.java143
1 files changed, 143 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/MobEffect.java b/src/main/java/net/minecraft/server/MobEffect.java
new file mode 100644
index 00000000..726a447a
--- /dev/null
+++ b/src/main/java/net/minecraft/server/MobEffect.java
@@ -0,0 +1,143 @@
+package net.minecraft.server;
+
+public class MobEffect {
+
+ private int effectId;
+ private int duration;
+ private int amplification;
+ private boolean splash;
+ private boolean ambient;
+
+ public MobEffect(int i, int j) {
+ this(i, j, 0);
+ }
+
+ public MobEffect(int i, int j, int k) {
+ this(i, j, k, false);
+ }
+
+ public MobEffect(int i, int j, int k, boolean flag) {
+ this.effectId = i;
+ this.duration = j;
+ this.amplification = k;
+ this.ambient = flag;
+ }
+
+ public MobEffect(MobEffect mobeffect) {
+ this.effectId = mobeffect.effectId;
+ this.duration = mobeffect.duration;
+ this.amplification = mobeffect.amplification;
+ }
+
+ public void a(MobEffect mobeffect) {
+ if (this.effectId != mobeffect.effectId) {
+ System.err.println("This method should only be called for matching effects!");
+ }
+
+ if (mobeffect.amplification > this.amplification) {
+ this.amplification = mobeffect.amplification;
+ this.duration = mobeffect.duration;
+ } else if (mobeffect.amplification == this.amplification && this.duration < mobeffect.duration) {
+ this.duration = mobeffect.duration;
+ } else if (!mobeffect.ambient && this.ambient) {
+ this.ambient = mobeffect.ambient;
+ }
+ }
+
+ public int getEffectId() {
+ return this.effectId;
+ }
+
+ public int getDuration() {
+ return this.duration;
+ }
+
+ public int getAmplifier() {
+ return this.amplification;
+ }
+
+ public boolean isSplash() {
+ return this.splash;
+ }
+
+ public void setSplash(boolean flag) {
+ this.splash = flag;
+ }
+
+ public boolean isAmbient() {
+ return this.ambient;
+ }
+
+ public boolean tick(EntityLiving entityliving) {
+ if (this.duration > 0) {
+ if (MobEffectList.byId[this.effectId].a(this.duration, this.amplification)) {
+ this.b(entityliving);
+ }
+
+ this.h();
+ }
+
+ return this.duration > 0;
+ }
+
+ private int h() {
+ return --this.duration;
+ }
+
+ public void b(EntityLiving entityliving) {
+ if (this.duration > 0) {
+ MobEffectList.byId[this.effectId].tick(entityliving, this.amplification);
+ }
+ }
+
+ public String f() {
+ return MobEffectList.byId[this.effectId].a();
+ }
+
+ public int hashCode() {
+ return this.effectId;
+ }
+
+ public String toString() {
+ String s = "";
+
+ if (this.getAmplifier() > 0) {
+ s = this.f() + " x " + (this.getAmplifier() + 1) + ", Duration: " + this.getDuration();
+ } else {
+ s = this.f() + ", Duration: " + this.getDuration();
+ }
+
+ if (this.splash) {
+ s = s + ", Splash: true";
+ }
+
+ return MobEffectList.byId[this.effectId].i() ? "(" + s + ")" : s;
+ }
+
+ public boolean equals(Object object) {
+ if (!(object instanceof MobEffect)) {
+ return false;
+ } else {
+ MobEffect mobeffect = (MobEffect) object;
+
+ return this.effectId == mobeffect.effectId && this.amplification == mobeffect.amplification && this.duration == mobeffect.duration && this.splash == mobeffect.splash && this.ambient == mobeffect.ambient;
+ }
+ }
+
+ public NBTTagCompound a(NBTTagCompound nbttagcompound) {
+ nbttagcompound.setByte("Id", (byte) this.getEffectId());
+ nbttagcompound.setByte("Amplifier", (byte) this.getAmplifier());
+ nbttagcompound.setInt("Duration", this.getDuration());
+ nbttagcompound.setBoolean("Ambient", this.isAmbient());
+ return nbttagcompound;
+ }
+
+ public static MobEffect b(NBTTagCompound nbttagcompound) {
+ byte b0 = nbttagcompound.getByte("Id");
+ byte b1 = nbttagcompound.getByte("Amplifier");
+ int i = nbttagcompound.getInt("Duration");
+ boolean flag = nbttagcompound.getBoolean("Ambient");
+
+ return new MobEffect(b0, i, b1, flag);
+ }
+}