From 4da3153cdd7399649c7d890ac0c4f13ed565eb36 Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 26 Mar 2018 14:39:28 +0800 Subject: [PATCH] Fix shulker color and playing sounds --- main/src/main/java/net/citizensnpcs/trait/ShulkerTrait.java | 6 +++++- .../citizensnpcs/nms/v1_11_R1/entity/ShulkerController.java | 2 +- .../java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/trait/ShulkerTrait.java b/main/src/main/java/net/citizensnpcs/trait/ShulkerTrait.java index c96bbd8e5..809df311d 100644 --- a/main/src/main/java/net/citizensnpcs/trait/ShulkerTrait.java +++ b/main/src/main/java/net/citizensnpcs/trait/ShulkerTrait.java @@ -12,6 +12,7 @@ import net.citizensnpcs.util.NMS; public class ShulkerTrait extends Trait { @Persist("color") private DyeColor color = DyeColor.PURPLE; + private int lastPeekSet = 0; @Persist("peek") private int peek = 0; @@ -30,7 +31,10 @@ public class ShulkerTrait extends Trait { color = DyeColor.PURPLE; } if (npc.getEntity() instanceof Shulker) { - NMS.setShulkerPeek((Shulker) npc.getEntity(), peek); + if (peek != lastPeekSet) { + NMS.setShulkerPeek((Shulker) npc.getEntity(), peek); + lastPeekSet = peek; + } NMS.setShulkerColor((Shulker) npc.getEntity(), color); } } diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/ShulkerController.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/ShulkerController.java index 1964fa055..650b4d47b 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/ShulkerController.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/ShulkerController.java @@ -196,7 +196,7 @@ public class ShulkerController extends MobEntityController { } public void setColor(DyeColor color) { - this.datawatcher.set(bw, color.getDyeData()); + this.datawatcher.set(bw, color.getWoolData()); } @Override diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java index 61545f03c..4d2296470 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java @@ -963,7 +963,7 @@ public class NMSImpl implements NMSBridge { @Override public void setShulkerColor(Shulker shulker, DyeColor color) { - ((EntityShulker) getHandle(shulker)).getDataWatcher().set(EntityShulker.COLOR, color.getDyeData()); + ((EntityShulker) getHandle(shulker)).getDataWatcher().set(EntityShulker.COLOR, color.getWoolData()); } @Override