93 lines
4.0 KiB
Diff
93 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Blast-MC <cjblanton2@gmail.com>
|
|
Date: Mon, 15 Jan 2024 16:39:10 -0500
|
|
Subject: [PATCH] Entity Data Storage
|
|
|
|
|
|
diff --git a/src/main/java/gg/projecteden/parchment/entity/EntityDataServices.java b/src/main/java/gg/projecteden/parchment/entity/EntityDataServices.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..30f8fd154136d05267e8737ff04a0be45b23a35d
|
|
--- /dev/null
|
|
+++ b/src/main/java/gg/projecteden/parchment/entity/EntityDataServices.java
|
|
@@ -0,0 +1,16 @@
|
|
+package gg.projecteden.parchment.entity;
|
|
+
|
|
+public class EntityDataServices {
|
|
+
|
|
+ private static boolean initialized;
|
|
+
|
|
+ public static void init() {
|
|
+ if (initialized) {
|
|
+ throw new RuntimeException("EntityData Services already initialized");
|
|
+ }
|
|
+ initialized = true;
|
|
+
|
|
+ // Initialize Services Here
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index 6de6dad36203479677a29ad61e21bc369d4e5513..4718291014acba4fac77fe18766b46bf9e7b3277 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -268,6 +268,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
return false;
|
|
}
|
|
|
|
+ gg.projecteden.parchment.entity.EntityDataServices.init();
|
|
+
|
|
// CraftBukkit start
|
|
// this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up
|
|
this.server.loadPlugins();
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 2c06f3ebf7e1069727387bfc60db30c958c14b5a..95a732d2ff7bf604e1640015552495e14b3ff2a4 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -160,6 +160,31 @@ import org.bukkit.plugin.PluginManager;
|
|
|
|
public abstract class Entity implements Nameable, EntityAccess, CommandSource, ScoreHolder {
|
|
|
|
+ @javax.annotation.Nullable
|
|
+ private gg.projecteden.parchment.entity.EntityData storedEntityData;
|
|
+
|
|
+ /**
|
|
+ * Retrieves the stored EntityData for this entity
|
|
+ * @return The currently stored EntityData
|
|
+ */
|
|
+ public gg.projecteden.parchment.entity.EntityData getStoredEntityData() {
|
|
+ if (this.storedEntityData == null) {
|
|
+ this.storedEntityData = gg.projecteden.parchment.entity.EntityData.create(this.getBukkitEntity());
|
|
+ }
|
|
+ return this.storedEntityData;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Clears the currently stored EntityData for this entity
|
|
+ * @return the previously stored EntityData
|
|
+ */
|
|
+ public @javax.annotation.Nullable gg.projecteden.parchment.entity.EntityData clearStoredEntityData() {
|
|
+ gg.projecteden.parchment.entity.EntityData data = this.storedEntityData;
|
|
+ this.storedEntityData = null;
|
|
+
|
|
+ return data;
|
|
+ }
|
|
+
|
|
// CraftBukkit start
|
|
private static final int CURRENT_LEVEL = 2;
|
|
public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first setPositionRotation
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index 8698104e3eb98e2cc5da5de87a8f538860c1d91d..269ad2696e07a602ca350284c32771a02dcdff08 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -77,6 +77,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
};
|
|
// Paper end - Folia schedulers
|
|
|
|
+ public gg.projecteden.parchment.entity.EntityData getStoredEntityData() {
|
|
+ return this.entity.getStoredEntityData();
|
|
+ }
|
|
+
|
|
public CraftEntity(final CraftServer server, final Entity entity) {
|
|
this.server = server;
|
|
this.entity = entity;
|