From a23204a86c10db9a7ea171a1ff05ba66294bb64d Mon Sep 17 00:00:00 2001 From: Matsv Date: Wed, 14 Jun 2017 15:16:52 +0200 Subject: [PATCH] Use a hanging bat for sitting parrot --- .../data/ParrotStorage.java | 1 + .../packets/EntityPackets1_12.java | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/data/ParrotStorage.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/data/ParrotStorage.java index 3f3abd51..e40497e5 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/data/ParrotStorage.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/data/ParrotStorage.java @@ -16,4 +16,5 @@ import nl.matsv.viabackwards.api.entities.storage.EntityStorage; @Data public class ParrotStorage extends EntityStorage { private boolean tamed = true; + private boolean sitting = true; } diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/packets/EntityPackets1_12.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/packets/EntityPackets1_12.java index c2aaee7e..19040b3b 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/packets/EntityPackets1_12.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/packets/EntityPackets1_12.java @@ -413,15 +413,29 @@ public class EntityPackets1_12 extends EntityRewriter { // Parrot remove animal metadata registerMetaHandler().filter(EntityType.PARROT, 12).removed(); // Is baby registerMetaHandler().filter(EntityType.PARROT, 13).handle(e -> { + Metadata data = e.getData(); ParrotStorage storage = e.getEntity().get(ParrotStorage.class); - boolean isTamed = (((byte) e.getData().getValue()) & 0x04) == 0x04; + boolean isSitting = (((byte) data.getValue()) & 0x01) == 0x01; + boolean isTamed = (((byte) data.getValue()) & 0x04) == 0x04; if (!storage.isTamed() && isTamed) { // TODO do something to let the user know it's done } storage.setTamed(isTamed); - throw new RemovedValueException(); + + if (isSitting) { + data.setId(12); + data.setValue((byte) 0x01); + storage.setSitting(true); + } else if (storage.isSitting()) { + data.setId(12); + data.setValue((byte) 0x00); + storage.setSitting(false); + } else + throw new RemovedValueException(); + + return data; }); // Flags (Is sitting etc, might be useful in the future registerMetaHandler().filter(EntityType.PARROT, 14).removed(); // Owner registerMetaHandler().filter(EntityType.PARROT, 15).removed(); // Variant