From 61dbf354ffda1a4717cfc54bc44faf5f4970248e Mon Sep 17 00:00:00 2001 From: Final Child Date: Wed, 25 May 2016 16:25:56 +0900 Subject: [PATCH 1/3] Fix #163 (ServerBlockValuePacket) --- .../server/world/ServerBlockValuePacket.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java index 914d0fdd..7e1135f7 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java @@ -68,32 +68,25 @@ public class ServerBlockValuePacket implements Packet { public void read(NetInput in) throws IOException { this.position = NetUtil.readPosition(in); int type = in.readUnsignedByte(); - if(this.blockId == NOTE_BLOCK) { + int value = in.readUnsignedByte(); + this.blockId = in.readVarInt() & 0xFFF; + + if(this.blockId == NOTE_BLOCK) { this.type = MagicValues.key(NoteBlockValueType.class, type); + this.value = new NoteBlockValue(value); } else if(this.blockId == STICKY_PISTON || this.blockId == PISTON) { this.type = MagicValues.key(PistonValueType.class, type); + this.value = MagicValues.key(PistonValue.class, value); } else if(this.blockId == MOB_SPAWNER) { this.type = MagicValues.key(MobSpawnerValueType.class, type); + this.value = new MobSpawnerValue(); } else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST) { this.type = MagicValues.key(ChestValueType.class, type); + this.value = new ChestValue(value); } else { this.type = MagicValues.key(GenericBlockValueType.class, type); + this.value = new GenericBlockValue(value); } - - int value = in.readUnsignedByte(); - if(this.blockId == NOTE_BLOCK) { - this.value = new NoteBlockValue(value); - } else if(this.blockId == STICKY_PISTON || this.blockId == PISTON) { - this.value = MagicValues.key(PistonValue.class, value); - } else if(this.blockId == MOB_SPAWNER) { - this.value = new MobSpawnerValue(); - } else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST) { - this.value = new ChestValue(value); - } else { - this.value = new GenericBlockValue(value); - } - - this.blockId = in.readVarInt() & 4095; } @Override From 03f1d7d92d3a37b116bbc7b8601afc06cdf75e68 Mon Sep 17 00:00:00 2001 From: Final Child Date: Wed, 25 May 2016 16:28:10 +0900 Subject: [PATCH 2/3] Fix last commit's code style --- .../server/world/ServerBlockValuePacket.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java index 7e1135f7..3a0f3446 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/world/ServerBlockValuePacket.java @@ -70,22 +70,22 @@ public class ServerBlockValuePacket implements Packet { int type = in.readUnsignedByte(); int value = in.readUnsignedByte(); this.blockId = in.readVarInt() & 0xFFF; - - if(this.blockId == NOTE_BLOCK) { + + if(this.blockId == NOTE_BLOCK) { this.type = MagicValues.key(NoteBlockValueType.class, type); - this.value = new NoteBlockValue(value); + this.value = new NoteBlockValue(value); } else if(this.blockId == STICKY_PISTON || this.blockId == PISTON) { this.type = MagicValues.key(PistonValueType.class, type); - this.value = MagicValues.key(PistonValue.class, value); + this.value = MagicValues.key(PistonValue.class, value); } else if(this.blockId == MOB_SPAWNER) { this.type = MagicValues.key(MobSpawnerValueType.class, type); - this.value = new MobSpawnerValue(); + this.value = new MobSpawnerValue(); } else if(this.blockId == CHEST || this.blockId == ENDER_CHEST || this.blockId == TRAPPED_CHEST) { this.type = MagicValues.key(ChestValueType.class, type); - this.value = new ChestValue(value); + this.value = new ChestValue(value); } else { this.type = MagicValues.key(GenericBlockValueType.class, type); - this.value = new GenericBlockValue(value); + this.value = new GenericBlockValue(value); } } From 99824e1e4ce44b946622ab13ad5c15ad65d7a75b Mon Sep 17 00:00:00 2001 From: Final Child Date: Wed, 25 May 2016 16:39:02 +0900 Subject: [PATCH 3/3] Fix #159 (Effect) --- src/main/java/org/spacehq/mc/protocol/data/MagicValues.java | 4 ++++ .../org/spacehq/mc/protocol/data/game/entity/Effect.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/spacehq/mc/protocol/data/MagicValues.java b/src/main/java/org/spacehq/mc/protocol/data/MagicValues.java index d124567f..b198e8cf 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/MagicValues.java +++ b/src/main/java/org/spacehq/mc/protocol/data/MagicValues.java @@ -265,6 +265,10 @@ public class MagicValues { register(Effect.HEALTH_BOOST, 21); register(Effect.ABSORPTION, 22); register(Effect.SATURATION, 23); + register(Effect.GLOWING, 24); + register(Effect.LEVITATION, 25); + register(Effect.LUCK, 26); + register(Effect.BAD_LUCK, 27); register(EntityStatus.HURT_OR_MINECART_SPAWNER_DELAY_RESET, 1); register(EntityStatus.LIVING_HURT, 2); diff --git a/src/main/java/org/spacehq/mc/protocol/data/game/entity/Effect.java b/src/main/java/org/spacehq/mc/protocol/data/game/entity/Effect.java index 4ca9f231..a8d02919 100644 --- a/src/main/java/org/spacehq/mc/protocol/data/game/entity/Effect.java +++ b/src/main/java/org/spacehq/mc/protocol/data/game/entity/Effect.java @@ -24,6 +24,10 @@ public enum Effect { WITHER_EFFECT, HEALTH_BOOST, ABSORPTION, - SATURATION; + SATURATION, + GLOWING, + LEVITATION, + LUCK, + BAD_LUCK; }