Skip to content

Commit

Permalink
Redirect isSteppingCarefully for better sponge compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Harris-Rouquette <[email protected]>
  • Loading branch information
gabizou committed Mar 5, 2022
1 parent 2db23cd commit be12795
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<TrackedData<?>, DataEntry<?>> dataMap = Maps.newHashMap();
private boolean dirty = false;
Expand Down Expand Up @@ -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);
}
}

0 comments on commit be12795

Please sign in to comment.