aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0421-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch
blob: 855bcf2639a71b2d57d6a3cc1150bd52726a72f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
index f5078b093b61dfe58e6fac24f59af945dd2f3df4..81ff696c34afffe6b1ee76347984b0d8cb5723e7 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4445,4 +4445,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 3547edda0db53ec6c59f30f478f1614bd932be02..390e8ebbc3d96cd6eaaae616d4366bfe52d6d62e 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -529,6 +529,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