diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/PlayerEntityMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/PlayerEntityMixin.java new file mode 100644 index 000000000..e4fb193c5 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/PlayerEntityMixin.java @@ -0,0 +1,34 @@ +package com.atsuishio.superbwarfare.mixins; + +import com.atsuishio.superbwarfare.entity.VehicleEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = Player.class, priority = 1100) +public abstract class PlayerEntityMixin extends Entity { + public PlayerEntityMixin(EntityType type, Level world) { + super(type, world); + } + + @Inject(method = "wantsToStopRiding", at = @At("HEAD"), cancellable = true) + void shouldDismountInjection(CallbackInfoReturnable cir) { + if (this.getRootVehicle() instanceof VehicleEntity) { + cir.setReturnValue(false); + } + } + + @Inject(method = "updatePlayerPose()V", at = @At("TAIL")) + void updatePostInjection(CallbackInfo ci) { + if (getRootVehicle() instanceof VehicleEntity) { + this.setPose(Pose.STANDING); + } + } +} diff --git a/src/main/resources/mixins.superbwarfare.json b/src/main/resources/mixins.superbwarfare.json index d5e4c37fd..d9b1fad96 100644 --- a/src/main/resources/mixins.superbwarfare.json +++ b/src/main/resources/mixins.superbwarfare.json @@ -5,7 +5,8 @@ "refmap": "mixins.superbwarfare.refmap.json", "mixins": [ "ClientboundSetEntityMotionPacketMixin", - "LivingEntityMixin" + "LivingEntityMixin", + "PlayerEntityMixin" ], "client": [ "CameraMixin",