From 0add346878c4ef980ce7a42358e16abb8499addf Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 23 Apr 2021 20:28:02 +0200 Subject: [PATCH] Fix REntity.setBowDrawn Fix PacketProcessor --- src/de/steamwar/spectatesystem/PacketProcessor.java | 4 ++-- src/de/steamwar/spectatesystem/elements/REntity.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/spectatesystem/PacketProcessor.java b/src/de/steamwar/spectatesystem/PacketProcessor.java index 971afe7..9f733a7 100644 --- a/src/de/steamwar/spectatesystem/PacketProcessor.java +++ b/src/de/steamwar/spectatesystem/PacketProcessor.java @@ -308,9 +308,9 @@ class PacketProcessor { private void bow() throws IOException { int entityId = source.rInt(); boolean drawn = source.rBoolean(); - int hand = source.rInt(); + boolean offHand = source.rBoolean(); - execSync(() -> REntity.getEntity(entityId).setBowDrawn(drawn, hand)); + execSync(() -> REntity.getEntity(entityId).setBowDrawn(drawn, offHand)); } private void damage() throws IOException { diff --git a/src/de/steamwar/spectatesystem/elements/REntity.java b/src/de/steamwar/spectatesystem/elements/REntity.java index ccc5171..2faa831 100644 --- a/src/de/steamwar/spectatesystem/elements/REntity.java +++ b/src/de/steamwar/spectatesystem/elements/REntity.java @@ -168,11 +168,11 @@ public abstract class REntity { sendDataWatcher(dataWatcher); } - public void setBowDrawn(boolean drawn, int hand) { + public void setBowDrawn(boolean drawn, boolean offHand) { DataWatcher dataWatcher = new DataWatcher(null); DataWatcherObject dataWatcherObject = new DataWatcherObject<>(7, DataWatcherRegistry.a); - dataWatcher.register(dataWatcherObject, (byte) ((drawn?1:0) + (hand * 2))); + dataWatcher.register(dataWatcherObject, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0))); dataWatcher.markDirty(dataWatcherObject); sendDataWatcher(dataWatcher);