mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
Entity IDs should not be changing
Removing an entity from a client doesn't work if the ID has changed.
This commit is contained in:
parent
e47fc9765d
commit
63e1b263c2
@ -17,24 +17,24 @@ public class ArmorStandWrapper {
|
||||
private final Class<?> dataWatcherClass = Utils.getNMSClass("DataWatcher");
|
||||
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
|
||||
private final int entityId;
|
||||
|
||||
private ShopChest plugin;
|
||||
private Object entity;
|
||||
private Location location;
|
||||
private String customName;
|
||||
private int entityId = -1;
|
||||
|
||||
public ArmorStandWrapper(ShopChest plugin, Location location, String customName, boolean interactable) {
|
||||
this.plugin = plugin;
|
||||
this.location = location;
|
||||
this.customName = customName;
|
||||
this.entityId = Utils.getFreeEntityId();
|
||||
}
|
||||
|
||||
public void setVisible(Player player, boolean visible) {
|
||||
try {
|
||||
if (visible) {
|
||||
Object dataWatcher = Utils.createDataWatcher(customName, null);
|
||||
entityId = Utils.getFreeEntityId();
|
||||
Utils.sendPacket(plugin, Utils.createPacketSpawnEntity(plugin, entityId, uuid, location, EntityType.ARMOR_STAND), player);
|
||||
Utils.sendPacket(plugin, packetPlayOutEntityMetadataClass.getConstructor(int.class, dataWatcherClass, boolean.class)
|
||||
.newInstance(entityId, dataWatcher, true), player);
|
||||
|
@ -22,8 +22,7 @@ public class ShopItem {
|
||||
private final ItemStack itemStack;
|
||||
private final Location location;
|
||||
private final UUID uuid = UUID.randomUUID();
|
||||
|
||||
private int entityId = -1;
|
||||
private final int entityId;
|
||||
|
||||
private final Class<?> packetPlayOutEntityDestroyClass = Utils.getNMSClass("PacketPlayOutEntityDestroy");
|
||||
private final Class<?> packetPlayOutEntityVelocityClass = Utils.getNMSClass("PacketPlayOutEntityVelocity");
|
||||
@ -37,6 +36,7 @@ public class ShopItem {
|
||||
this.plugin = plugin;
|
||||
this.itemStack = itemStack;
|
||||
this.location = location;
|
||||
this.entityId = Utils.getFreeEntityId();
|
||||
|
||||
Class<?> entityClass = Utils.getNMSClass("Entity");
|
||||
|
||||
@ -91,7 +91,6 @@ public class ShopItem {
|
||||
try {
|
||||
Object nmsItemStack = craftItemStackClass.getMethod("asNMSCopy", ItemStack.class).invoke(null, itemStack);
|
||||
Object dataWatcher = Utils.createDataWatcher(null, nmsItemStack);
|
||||
entityId = Utils.getFreeEntityId();
|
||||
Utils.sendPacket(plugin, Utils.createPacketSpawnEntity(plugin, entityId, uuid, location, EntityType.DROPPED_ITEM), p);
|
||||
Utils.sendPacket(plugin, packetPlayOutEntityMetadataClass.getConstructor(int.class, dataWatcherClass, boolean.class).newInstance(entityId, dataWatcher, true), p);
|
||||
if (Utils.getMajorVersion() < 14) {
|
||||
|
Loading…
Reference in New Issue
Block a user