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 f8f0be4ebb097c26461ea0fcbce7914ce84e87ed..7fe47f6158ca78f522685762e1e990ff6e588b87 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -4308,4 +4308,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { void accept(Entity entity, double x, double y, double z); } + + // Paper start + public static int nextEntityId() { + return ENTITY_COUNTER.incrementAndGet(); + } + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index f6eae5756dd7919938ca8265bfeba84fba3ec644..8bd49ffe7e26e6309407830794fae6b7c91c5600 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -514,6 +514,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 /**