From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Fri, 28 Aug 2020 01:41:26 +0200 Subject: [PATCH] Expose the Entity Counter to allow plugins to use valid and non-conflicting Entity Ids diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index f8fd729d53248c7598a118d89fedf340f82cdd61..ac1b2b3982e5ceb8fecf20867dd2ac6e143463c3 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -4704,4 +4704,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess void accept(Entity entity, double x, double y, double z); } + + // Paper start - Expose entity id counter + public static int nextEntityId() { + return ENTITY_COUNTER.incrementAndGet(); + } + // Paper end - Expose entity id counter } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index f78459e65fd27a5fd9839d2ad1c95758c8d95489..249c0f717a80b9ca8e200ebdbf72a0dc4c3730cc 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -511,6 +511,11 @@ public final class CraftMagicNumbers implements UnsafeValues { Preconditions.checkArgument(dataVersion <= getDataVersion(), "Newer version! Server downgrades are not supported!"); return compound; } + + @Override + public int nextEntityId() { + return net.minecraft.world.entity.Entity.nextEntityId(); + } // Paper end @Override