Skip to content

Commit

Permalink
Fixed issues with vanilla jump function overriding Mario's jump veloc…
Browse files Browse the repository at this point in the history
…ity while crouch-jumping (why??)
  • Loading branch information
floral-qua-floral committed Nov 27, 2024
1 parent 4356235 commit 4ac6957
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
29 changes: 6 additions & 23 deletions mod/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -101,22 +98,8 @@ public void changeDismounting(CallbackInfoReturnable<Boolean> 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();
}
}

0 comments on commit 4ac6957

Please sign in to comment.