From da9718c69c5a98ac238b6d8601b8ee53b341d4f5 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Tue, 17 Jan 2023 13:50:55 +0100 Subject: [PATCH] add additional Entity data --- .../src/de/steamwar/entity/RArmorStand.java | 2 +- SpigotCore_Main/src/de/steamwar/entity/REntity.java | 12 +++++++++--- SpigotCore_Main/src/de/steamwar/entity/RPlayer.java | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java b/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java index 5513d2b..152e858 100644 --- a/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java +++ b/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java @@ -52,7 +52,7 @@ public class RArmorStand extends REntity { private final Size size; public RArmorStand(REntityServer server, Location location, Size size) { - super(server, EntityType.ARMOR_STAND, location); + super(server, EntityType.ARMOR_STAND, location,0); this.size = size; } diff --git a/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore_Main/src/de/steamwar/entity/REntity.java index 9fba9ec..58a7720 100644 --- a/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -64,15 +64,17 @@ public class REntity { private boolean noGravity; private boolean isGlowing; private int fireTick; + + private final int objectData; @Getter private String displayName; protected final Map itemSlots; - public REntity(REntityServer server, EntityType entityType, Location location) { - this(server, entityType, new UUID(random.nextLong() & -61441L | 16384L, random.nextLong() & 4611686018427387903L | -9223372036854775808L), location); + public REntity(REntityServer server, EntityType entityType, Location location,int objectData) { + this(server, entityType, new UUID(random.nextLong() & -61441L | 16384L, random.nextLong() & 4611686018427387903L | -9223372036854775808L), location,objectData); } - protected REntity(REntityServer server, EntityType entityType, UUID uuid, Location location) { + protected REntity(REntityServer server, EntityType entityType, UUID uuid, Location location,int objectData) { this.server = server; this.entityType = entityType; this.entityId = entityIdCounter--; @@ -89,6 +91,8 @@ public class REntity { this.noGravity = false; this.isGlowing = false; + this.objectData = objectData; + server.addEntity(this); } @@ -369,11 +373,13 @@ public class REntity { protected static Function spawnPacketGenerator(Class spawnPacket, int posOffset) { Reflection.FieldAccessor entityId = Reflection.getField(spawnPacket, int.class, 0); + Reflection.FieldAccessor additionalData = Reflection.getField(spawnPacket, int.class, 9); BountifulWrapper.PositionSetter position = BountifulWrapper.impl.getPositionSetter(spawnPacket, posOffset); return entity -> { Object packet = Reflection.newInstance(spawnPacket); entityId.set(packet, entity.entityId); + additionalData.set(packet,entity.objectData); position.set(packet, entity.x, entity.y, entity.z); return packet; }; diff --git a/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java b/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java index c5a080b..fa6d513 100644 --- a/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java +++ b/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java @@ -76,7 +76,7 @@ public class RPlayer extends REntity { private final String name; public RPlayer(REntityServer server, UUID uuid, String name, Location location) { - super(server, EntityType.PLAYER, uuid, location); + super(server, EntityType.PLAYER, uuid, location,0); this.name = name; //team.addEntry(name); }