mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 16:29:16 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@691d452 Fix bundled spark permission check (#11355) PaperMC/Paper@012c527 Update Velocity natives (#11347) PaperMC/Paper@953e6e9 Fire BlockExpEvent on grindstone use (#11346) PaperMC/Paper@10f5879 Change condition check order of entity tracking Y (#11348) PaperMC/Paper@805a974 Improve console completion with brig suggestions (#9251) PaperMC/Paper@e0021b1 Fix allowSpiderWorldBorderClimbing world config (#11321) PaperMC/Paper@3db4758 Check dead flag in isAlive() (#11330) PaperMC/Paper@21f125f Revert velocity natives to 3.1.2 (#11368) PaperMC/Paper@0e82527 Fix NPE while trying to respawn an already disconnected player (#11353) PaperMC/Paper@5d91bef Fix shulkerbox loot table replenish (#11366) PaperMC/Paper@a8e6a93 Deprecate for removal all OldEnum-related methods (#11371) PaperMC/Paper@925c3b9 Add FeatureFlag API (#8952) PaperMC/Paper@426f992 Enchantment is data-driven, so not FeatureDependant (#11377) PaperMC/Paper@1ba1be7 Update Velocity natives again PaperMC/Paper@7632de5 Tag Lifecycle Events (#10993) PaperMC/Paper@b09eaf2 Add Item serialization as json api (#11235) PaperMC/Paper@971a7a5 Add Decorated Pot Cracked API (#11365) PaperMC/Paper@61fe23c deprecate isEnabledByFeature in Item/BlockType PaperMC/Paper@e945cfe Fix PaperServerListPingEvent#getPlayerSample not being populated or used (#11387) PaperMC/Paper@4ff58c4 Update spark PaperMC/Paper@d1a72ea Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11405) PaperMC/Paper@0a53f1d Set default drop behavior for player deaths (#11380) PaperMC/Paper@951e7dd Fix TrialSpawner forgetting assigned mob when placed by player (#11381) PaperMC/Paper@13a2395 Fix enable-player-collisions playing sounds when set to false (#11390) PaperMC/Paper@1348e44 Prevent NPE when serializing unresolved profile (#11407) PaperMC/Paper@2aaf436 Validate slot in PlayerInventory#setSlot (#11399) PaperMC/Paper@5c82955 Only mark decorations dirty if a removal actually occurs (#11413) PaperMC/Paper@c5a1066 Remove wall-time / unused skip tick protection (#11412)
92 lines
4.1 KiB
Diff
92 lines
4.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
|
Date: Wed, 16 Aug 2023 22:34:49 +0100
|
|
Subject: [PATCH] Store Entity Data/State
|
|
|
|
|
|
diff --git a/src/main/java/me/samsuik/sakura/entity/EntityState.java b/src/main/java/me/samsuik/sakura/entity/EntityState.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..10630c7e04a137ce766f4a45cb0f2e51bd967c98
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/entity/EntityState.java
|
|
@@ -0,0 +1,37 @@
|
|
+package me.samsuik.sakura.entity;
|
|
+
|
|
+import net.minecraft.core.BlockPos;
|
|
+import net.minecraft.world.entity.Entity;
|
|
+import net.minecraft.world.phys.AABB;
|
|
+import net.minecraft.world.phys.Vec3;
|
|
+
|
|
+import java.util.Optional;
|
|
+
|
|
+public record EntityState(Vec3 position, Vec3 momentum, AABB bb, Vec3 stuckSpeed, Optional<BlockPos> supportingPos, boolean onGround, float fallDistance) {
|
|
+ public static EntityState of(Entity entity) {
|
|
+ return new EntityState(entity.position(), entity.getDeltaMovement(), entity.getBoundingBox(), entity.stuckSpeedMultiplier(), entity.mainSupportingBlockPos, entity.onGround(), entity.fallDistance);
|
|
+ }
|
|
+
|
|
+ public void apply(Entity entity) {
|
|
+ entity.setPos(this.position);
|
|
+ entity.setDeltaMovement(this.momentum);
|
|
+ entity.setBoundingBox(this.bb);
|
|
+ // null here is only safe for our use case (tnt and sand)
|
|
+ //noinspection DataFlowIssue
|
|
+ entity.makeStuckInBlock(null, this.stuckSpeed);
|
|
+ entity.onGround = this.onGround;
|
|
+ entity.mainSupportingBlockPos = this.supportingPos;
|
|
+ entity.fallDistance = this.fallDistance;
|
|
+ }
|
|
+
|
|
+ public void position(Entity entity) {
|
|
+ entity.setPos(this.position);
|
|
+ entity.setBoundingBox(this.bb);
|
|
+ }
|
|
+
|
|
+ public boolean isCurrentState(Entity entity) {
|
|
+ return entity.position().equals(this.position)
|
|
+ && entity.getDeltaMovement().equals(this.momentum);
|
|
+ // && entity.getBoundingBox().equals(bb); // uncomment if there are issues with morphed bounding boxes
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 1927afe8646219403e013c92a6da0a47caf5d7d5..3233e54b6f85ab03859b5a3f2912b7cfb115d050 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -567,6 +567,25 @@ 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 Vec3 stuckSpeedMultiplier() {
|
|
+ return this.stuckSpeedMultiplier;
|
|
+ }
|
|
+
|
|
+ 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(Entity to) {
|
|
+ return to.entityState() != null && to.entityState().isCurrentState(this);
|
|
+ }
|
|
+ // Sakura end - store entity data/state
|
|
|
|
public Entity(EntityType<?> type, Level world) {
|
|
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index c811bc64d0686fdec58defb707d57e539c261b48..0925de100a7da3bba6c3fab7a0c79b2ee0d86904 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -1430,6 +1430,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
|
|
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
|
|
try {
|
|
+ entity.storeEntityState(); // Sakura - store entity data/state
|
|
tickConsumer.accept(entity);
|
|
} catch (Throwable throwable) {
|
|
if (throwable instanceof ThreadDeath) throw throwable; // Paper
|