-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More mixins; useMarioPhysics from old version
- Loading branch information
1 parent
cb47b45
commit d40b45a
Showing
19 changed files
with
375 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ | |
public enum EvaluatorEnvironment { | ||
CLIENT_ONLY, | ||
SERVER_ONLY, | ||
COMMON | ||
COMMON, | ||
CLIENT_CHECKED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
content/src/main/java/com/fqf/mario_qua_mario/actions/grounded/WalkRun.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.fqf.mario_qua_mario.actions.grounded; | ||
|
||
import com.fqf.mario_qua_mario.MarioQuaMarioContent; | ||
import com.fqf.mario_qua_mario.definitions.states.actions.GroundedActionDefinition; | ||
import com.fqf.mario_qua_mario.definitions.states.actions.util.*; | ||
import com.fqf.mario_qua_mario.mariodata.IMarioAuthoritativeData; | ||
import com.fqf.mario_qua_mario.mariodata.IMarioClientData; | ||
import com.fqf.mario_qua_mario.mariodata.IMarioReadableMotionData; | ||
import com.fqf.mario_qua_mario.mariodata.IMarioTravelData; | ||
import com.fqf.mario_qua_mario.util.CharaStat; | ||
import net.minecraft.util.Identifier; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static com.fqf.mario_qua_mario.util.StatCategory.*; | ||
import static com.fqf.mario_qua_mario.util.StatCategory.OVERSPEED_CORRECTION; | ||
|
||
public class WalkRun extends SubWalk implements GroundedActionDefinition { | ||
@Override public @NotNull Identifier getID() { | ||
return MarioQuaMarioContent.makeID("walk_run"); | ||
} | ||
|
||
@Override public @NotNull SprintingRule getSprintingRule() { | ||
return SprintingRule.ALLOW; | ||
} | ||
|
||
public static final CharaStat RUN_ACCEL = new CharaStat(0.0175, RUNNING, FORWARD, ACCELERATION); | ||
public static final CharaStat RUN_SPEED = new CharaStat(0.55, RUNNING, FORWARD, SPEED); | ||
public static final CharaStat RUN_REDIRECTION = new CharaStat(2.76, RUNNING, FORWARD, REDIRECTION); | ||
public static final CharaStat OVERRUN_ACCEL = new CharaStat(0.0175, RUNNING, FORWARD, OVERSPEED_CORRECTION); | ||
|
||
public static boolean meetsWalkRunRequirement(IMarioReadableMotionData data) { | ||
return data.getInputs().getForwardInput() > 0 && | ||
data.getForwardVel() > WALK_STANDSTILL_THRESHOLD.get(data) && | ||
data.getHorizVelSquared() > WALK_SPEED.getAsSquaredThreshold(data); | ||
} | ||
|
||
@Override public void travelHook(IMarioTravelData data, GroundedActionHelper helper) { | ||
if(data.getMario().isSprinting()) { | ||
if(data.getForwardVel() > RUN_SPEED.getAsLimit(data)) { | ||
// Overrun | ||
helper.groundAccel(data, | ||
OVERRUN_ACCEL, RUN_SPEED, | ||
STRAFE_ACCEL, STRAFE_SPEED, | ||
data.getInputs().getForwardInput(), data.getInputs().getStrafeInput() * 0.8, | ||
RUN_REDIRECTION | ||
); | ||
} | ||
else { | ||
// Run Accel | ||
helper.groundAccel(data, | ||
RUN_ACCEL, RUN_SPEED, | ||
STRAFE_ACCEL, STRAFE_SPEED, | ||
data.getInputs().getForwardInput(), data.getInputs().getStrafeInput(), | ||
RUN_REDIRECTION | ||
); | ||
} | ||
} | ||
else super.travelHook(data, helper); | ||
} | ||
|
||
@Override public @NotNull List<TransitionDefinition> getBasicTransitions(GroundedActionHelper helper) { | ||
return List.of( | ||
new TransitionDefinition( | ||
MarioQuaMarioContent.makeID("sub_walk"), | ||
data -> !meetsWalkRunRequirement(data), | ||
EvaluatorEnvironment.CLIENT_ONLY | ||
) | ||
); | ||
} | ||
|
||
@Override public @NotNull Set<TransitionInjectionDefinition> getTransitionInjections() { | ||
return Set.of(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
mod/src/client/java/com/fqf/mario_qua_mario/mixin/client/ClientPlayerEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.fqf.mario_qua_mario.mixin.client; | ||
|
||
import com.fqf.mario_qua_mario.definitions.states.actions.util.SprintingRule; | ||
import com.fqf.mario_qua_mario.mariodata.injections.MarioMainClientDataHolder; | ||
import com.mojang.authlib.GameProfile; | ||
import net.minecraft.client.network.AbstractClientPlayerEntity; | ||
import net.minecraft.client.network.ClientPlayerEntity; | ||
import net.minecraft.client.world.ClientWorld; | ||
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.CallbackInfoReturnable; | ||
|
||
@Mixin(ClientPlayerEntity.class) | ||
public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity implements MarioMainClientDataHolder { | ||
public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) { | ||
super(world, profile); | ||
throw new AssertionError("Mixin constructor?!"); | ||
} | ||
|
||
@Inject(method = "canSprint", at = @At("HEAD"), cancellable = true) | ||
private void preventSprinting(CallbackInfoReturnable<Boolean> cir) { | ||
if(mqm$getMarioData().doMarioTravel() && mqm$getMarioData().getAction().SPRINTING_RULE == SprintingRule.PROHIBIT) | ||
cir.setReturnValue(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.