From 4ac69574270922c76dd1e77ed6f42151d5aa78bc Mon Sep 17 00:00:00 2001 From: Floral <49110090+floral-qua-floral@users.noreply.github.com> Date: Tue, 26 Nov 2024 23:42:39 -0500 Subject: [PATCH] Fixed issues with vanilla jump function overriding Mario's jump velocity while crouch-jumping (why??) --- .../actions/AirborneActionDefinition.java | 1 - .../mariodata/MarioDataPackets.java | 4 ++- .../mixin/PlayerEntityMixin.java | 29 ++++--------------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/api/src/main/java/com/floralquafloral/definitions/actions/AirborneActionDefinition.java b/api/src/main/java/com/floralquafloral/definitions/actions/AirborneActionDefinition.java index be1fa22..8885527 100644 --- a/api/src/main/java/com/floralquafloral/definitions/actions/AirborneActionDefinition.java +++ b/api/src/main/java/com/floralquafloral/definitions/actions/AirborneActionDefinition.java @@ -95,7 +95,6 @@ public abstract static class AerialStats { if(yVel > terminalVelocity) { CharaStat useGravity = (ACTION_JUMP_GRAVITY == null || data.getTimers().jumpCapped) ? ACTION_GRAVITY : ACTION_JUMP_GRAVITY; - LoggerFactory.getLogger("test").info("use gravity {}", useGravity.get(data)); yVel += useGravity.get(data); data.setYVel(Math.max(terminalVelocity, yVel)); diff --git a/mod/src/main/java/com/floralquafloral/mariodata/MarioDataPackets.java b/mod/src/main/java/com/floralquafloral/mariodata/MarioDataPackets.java index 44d25f5..282908b 100644 --- a/mod/src/main/java/com/floralquafloral/mariodata/MarioDataPackets.java +++ b/mod/src/main/java/com/floralquafloral/mariodata/MarioDataPackets.java @@ -2,6 +2,7 @@ import com.floralquafloral.MarioPackets; import com.floralquafloral.MarioQuaMario; +import com.floralquafloral.mariodata.moveable.MarioServerData; import com.floralquafloral.registries.RegistryManager; import com.floralquafloral.registries.states.action.ParsedAction; import com.floralquafloral.registries.states.character.ParsedCharacter; @@ -74,8 +75,9 @@ public static String setMarioEnabled(ServerPlayerEntity player, boolean enabled) } public static boolean setMarioAction(ServerPlayerEntity mario, ParsedAction action, long seed, boolean networkToMario) { - MarioPlayerData data = getMarioData(mario); + MarioServerData data = (MarioServerData) getMarioData(mario); boolean foundTransition = data.getAction().transitionTo(data, action, seed); + data.applyModifiedVelocity(); if(foundTransition || !mario.getWorld().getGameRules().getBoolean(MarioQuaMario.REJECT_INVALID_ACTION_TRANSITIONS)) { data.setActionTransitionless(action); SetActionS2CPayload payload = new SetActionS2CPayload(mario, action, false, seed); diff --git a/mod/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java b/mod/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java index 019cbba..1dc3134 100644 --- a/mod/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java +++ b/mod/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java @@ -1,17 +1,14 @@ package com.floralquafloral.mixin; -import com.floralquafloral.MarioQuaMario; -import com.floralquafloral.mariodata.MarioClientSideData; import com.floralquafloral.mariodata.MarioDataManager; import com.floralquafloral.mariodata.MarioPlayerData; -import com.floralquafloral.mariodata.MarioTravelData; import com.floralquafloral.mariodata.moveable.MarioMoveableData; -import com.floralquafloral.mariodata.moveable.MarioServerData; import com.floralquafloral.registries.states.character.ParsedCharacter; import com.floralquafloral.registries.states.powerup.ParsedPowerUp; -import net.minecraft.entity.Entity; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityPose; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; @@ -101,22 +98,8 @@ public void changeDismounting(CallbackInfoReturnable cir) { } } -// @Inject(method = "attack", at = @At("HEAD"), cancellable = true) -// public void interceptUnarmedAttacks(Entity target, CallbackInfo ci) { -// PlayerEntity player = (PlayerEntity) (Object) this; -// if(!target.isAttackable() || target.handleAttack(player)) return; -// -// if(player.isUsingRiptide() || !player.getWeaponStack().isEmpty()) return; -// -// MarioPlayerData data = MarioDataManager.getMarioData(player); -// if(data.getAction().interceptAttack( -// data, -// data instanceof MarioClientSideData clientData ? clientData : null, -// data instanceof MarioTravelData travelData ? travelData : null, -// target, null -// )) ci.cancel(); -// -// MarioQuaMario.LOGGER.info("Intercepted unarmed attack!!!"); -// ci.cancel(); -// } + @WrapWithCondition(method = "jump", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;jump()V")) + private boolean preventLivingEntityJump(LivingEntity instance) { + return !MarioDataManager.getMarioData(this).useMarioPhysics(); + } }