Sort methods

This commit is contained in:
libraryaddict 2014-07-14 13:11:30 +12:00
parent 67e4631a1a
commit 8e7028ce96
4 changed files with 35 additions and 35 deletions

View File

@ -31,30 +31,16 @@ public class PlayerWatcher extends LivingWatcher {
return (Byte) getValue(9, (byte) 0); return (Byte) getValue(9, (byte) 0);
} }
public boolean isSleeping() { private boolean getValue16(int i) {
return isInBed; return ((Byte) getValue(16, (byte) 0) & 1 << i) != 0;
}
public void setHideCape(boolean hideCape) {
setValue16(1, hideCape);
sendData(16);
} }
public boolean isHideCape() { public boolean isHideCape() {
return getValue16(1); return getValue16(1);
} }
private boolean getValue16(int i) { public boolean isSleeping() {
return ((Byte) getValue(16, (byte) 0) & 1 << i) != 0; return isInBed;
}
private void setValue16(int i, boolean flag) {
byte b0 = (Byte) getValue(16, (byte) 0);
if (flag) {
setValue(16, Byte.valueOf((byte) (b0 | 1 << i)));
} else {
setValue(16, Byte.valueOf((byte) (b0 & (1 << i ^ 0xFFFFFFFF))));
}
} }
public void setArrowsSticking(int arrowsNo) { public void setArrowsSticking(int arrowsNo) {
@ -62,6 +48,11 @@ public class PlayerWatcher extends LivingWatcher {
sendData(9); sendData(9);
} }
public void setHideCape(boolean hideCape) {
setValue16(1, hideCape);
sendData(16);
}
public void setSkin(String playerName) { public void setSkin(String playerName) {
((PlayerDisguise) getDisguise()).setSkin(playerName); ((PlayerDisguise) getDisguise()).setSkin(playerName);
} }
@ -99,4 +90,13 @@ public class PlayerWatcher extends LivingWatcher {
} }
} }
private void setValue16(int i, boolean flag) {
byte b0 = (Byte) getValue(16, (byte) 0);
if (flag) {
setValue(16, Byte.valueOf((byte) (b0 | 1 << i)));
} else {
setValue(16, Byte.valueOf((byte) (b0 & (1 << i ^ 0xFFFFFFFF))));
}
}
} }

View File

@ -8,13 +8,13 @@ public class WitchWatcher extends LivingWatcher {
super(disguise); super(disguise);
} }
public boolean isAggressive() {
return (Byte) getValue(21, (byte) 0) == 1;
}
public void setAggressive(boolean isTrue) { public void setAggressive(boolean isTrue) {
setValue(21, (byte) (isTrue ? 1 : 0)); setValue(21, (byte) (isTrue ? 1 : 0));
sendData(21); sendData(21);
} }
public boolean isAggressive() {
return (Byte) getValue(21, (byte) 0) == 1;
}
} }

View File

@ -20,6 +20,10 @@ public class WitherWatcher extends LivingWatcher {
return (Integer) getValue(20, 0); return (Integer) getValue(20, 0);
} }
public int[] getTargets() {
return new int[] { (Integer) getValue(17, 0), (Integer) getValue(18, 0), (Integer) getValue(19, 0) };
}
public void setInvul(int invulnerability) { public void setInvul(int invulnerability) {
setInvulnerability(invulnerability); setInvulnerability(invulnerability);
} }
@ -40,8 +44,4 @@ public class WitherWatcher extends LivingWatcher {
sendData(17, 18, 19); sendData(17, 18, 19);
} }
public int[] getTargets() {
return new int[] { (Integer) getValue(17, 0), (Integer) getValue(18, 0), (Integer) getValue(19, 0) };
}
} }

View File

@ -16,6 +16,10 @@ public class ZombieWatcher extends LivingWatcher {
return (Byte) getValue(12, (byte) 0) == 1; return (Byte) getValue(12, (byte) 0) == 1;
} }
public boolean isShaking() {
return (Byte) getValue(14, (byte) 0) == 1;
}
public boolean isVillager() { public boolean isVillager() {
return (Byte) getValue(13, (byte) 0) == 1; return (Byte) getValue(13, (byte) 0) == 1;
} }
@ -28,20 +32,16 @@ public class ZombieWatcher extends LivingWatcher {
setBaby(true); setBaby(true);
} }
public void setShaking(boolean shaking) {
setValue(14, (byte) (shaking ? 1 : 0));
sendData(14);
}
public boolean isShaking() {
return (Byte) getValue(14, (byte) 0) == 1;
}
public void setBaby(boolean baby) { public void setBaby(boolean baby) {
setValue(12, (byte) (baby ? 1 : 0)); setValue(12, (byte) (baby ? 1 : 0));
sendData(12); sendData(12);
} }
public void setShaking(boolean shaking) {
setValue(14, (byte) (shaking ? 1 : 0));
sendData(14);
}
public void setVillager(boolean villager) { public void setVillager(boolean villager) {
setValue(13, (byte) (villager ? 1 : 0)); setValue(13, (byte) (villager ? 1 : 0));
sendData(13); sendData(13);