Rewrite Movement Mixin to Inject
This commit is contained in:
parent
ff6f17b330
commit
821c045980
1 changed files with 7 additions and 4 deletions
|
@ -11,7 +11,8 @@ import net.minecraft.world.World;
|
|||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(EntityPlayerSP.class)
|
||||
public class MixinEntityPlayerSP extends AbstractClientPlayer {
|
||||
|
@ -54,11 +55,13 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer {
|
|||
|
||||
|
||||
|
||||
@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;move(Lnet/minecraft/entity/MoverType;DDD)V"))
|
||||
public void move(AbstractClientPlayer abstractClientPlayer, MoverType type, double x, double y, double z) {
|
||||
MoveEvent event = new MoveEvent(type, x, y, z);
|
||||
@Inject(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;move(Lnet/minecraft/entity/MoverType;DDD)V"), cancellable = true)
|
||||
public void move(MoverType p_70091_1_, double p_70091_2_, double p_70091_4_, double p_70091_6_, CallbackInfo ci) {
|
||||
MoveEvent event = new MoveEvent(p_70091_1_, p_70091_2_, p_70091_4_, p_70091_6_);
|
||||
if(!BaseBand.eventManager.publish(event).isCancelled())
|
||||
super.move(event.type, event.x, event.y, event.z);
|
||||
else
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue