Use a hanging bat for sitting parrot

This commit is contained in:
Matsv 2017-06-14 15:16:52 +02:00
parent 4928dab3f0
commit a23204a86c
No known key found for this signature in database
GPG Key ID: 97CEC2A2EA31350F
2 changed files with 17 additions and 2 deletions

View File

@ -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;
}

View File

@ -413,15 +413,29 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
// 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