mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-20 07:19:33 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@1e7dd72 Remove 'fix Vanilla Minecart speed' patch (#10068) PaperMC/Paper@e7e1c8a Fix and add new scoreboard API (#10037) PaperMC/Paper@49f9f6f Add Registry#getKey (#10066) PaperMC/Paper@4adca3d Update to adventure 4.15 (#10045) PaperMC/Paper@ff7b9b0 Increase default custom payload channel size limit (#10006) PaperMC/Paper@1cda66e Hotfix Entity isInRain reobf issue PaperMC/Paper@61768e0 [ci skip] Remove no longer needed mappings change PaperMC/Paper@e035fd7 Updated Upstream (Bukkit/CraftBukkit/Spigot) PaperMC/Paper@c215ce1 [ci skip] cleanup patch diff from last commit PaperMC/Paper@4fdda9e Keep newlines in outdated client/server message (#10042) PaperMC/Paper@f483b38 fix NPE on EntityTeleportEvent getTo (#10016) PaperMC/Paper@dc62150 Catch async usage of playsound (#10021) PaperMC/Paper@0d6a0c3 Fix command block async message (again) (#10082) PaperMC/Paper@d1f507f Don't fire 2 game events for certain cauldron interactions (#8904) PaperMC/Paper@a401585 Fix campfire recipes not always outputting full result (#8754) PaperMC/Paper@88d28d6 Fix long loading screen when refreshing skins (#10026) PaperMC/Paper@c081104 Add experience points api (#9688) PaperMC/Paper@8221b08 Fix global sound event gamerule not being respected (#8727) PaperMC/Paper@3c0d6aa Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10085) PaperMC/Paper@2c3ccb8 Add drops to shear events (#5678) PaperMC/Paper@b2ffb1b Add PlayerShieldDisableEvent (#9177) PaperMC/Paper@2951732 Add HiddenPotionEffect API (#9910) PaperMC/Paper@e4ab50d Properly disallow async Player#chat (#8123) PaperMC/Paper@5e978d3 Fix Folia scheduler tasks not canceling when plugin disable (#10091) PaperMC/Paper@e56e53f Fix some component bugs in login disconnect packet (#10090) PaperMC/Paper@3484ae9 Call entity_die game event after event cancel check (#10096) PaperMC/Paper@0ae58c0 cleanup player death event adventure logic (#10095) PaperMC/Paper@1281f4f Make region/lock shift accessors per world PaperMC/Paper@983377b Correctly check if bucket dispenses will succeed for event (#10109) PaperMC/Paper@58e120b [ci skip] Remove extraneous diff added in 1.20.3 update (#10101) PaperMC/Paper@816bacc Call EntityChangeBlockEvent for cake eating (#10105) PaperMC/Paper@692db0c fix CustomModelData being removed (#10113) PaperMC/Paper@509876d Keep fully frozen entities fully activated (#10103) PaperMC/Paper@1fa48d1 include relative flags in PlayerTeleportEvent (#8190) PaperMC/Paper@ae001ae Fix untrack event not being called for all 'untracks' (#10110) PaperMC/Paper@259bc76 Pass system properties to maven repo session (#10117) PaperMC/Paper@b2a6d57 Validate ResourceLocation in NBT reading PaperMC/Paper@7eaff48 [ci skip] Replace some magic values with constant references PaperMC/Paper@19a6202 Fix experience & improvements to block events (#8067) PaperMC/Paper@8379027 Fix cmd permission levels for command blocks (#7404) PaperMC/Paper@a93acc4 Fix EntityChangePoseEvent being called during worldgen (#10120) PaperMC/Paper@25a99b1 Fix BlockDestroyEvents effectBlock not being set (#10131) PaperMC/Paper@a58e29d Fix a borked update of 'Properly handle BlockBreakEvent#isDropItems' (#10134) PaperMC/Paper@570cfb4 Validate missed resource location parsing PaperMC/Paper@e46276e Fixup NamespacedKey parsing PaperMC/Paper@f1c5f01 [ci skip] Fix typo PaperMC/Paper@07b956e Fix tests by disabling them
105 lines
4.4 KiB
Diff
105 lines
4.4 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..c9f2c5ae57878283e8c8bc3847fe63b98f4e8d10
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/entity/EntityState.java
|
|
@@ -0,0 +1,41 @@
|
|
+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(position);
|
|
+ entity.setDeltaMovement(momentum);
|
|
+ entity.setBoundingBox(bb);
|
|
+ // null here is only safe for our use case (tnt and sand)
|
|
+ //noinspection DataFlowIssue
|
|
+ entity.makeStuckInBlock(null, stuckSpeed);
|
|
+ entity.onGround = onGround;
|
|
+ entity.mainSupportingBlockPos = supportingPos;
|
|
+ entity.fallDistance = fallDistance;
|
|
+ }
|
|
+
|
|
+ public void position(Entity entity) {
|
|
+ entity.setPos(position);
|
|
+ entity.setBoundingBox(bb);
|
|
+ }
|
|
+
|
|
+ public boolean isCurrentState(Entity entity) {
|
|
+ return entity.position().equals(position)
|
|
+ && entity.getDeltaMovement().equals(momentum);
|
|
+ // 1.14+ versions seem to correct morphed bounding boxes after a gametick.
|
|
+ // If there are any related issues uncomment this line of code.
|
|
+ // && entity.getBoundingBox().equals(bb);
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 7fad22ee8a24399acbae6a9bc07ad5de39d41020..393e951102c49d45a135b37ccd876283c5355710 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -550,6 +550,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
|
return flags;
|
|
}
|
|
// Sakura end
|
|
+ // Sakura start - entity state (from start of tick)
|
|
+ private @Nullable me.samsuik.sakura.entity.EntityState entityState = null;
|
|
+
|
|
+ public Vec3 stuckSpeedMultiplier() {
|
|
+ return stuckSpeedMultiplier;
|
|
+ }
|
|
+
|
|
+ public void storeEntityState() {
|
|
+ entityState = me.samsuik.sakura.entity.EntityState.of(this);
|
|
+ }
|
|
+
|
|
+ public @Nullable me.samsuik.sakura.entity.EntityState entityState() {
|
|
+ return entityState;
|
|
+ }
|
|
+
|
|
+ public boolean compareState(Entity to) {
|
|
+ return to.entityState() != null && to.entityState().isCurrentState(this);
|
|
+ }
|
|
+
|
|
+ public long getPackedOrigin() {
|
|
+ var v = getOriginVector();
|
|
+ if (v == null) return Long.MIN_VALUE;
|
|
+ // Note: vector#getBlockN may not be 100% exact
|
|
+ // If there's any future issues at let's say 0.999999...
|
|
+ // giving an incorrect position change it to Mth instead.
|
|
+ return BlockPos.asLong(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
|
+ }
|
|
+ // Sakura end
|
|
|
|
public boolean isLegacyTrackingEntity = false;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index bf361855ecf8c1d5dee2e735278243b836bf0f2a..902ec524d209ab56a6dadb260559910c76dbf96b 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -1342,6 +1342,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
|
|
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
|
|
try {
|
|
+ entity.storeEntityState(); // Sakura - store entity state
|
|
tickConsumer.accept(entity);
|
|
MinecraftServer.getServer().executeMidTickTasks(); // Paper - execute chunk tasks mid tick
|
|
} catch (Throwable throwable) {
|