[Compat] Support for demagnetizers
Jophire opened this issue ยท 0 comments
Hello, I would like to request a change to the magnet ability.
Please add a check for the PreventRemoteMovement tag. This will fix issues where the player is grabbing items when walking by machines.
@Override
public void tick(PlayerSkillData data)
{
if(data.magnetism && data.magnetismRange > 1F)
{
var pos = data.player.getBoundingBox().getCenter();
for(var ie : data.player.level().getEntitiesOfClass(ItemEntity.class, new AABB(pos.x, pos.y, pos.z, pos.x, pos.y, pos.z).inflate(data.magnetismRange)))
{
if (!ie.getPersistentData().getBoolean("PreventRemoteMovement"))
{
ie.setDeltaMovement(
ie.getDeltaMovement()
.scale(0.98F)
.add(
data.player.position()
.subtract(ie.position())
.normalize()
.multiply(0.1F, 0.2F, 0.1F)
)
);
}
}
}
}