From cfbd75b67ef1daa5950e0332702766495918723d Mon Sep 17 00:00:00 2001 From: TudbuT Date: Mon, 10 Jun 2024 07:34:19 +0200 Subject: [PATCH] GOING INGAME! --- .../client/mixins/MixinEntityPlayerSP.java | 7 ++++++- .../com/baseband/client/mixins/MixinProxy.java | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java b/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java index 2271219..4eab497 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinEntityPlayerSP.java @@ -5,6 +5,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.MoverType; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -64,7 +65,11 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer { @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) { - MixinProxy.onMove(this, p_70091_1_, p_70091_2_, p_70091_4_, p_70091_6_, ci); + Object e = MixinProxy.onMove(p_70091_1_, p_70091_2_, p_70091_4_, p_70091_6_, ci); + if(!MixinProxy.MoveEventProxy.isCancelled(e)) { + Vec3d vec = MixinProxy.MoveEventProxy.getVec(e); + super.move(MixinProxy.MoveEventProxy.getType(e), vec.x, vec.y, vec.z); + } } } diff --git a/Client/src/main/java/com/baseband/client/mixins/MixinProxy.java b/Client/src/main/java/com/baseband/client/mixins/MixinProxy.java index 5fe03db..fcea41b 100644 --- a/Client/src/main/java/com/baseband/client/mixins/MixinProxy.java +++ b/Client/src/main/java/com/baseband/client/mixins/MixinProxy.java @@ -107,14 +107,26 @@ public class MixinProxy { BaseBand.publish(new MotionUpdateEvent.Post()); } - public static void onMove(AbstractClientPlayer p, MoverType p_70091_1_, double p_70091_2_, double p_70091_4_, double p_70091_6_, CallbackInfo ci) { + public static Object onMove(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.publish(event).isCancelled()) - p.move(event.type, event.x, event.y, event.z); ci.cancel(); + return BaseBand.publish(event); } public static void minecraftOnInit() { BaseBand.onInit(); } + + public static class MoveEventProxy { + public static boolean isCancelled(Object e) { + return ((com.baseband.client.event.events.MoveEvent) e).isCancelled(); + } + public static MoverType getType(Object e) { + return ((com.baseband.client.event.events.MoveEvent) e).type; + } + public static Vec3d getVec(Object e) { + com.baseband.client.event.events.MoveEvent ev = (com.baseband.client.event.events.MoveEvent) e; + return new Vec3d(ev.x, ev.y, ev.z); + } + } }