Skip to content

Commit

Permalink
Getting some weirdness where Mario transitions back into Fall on the …
Browse files Browse the repository at this point in the history
…client side after landing...? :( Need to figure that out...
  • Loading branch information
floral-qua-floral committed Dec 23, 2024
1 parent d40b45a commit d7b3a93
Show file tree
Hide file tree
Showing 29 changed files with 570 additions and 117 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.fqf.mario_qua_mario.definitions.states;

import net.minecraft.entity.Entity;
import net.minecraft.util.Identifier;

public interface CharacterDefinition extends StatAlteringStateDefinition {
Identifier getInitialAction();
Identifier getInitialPowerUp();

Identifier getMountedAction(Entity vehicle);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
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.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

Expand Down Expand Up @@ -73,5 +75,11 @@ void applyDrag(
);

double getSlipFactor(IMarioReadableMotionData data);

void performJump(
IMarioTravelData data,
CharaStat jumpVel,
@Nullable CharaStat speedAddend
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.fqf.mario_qua_mario.definitions.states.actions;

import com.fqf.mario_qua_mario.definitions.states.actions.util.IncompleteActionDefinition;
import com.fqf.mario_qua_mario.definitions.states.actions.util.TransitionDefinition;
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.entity.Entity;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public interface MountedActionDefinition extends IncompleteActionDefinition {
boolean travelHook(IMarioTravelData data, Entity mount, MountedActionHelper helper);

@NotNull List<TransitionDefinition> getBasicTransitions(MountedActionHelper helper);
@NotNull List<TransitionDefinition> getInputTransitions(MountedActionHelper helper);
@NotNull List<TransitionDefinition> getWorldCollisionTransitions(MountedActionHelper helper);

/**
* Contains a number of methods intended to help with the creation of Mounted Actions. Can be cast to any of the
* other ActionHelpers, if for whatever reason you need them.
*/
interface MountedActionHelper {
Entity getMount(IMarioReadableMotionData data);

void dismount(IMarioTravelData data, boolean reposition);

double getSlipFactor(Entity mount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public TransitionDefinition(@NotNull Identifier targetID, @NotNull Evaluator eva
* when you're the one transitioning.
*/
@FunctionalInterface public interface TravelExecutor {
boolean execute(IMarioTravelData data);
void execute(IMarioTravelData data);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum ActionCategory {
GROUNDED,
AIRBORNE,
AQUATIC,
WALL
WALLBOUND,
MOUNTED
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.fqf.mario_qua_mario.actions.airborne;

import com.fqf.mario_qua_mario.MarioQuaMarioContent;
import com.fqf.mario_qua_mario.definitions.states.actions.AirborneActionDefinition;
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.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.*;

public class Fall implements AirborneActionDefinition {
@Override public @NotNull Identifier getID() {
return MarioQuaMarioContent.makeID("fall");
}

@Override public @Nullable String getAnimationName() {
return null;
}
@Override public @Nullable CameraAnimationSet getCameraAnimations() {
return null;
}
@Override public @NotNull SlidingStatus getSlidingStatus() {
return SlidingStatus.NOT_SLIDING;
}

@Override public @NotNull SneakingRule getSneakingRule() {
return SneakingRule.PROHIBIT;
}
@Override public @NotNull SprintingRule getSprintingRule() {
return SprintingRule.PROHIBIT;
}

@Override public @Nullable BumpType getBumpType() {
return null;
}
@Override public @Nullable Identifier getStompTypeID() {
return null;
}

public static final CharaStat FALL_ACCEL = new CharaStat(-0.115, NORMAL_GRAVITY);
public static final CharaStat FALL_SPEED = new CharaStat(-3.25, TERMINAL_VELOCITY);

public static final TransitionDefinition FALL = new TransitionDefinition(
MarioQuaMarioContent.makeID("fall"),
data -> !data.getMario().isOnGround(),
EvaluatorEnvironment.COMMON
);

@Override public void clientTick(IMarioClientData data, boolean isSelf) {

}
@Override public void serverTick(IMarioAuthoritativeData data) {

}
@Override public void travelHook(IMarioTravelData data, AirborneActionHelper helper) {
helper.applyGravity(data, FALL_ACCEL, null, FALL_SPEED);
}

@Override public @NotNull List<TransitionDefinition> getBasicTransitions(AirborneActionHelper helper) {
return List.of();
}
@Override public @NotNull List<TransitionDefinition> getInputTransitions(AirborneActionHelper helper) {
return List.of();
}
@Override public @NotNull List<TransitionDefinition> getWorldCollisionTransitions(AirborneActionHelper helper) {
return List.of(
new TransitionDefinition(
MarioQuaMarioContent.makeID("sub_walk"),
data -> data.getMario().isOnGround(),
EvaluatorEnvironment.CLIENT_CHECKED
)
);
}

@Override public @NotNull Set<TransitionInjectionDefinition> getTransitionInjections() {
return Set.of();
}

@Override public @NotNull List<AttackInterceptionDefinition> getUnarmedAttackInterceptions() {
return List.of();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.fqf.mario_qua_mario.actions.airborne;

import com.fqf.mario_qua_mario.MarioQuaMarioContent;
import com.fqf.mario_qua_mario.definitions.states.actions.AirborneActionDefinition;
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.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.*;

public class Jump extends Fall implements AirborneActionDefinition {
@Override public @NotNull Identifier getID() {
return MarioQuaMarioContent.makeID("jump");
}

@Override public @Nullable String getAnimationName() {
return null;
}

public static final CharaStat JUMP_GRAVITY = new CharaStat(-0.095, JUMPING_GRAVITY);

public static final CharaStat JUMP_VEL = new CharaStat(0.858, JUMP_VELOCITY);
public static final CharaStat JUMP_ADDEND = new CharaStat(0.2, JUMP_VELOCITY);

public static TransitionDefinition makeJumpTransition(GroundedActionDefinition.GroundedActionHelper helper) {
return new TransitionDefinition(
MarioQuaMarioContent.makeID("jump"),
data -> data.getInputs().JUMP.isPressed(),
EvaluatorEnvironment.CLIENT_ONLY,
data -> helper.performJump(data, JUMP_VEL, JUMP_ADDEND),
(data, isSelf, seed) -> data.playJumpSound(seed)
);
}

@Override public void clientTick(IMarioClientData data, boolean isSelf) {

}
@Override public void serverTick(IMarioAuthoritativeData data) {

}
@Override public void travelHook(IMarioTravelData data, AirborneActionHelper helper) {
helper.applyGravity(data, Fall.FALL_ACCEL, JUMP_GRAVITY, Fall.FALL_SPEED);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.fqf.mario_qua_mario.actions.grounded;

import com.fqf.mario_qua_mario.MarioQuaMarioContent;
import com.fqf.mario_qua_mario.actions.airborne.Fall;
import com.fqf.mario_qua_mario.actions.airborne.Jump;
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;
Expand Down Expand Up @@ -150,11 +152,13 @@ else if(data.getForwardVel() < BACKPEDAL_SPEED.getAsLimit(data)) {
}
@Override public @NotNull List<TransitionDefinition> getInputTransitions(GroundedActionHelper helper) {
return List.of(

Jump.makeJumpTransition(helper)
);
}
@Override public @NotNull List<TransitionDefinition> getWorldCollisionTransitions(GroundedActionHelper helper) {
return List.of();
return List.of(
Fall.FALL
);
}

@Override public @NotNull Set<TransitionInjectionDefinition> getTransitionInjections() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ public static boolean meetsWalkRunRequirement(IMarioReadableMotionData data) {
}

@Override public @NotNull Set<TransitionInjectionDefinition> getTransitionInjections() {
return Set.of();
return Set.of(
new TransitionInjectionDefinition(
TransitionInjectionDefinition.InjectionPlacement.BEFORE,
MarioQuaMarioContent.makeID("sub_walk"),
TransitionInjectionDefinition.ActionCategory.AIRBORNE,
nearbyTransition -> new TransitionDefinition(
this.getID(),
data -> meetsWalkRunRequirement(data) && nearbyTransition.evaluator().shouldTransition(data),
EvaluatorEnvironment.CLIENT_ONLY,
nearbyTransition.travelExecutor(),
nearbyTransition.clientsExecutor()
)
)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.fqf.mario_qua_mario.actions.mounted;

import com.fqf.mario_qua_mario.MarioQuaMarioContent;
import com.fqf.mario_qua_mario.definitions.states.actions.MountedActionDefinition;
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.IMarioTravelData;
import net.minecraft.entity.Entity;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Set;

public class Mounted implements MountedActionDefinition {
@Override public @NotNull Identifier getID() {
return MarioQuaMarioContent.makeID("mounted");
}

@Override public @Nullable String getAnimationName() {
return null;
}
@Override public @Nullable CameraAnimationSet getCameraAnimations() {
return null;
}
@Override public @NotNull SlidingStatus getSlidingStatus() {
return SlidingStatus.NOT_SLIDING;
}

@Override public @NotNull SneakingRule getSneakingRule() {
return SneakingRule.PROHIBIT;
}
@Override public @NotNull SprintingRule getSprintingRule() {
return SprintingRule.PROHIBIT;
}

@Override public @Nullable BumpType getBumpType() {
return null;
}
@Override public @Nullable Identifier getStompTypeID() {
return null;
}

@Override public void clientTick(IMarioClientData data, boolean isSelf) {

}
@Override public void serverTick(IMarioAuthoritativeData data) {

}
@Override public boolean travelHook(IMarioTravelData data, Entity mount, MountedActionHelper helper) {
return false;
}

@Override public @NotNull List<TransitionDefinition> getBasicTransitions(MountedActionHelper helper) {
return List.of(
new TransitionDefinition(
MarioQuaMarioContent.makeID("sub_walk"),
data -> helper.getMount(data) == null,
EvaluatorEnvironment.COMMON
)
);
}
@Override public @NotNull List<TransitionDefinition> getInputTransitions(MountedActionHelper helper) {
return List.of(
new TransitionDefinition(
MarioQuaMarioContent.makeID("walk_run"),
data -> data.getInputs().DUCK.isHeld() && data.getInputs().JUMP.isPressed(),
EvaluatorEnvironment.CLIENT_ONLY,
data -> {
data.setYVel(1);
helper.dismount(data, false);
},
(data, isSelf, seed) -> data.playJumpSound(seed)
)
);
}
@Override public @NotNull List<TransitionDefinition> getWorldCollisionTransitions(MountedActionHelper helper) {
return List.of();
}

@Override public @NotNull Set<TransitionInjectionDefinition> getTransitionInjections() {
return Set.of();
}

@Override public @NotNull List<AttackInterceptionDefinition> getUnarmedAttackInterceptions() {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fqf.mario_qua_mario.definitions.states.CharacterDefinition;
import com.fqf.mario_qua_mario.mariodata.IMarioAuthoritativeData;
import com.fqf.mario_qua_mario.mariodata.IMarioClientData;
import net.minecraft.entity.Entity;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;

Expand All @@ -21,6 +22,10 @@ public class Mario implements CharacterDefinition {
return MarioQuaMarioContent.makeID("super");
}

@Override public Identifier getMountedAction(Entity vehicle) {
return MarioQuaMarioContent.makeID("mounted");
}

@Override public float getWidthFactor() {
return 1;
}
Expand Down
Loading

0 comments on commit d7b3a93

Please sign in to comment.