testserver/Spigot-Server-Patches/0573-Expose-the-Entity-Coun...

38 lines
1.7 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MeFisto94 <MeFisto94@users.noreply.github.com>
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
2021-03-16 13:04:28 +00:00
index 0a853ffc658d8e82c21af7853bdaa9112a4e1e20..1b3371b087efa8c184f3c07fe560a709f76db4f7 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2021-03-16 13:04:28 +00:00
@@ -3473,4 +3473,10 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
void accept(Entity entity, double d0, double d1, double d2);
}
+
+ // Paper start
+ public static int nextEntityId() {
+ return entityCount.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 6fbface979f6f9ed97bb39ca91a29bffe05fddda..25af57d0ab191f6a29ae95cec764667e9c23bdd4 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -420,6 +420,10 @@ public final class CraftMagicNumbers implements UnsafeValues {
return net.minecraft.world.entity.EntityTypes.getByName(type.getName()).map(net.minecraft.world.entity.EntityTypes::getDescriptionId).orElse(null);
}
+ public int nextEntityId() {
+ return net.minecraft.world.entity.Entity.nextEntityId();
+ }
+
// Paper end
/**