diff --git a/src/de/steamwar/spectatesystem/PacketProcessor.java b/src/de/steamwar/spectatesystem/PacketProcessor.java index bf5b5d5..fe14625 100644 --- a/src/de/steamwar/spectatesystem/PacketProcessor.java +++ b/src/de/steamwar/spectatesystem/PacketProcessor.java @@ -305,8 +305,12 @@ class PacketProcessor { packetCounter.clear(); } - private void bow() { - //TODO implement Bow + private void bow() throws IOException { + int entityId = source.rInt(); + boolean drawn = source.rBoolean(); + int hand = source.rInt(); + + execSync(() -> REntity.getEntity(entityId).setBowDrawn(drawn, hand)); } private void damage() throws IOException { @@ -317,8 +321,9 @@ class PacketProcessor { private void fireTick() throws IOException { int entityId = source.rInt(); + boolean perma = source.rBoolean(); - execSync(() -> REntity.getEntity(entityId).setOnFire()); + execSync(() -> REntity.getEntity(entityId).setOnFire(perma)); } private void process(){ @@ -360,10 +365,14 @@ class PacketProcessor { fireballSpawn(); break; case 0x0A: + bow(); + break; case 0x0B: damage(); + break; case 0x0C: fireTick(); + break; case 0x30: block(); break; diff --git a/src/de/steamwar/spectatesystem/elements/REntity.java b/src/de/steamwar/spectatesystem/elements/REntity.java index 17a98a9..f2f651f 100644 --- a/src/de/steamwar/spectatesystem/elements/REntity.java +++ b/src/de/steamwar/spectatesystem/elements/REntity.java @@ -119,8 +119,9 @@ public abstract class REntity { } } - public void setOnFire() { - entity.setOnFire(21, false); + public void setOnFire(boolean perma) { + if(!perma) + entity.setOnFire(21, false); DataWatcher dataWatcher = new DataWatcher(null); @@ -135,6 +136,20 @@ public abstract class REntity { } } + public void setBowDrawn(boolean drawn, int hand) { + DataWatcher dataWatcher = new DataWatcher(null); + + DataWatcherObject dataWatcherObject = new DataWatcherObject<>(7, DataWatcherRegistry.a); + dataWatcher.register(dataWatcherObject, (byte) ((drawn?1:0) + (hand * 2))); + dataWatcher.markDirty(dataWatcherObject); + + PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false); + + for(Player player : Bukkit.getOnlinePlayers()){ + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } + } + public void damage() { PacketPlayOutEntityStatus packet = new PacketPlayOutEntityStatus(entity, (byte) 2);