From a1ee630f230ea1c9d1c56a7dfbbc7b8886f793db Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Wed, 1 Jan 2025 22:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=BD=9C=E8=A1=8C=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mixins/PlayerEntityMixin.java | 34 +++++++++++++++++++ src/main/resources/mixins.superbwarfare.json | 3 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/atsuishio/superbwarfare/mixins/PlayerEntityMixin.java 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",