9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-21 15:59:26 +00:00
Files
SakuraMC/sakura-server/minecraft-patches/features/0007-Store-Entity-Data-State.patch
2025-09-29 01:59:24 +01:00

45 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Wed, 16 Aug 2023 22:34:49 +0100
Subject: [PATCH] Store Entity Data/State
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index a13f7613115f08461ed6852fd35bc19f4923063d..815f92176821bf4117952450e97bd5b044c78b58 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -550,6 +550,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return flags;
}
// Sakura end - load chunks on movement
+ // Sakura start - store entity data/state
+ private me.samsuik.sakura.entity.EntityState entityState = null;
+
+ public final void storeEntityState() {
+ this.entityState = me.samsuik.sakura.entity.EntityState.of(this);
+ }
+
+ public final me.samsuik.sakura.entity.EntityState entityState() {
+ return this.entityState;
+ }
+
+ public final boolean compareState(final Entity to) {
+ return to.entityState() != null && to.entityState().comparePositionAndMotion(this);
+ }
+ // Sakura end - store entity data/state
public Entity(EntityType<?> entityType, Level level) {
this.type = entityType;
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 44e4c907801b934c188cf67bf3c75023a52a948f..4ff7fdc9a75e7d31170385016bf8ea75c45719a1 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -1498,6 +1498,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
public <T extends Entity> void guardEntityTick(Consumer<T> consumerEntity, T entity) {
try {
+ entity.storeEntityState(); // Sakura - store entity data/state
consumerEntity.accept(entity);
} catch (Throwable var6) {
// Paper start - Prevent block entity and entity crashes