3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/server/0408-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch

39 Zeilen
1.7 KiB
Diff

2021-06-11 14:02:28 +02:00
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 2c9e57436469f94beb45f656a1df71aba7b1e408..c3e28cc070993be5afe9323c2c2d54ffc81d82f3 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
2024-10-23 17:13:43 +02:00
@@ -4704,4 +4704,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
2021-06-11 14:02:28 +02:00
void accept(Entity entity, double x, double y, double z);
}
+
+ // Paper start - Expose entity id counter
2021-06-11 14:02:28 +02:00
+ public static int nextEntityId() {
+ return ENTITY_COUNTER.incrementAndGet();
+ }
+ // Paper end - Expose entity id counter
2021-06-11 14:02:28 +02:00
}
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
2021-06-11 14:02:28 +02:00
--- 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;
2021-06-11 14:02:28 +02:00
}
+
+ @Override
2021-06-11 14:02:28 +02:00
+ public int nextEntityId() {
+ return net.minecraft.world.entity.Entity.nextEntityId();
+ }
// Paper end
2024-10-27 18:11:15 +01:00
/**