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 906a5cc5671b707ef90d1f25d8ba5642c7a483bc..3f0a44db707176c25e306f55fa63da9314d682a1 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -4734,4 +4734,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 b50d1ddfd23bf1af16d86e5edcb72196b4674868..09a6a0c06580aea9e7be8de2189673d1a476f411 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -527,6 +527,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 /**