Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect isSteppingCarefully for better sponge compatibility #146

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this private.

Suggested change
public World level;
private World level;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but the field itself is public, Shadows should normally retain the same access level as their targets, regardless whether their intended uses are internal or external to the mixin in question.


@Shadow
protected abstract BlockPos getOnPos();

private Map<TrackedData<?>, DataEntry<?>> dataMap = Maps.newHashMap();
private boolean dirty = false;
Expand Down Expand Up @@ -131,10 +133,8 @@ 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 onIsSteppingCarefully(Entity instance) {
return instance.isSteppingCarefully() && !EntityWalkEvent.onEntityWalk(this.level, this.getOnPos(), instance);
}
}