From 8e7028ce969e5a52c86a560188ded2feb812e6f9 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 14 Jul 2014 13:11:30 +1200 Subject: [PATCH] Sort methods --- .../disguisetypes/watchers/PlayerWatcher.java | 36 +++++++++---------- .../disguisetypes/watchers/WitchWatcher.java | 8 ++--- .../disguisetypes/watchers/WitherWatcher.java | 8 ++--- .../disguisetypes/watchers/ZombieWatcher.java | 18 +++++----- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java index 4abe6c4e..a6f1a852 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PlayerWatcher.java @@ -31,30 +31,16 @@ public class PlayerWatcher extends LivingWatcher { return (Byte) getValue(9, (byte) 0); } - public boolean isSleeping() { - return isInBed; - } - - public void setHideCape(boolean hideCape) { - setValue16(1, hideCape); - sendData(16); + private boolean getValue16(int i) { + return ((Byte) getValue(16, (byte) 0) & 1 << i) != 0; } public boolean isHideCape() { return getValue16(1); } - private boolean getValue16(int i) { - return ((Byte) getValue(16, (byte) 0) & 1 << i) != 0; - } - - 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 boolean isSleeping() { + return isInBed; } public void setArrowsSticking(int arrowsNo) { @@ -62,6 +48,11 @@ public class PlayerWatcher extends LivingWatcher { sendData(9); } + public void setHideCape(boolean hideCape) { + setValue16(1, hideCape); + sendData(16); + } + public void setSkin(String 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)))); + } + } + } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java index f8f529b3..0adb2a32 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitchWatcher.java @@ -8,13 +8,13 @@ public class WitchWatcher extends LivingWatcher { super(disguise); } + public boolean isAggressive() { + return (Byte) getValue(21, (byte) 0) == 1; + } + public void setAggressive(boolean isTrue) { setValue(21, (byte) (isTrue ? 1 : 0)); sendData(21); } - public boolean isAggressive() { - return (Byte) getValue(21, (byte) 0) == 1; - } - } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java index d030e71b..95abb4f3 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/WitherWatcher.java @@ -20,6 +20,10 @@ public class WitherWatcher extends LivingWatcher { 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) { setInvulnerability(invulnerability); } @@ -40,8 +44,4 @@ public class WitherWatcher extends LivingWatcher { sendData(17, 18, 19); } - public int[] getTargets() { - return new int[] { (Integer) getValue(17, 0), (Integer) getValue(18, 0), (Integer) getValue(19, 0) }; - } - } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java index 33ddf2bd..0447f519 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java @@ -16,6 +16,10 @@ public class ZombieWatcher extends LivingWatcher { return (Byte) getValue(12, (byte) 0) == 1; } + public boolean isShaking() { + return (Byte) getValue(14, (byte) 0) == 1; + } + public boolean isVillager() { return (Byte) getValue(13, (byte) 0) == 1; } @@ -28,20 +32,16 @@ public class ZombieWatcher extends LivingWatcher { 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) { setValue(12, (byte) (baby ? 1 : 0)); sendData(12); } + public void setShaking(boolean shaking) { + setValue(14, (byte) (shaking ? 1 : 0)); + sendData(14); + } + public void setVillager(boolean villager) { setValue(13, (byte) (villager ? 1 : 0)); sendData(13);