From be12795676ef628e07d4c044dc57823ecaab3bff Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Sat, 5 Mar 2022 14:35:30 -0800 Subject: [PATCH] Redirect isSteppingCarefully for better sponge compatibility Signed-off-by: Gabriel Harris-Rouquette --- .../abnormals_core/core/mixin/EntityMixin.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/minecraftabnormals/abnormals_core/core/mixin/EntityMixin.java b/src/main/java/com/minecraftabnormals/abnormals_core/core/mixin/EntityMixin.java index cd0f8288..41ad9e50 100644 --- a/src/main/java/com/minecraftabnormals/abnormals_core/core/mixin/EntityMixin.java +++ b/src/main/java/com/minecraftabnormals/abnormals_core/core/mixin/EntityMixin.java @@ -8,7 +8,6 @@ import com.minecraftabnormals.abnormals_core.common.world.storage.tracking.TrackedDataManager; import com.minecraftabnormals.abnormals_core.core.AbnormalsCore; import com.minecraftabnormals.abnormals_core.core.events.EntityWalkEvent; -import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; @@ -28,9 +27,12 @@ import java.util.Set; @Mixin(Entity.class) -public final class EntityMixin implements IDataManager { +public abstract class EntityMixin implements IDataManager { @Shadow - private World level; + public World level; + + @Shadow + protected abstract BlockPos getOnPos(); private Map, DataEntry> dataMap = Maps.newHashMap(); private boolean dirty = false; @@ -131,10 +133,11 @@ public void read(CompoundNBT compound, CallbackInfo info) { } } - @Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;stepOn(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/Entity;)V")) - private void onEntityWalk(Block block, World world, BlockPos pos, Entity entity) { - if (!EntityWalkEvent.onEntityWalk(world, pos, entity)) { - block.stepOn(world, pos, entity); + @Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isSteppingCarefully()Z")) + private boolean checkIsSteppingCarefullyAndCanEntityWalkOn(Entity instance) { + if (!instance.isSteppingCarefully()) { + return false; } + return !EntityWalkEvent.onEntityWalk(this.level, this.getOnPos(), instance); } }