mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-17 02:34:30 +01:00
Expose the Entity Counter to allow plugins to use valid and non-conflicting Entity Ids
This commit is contained in:
parent
6fea984629
commit
28be3aae37
2 changed files with 62 additions and 0 deletions
Spigot-API-Patches
Spigot-Server-Patches
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MeFisto94 <MeFisto94@users.noreply.github.com>
|
||||
Date: Fri, 28 Aug 2020 01:41:31 +0200
|
||||
Subject: [PATCH] Expose the Entity Counter to allow plugins to use valid and
|
||||
non-conflicting Entity Ids
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -0,0 +0,0 @@ public interface UnsafeValues {
|
||||
* @return the translation key
|
||||
*/
|
||||
String getTranslationKey(org.bukkit.entity.EntityType type);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates and returns the next EntityId available.
|
||||
+ * <p>
|
||||
+ * Use this when sending custom packets, so that there are no collisions on the client or server.
|
||||
+ */
|
||||
+ public int nextEntityId();
|
||||
+
|
||||
// Paper end
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
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/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
return net.minecraft.server.EntityTypes.getByName(type.getName()).map(net.minecraft.server.EntityTypes::getDescriptionId).orElse(null);
|
||||
}
|
||||
|
||||
+ public int nextEntityId() {
|
||||
+ return net.minecraft.server.Entity.nextEntityId();
|
||||
+ }
|
||||
+
|
||||
// Paper end
|
||||
|
||||
/**
|
Loading…
Add table
Reference in a new issue