Skip to content

Commit

Permalink
Starting on Action implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
floral-qua-floral committed Dec 6, 2024
1 parent 9d4c307 commit 4199844
Show file tree
Hide file tree
Showing 22 changed files with 466 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.fqf.mario_qua_mario.definitions;

import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public interface AttackInterceptingStateDefinition extends MarioStateDefinition {
List<AttackInterceptionDefinition> getUnarmedAttackInterceptions();

interface AttackInterceptionDefinition {
@Nullable Identifier getActionTarget();
@Nullable Hand getHandToSwing();
boolean shouldTriggerAttackCooldown();

boolean shouldIntercept(

);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.fqf.mario_qua_mario.definitions;

import com.fqf.mario_qua_mario.mariodata.IMarioAuthoritativeData;
import com.fqf.mario_qua_mario.mariodata.IMarioClientData;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;

public interface MarioStateDefinition {
@NotNull Identifier getID();

void clientTick(IMarioClientData data, boolean isSelf);
void serverTick(IMarioAuthoritativeData data);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.fqf.mario_qua_mario.definitions.actions;

import com.fqf.mario_qua_mario.definitions.AttackInterceptingStateDefinition;
import com.fqf.mario_qua_mario.definitions.actions.util.BumpingRule;
import com.fqf.mario_qua_mario.definitions.actions.util.CameraAnimationSet;
import com.fqf.mario_qua_mario.definitions.actions.util.SneakingRule;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface ActionDefinition extends AttackInterceptingStateDefinition {
@Nullable String getAnimationName();
@Nullable CameraAnimationSet getCameraAnimations();

@NotNull SneakingRule getSneakingRule();

boolean canSprint();

@Nullable Identifier getStompType();

@Nullable BumpingRule getBumpingRule();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.fqf.mario_qua_mario.definitions.actions.util;

import com.fqf.mario_qua_mario.util.CharaStat;
import com.fqf.mario_qua_mario.util.StatCategory;

public class BumpingRule {
/**
* A strength of 4 represents Super Mario being able to destroy a Brick Block, but Small Mario only bumping it.
* (Example: Ground Pound, hitting a block from below)
* <p>
* A strength of 3 represents Super Mario and Small Mario both bumping a Brick Block without destroying it.
* (Example: Rolling into a wall, Bonking)
* <p>
* A strength of 2 represents Super Mario being able to shatter a Flip Block, and Small Mario having no effect on it.
* (Example: Spin Jump)
* <p>
* A strength of 1 represents Mario landing on a block and having no effect on it.
* (Example: Regular jump)
*/
public static final BumpingRule JUMPING = new BumpingRule(4, 1);
public static final BumpingRule FALLING = new BumpingRule(4, 1);
public static final BumpingRule SWIMMING = new BumpingRule(4, 0);
public static final BumpingRule GROUND_POUND = new BumpingRule(0, 4);
public static final BumpingRule SPIN_JUMPING = new BumpingRule(2, 2);

public final int CEILINGS;
public final int FLOORS;
public final int WALLS;
public final CharaStat WALL_SPEED_THRESHOLD;

public BumpingRule(int ceilingBumpStrength, int floorBumpStrength) {
this(ceilingBumpStrength, floorBumpStrength, 0, 0);
}

public BumpingRule(int ceilingBumpStrength, int floorBumpStrength, int wallBumpStrength, double wallBumpSpeedThreshold) {
this.CEILINGS = ceilingBumpStrength;
this.FLOORS = floorBumpStrength;
this.WALLS = wallBumpStrength;
this.WALL_SPEED_THRESHOLD = new CharaStat(wallBumpSpeedThreshold, StatCategory.THRESHOLD);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.fqf.mario_qua_mario.definitions.actions.util;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class CameraAnimationSet {
public CameraAnimationSet(
@NotNull CameraAnimation authentic,
@Nullable CameraAnimation gentle,
@Nullable CameraAnimation minimal
) {
this.AUTHENTIC_ANIMATION = authentic;
this.GENTLE_ANIMATION = gentle == null ? authentic : gentle;
this.MINIMAL_ANIMATION = minimal;
}

public static class CameraAnimation {
@FunctionalInterface
public interface rotationalOffsetCalculator {
void setRotationalOffsets(float progress, float[] offsets);
}

public CameraAnimation(
boolean looping,
float durationSeconds,
CameraAnimation.rotationalOffsetCalculator calculator
) {
this.SHOULD_LOOP = looping;
this.DURATION_TICKS = durationSeconds * 20;
this.CALCULATOR = calculator;
}

public final boolean SHOULD_LOOP;
public final float DURATION_TICKS;
public final CameraAnimation.rotationalOffsetCalculator CALCULATOR;
}

@NotNull
public final CameraAnimation AUTHENTIC_ANIMATION;
@NotNull
public final CameraAnimation GENTLE_ANIMATION;
@Nullable
public final CameraAnimation MINIMAL_ANIMATION;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.fqf.mario_qua_mario.definitions.actions.util;

public enum SlidingStatus {
NOT_SLIDING,
NOT_SLIDING_SMOOTH,

SLIDING,
SKIDDING,
WALL_SLIDING
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.fqf.mario_qua_mario.definitions.actions.util;

public enum SneakingRule {
ALLOW,
PROHIBIT,
SLIP,
FORCE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.fqf.mario_qua_mario.definitions.actions.util;

import com.fqf.mario_qua_mario.mariodata.IMarioClientData;
import com.fqf.mario_qua_mario.mariodata.IMarioTravelData;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class TransitionDefinition {
@FunctionalInterface
public interface Evaluator {
boolean shouldTransition(IMarioTravelData data);
}

@FunctionalInterface
public interface TravelExecutor {
boolean execute(IMarioTravelData data);
}

@FunctionalInterface
public interface ClientsExecutor {
boolean execute(IMarioClientData data, boolean isSelf, long seed);
}

public TransitionDefinition(
@NotNull String targetID,
@NotNull Evaluator evaluator,
@Nullable TravelExecutor travelExecutor,
@Nullable ClientsExecutor clientsExecutor
) {
this.TARGET_IDENTIFIER = Identifier.of(targetID);
this.EVALUATOR = evaluator;
this.TRAVEL_EXECUTOR = travelExecutor;
this.CLIENTS_EXECUTOR = clientsExecutor;
}

public TransitionDefinition(@NotNull String targetID, @NotNull Evaluator evaluator) {
this(targetID, evaluator, null, null);
}

public final Identifier TARGET_IDENTIFIER;
public final Evaluator EVALUATOR;
public final TravelExecutor TRAVEL_EXECUTOR;
public final ClientsExecutor CLIENTS_EXECUTOR;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.fqf.mario_qua_mario.definitions.actions.util;

import net.minecraft.util.Identifier;

public class TransitionInjectionDefinition {
@FunctionalInterface
public interface TransitionCreator {
TransitionDefinition makeTransition(TransitionDefinition previousTransition);
}

public enum InjectionPlacement {
BEFORE,
AFTER
}

public enum ActionCategory {
ANY,
GROUNDED,
AIRBORNE,
AQUATIC,
WALL,
UNDEFINED
}

public TransitionInjectionDefinition(
InjectionPlacement placement,
String injectNearTransitionsTo,
ActionCategory category,
TransitionCreator injectedTransitionCreator
) {
this.PLACEMENT = placement;
this.INJECT_NEAR = Identifier.of(injectNearTransitionsTo);
this.INJECT_IN_CATEGORY = category;
this.TRANSITION_CREATOR = injectedTransitionCreator;
}

public final InjectionPlacement PLACEMENT;
public final Identifier INJECT_NEAR;
public final ActionCategory INJECT_IN_CATEGORY;
public final TransitionCreator TRANSITION_CREATOR;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.fqf.mario_qua_mario.mariodata;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;

public interface IMarioAuthoritativeData {
public interface IMarioAuthoritativeData extends IMarioData {
@Override ServerPlayerEntity getMario();

boolean setEnabled(boolean enable);

boolean setAction(Identifier actionID);
boolean setAction(String actionID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ public interface IMarioData {
PlayerEntity getMario();
boolean isClient();

double getStat(CharaStat stat);
double getStatMultiplier(CharaStat stat);
int getBumpStrengthModifier();

boolean canSneak();
boolean canSprint();

boolean isEnabled();
Identifier getActionID();
Identifier getPowerUpID();
Identifier getCharacterID();

double getStat(CharaStat stat);
double getStatMultiplier(CharaStat stat);
int getBumpStrengthModifier();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.fqf.mario_qua_mario.mariodata;

public interface IMarioReadableMotionData extends IMarioData {
double getForwardVel();
double getStrafeVel();
double getYVel();

MarioInputs getInputs();

abstract class MarioInputs {
public final MarioButton JUMP;
public final MarioButton DUCK;
public final MarioButton SPIN;

public abstract double getForwardInput();
public abstract double getStrafeInput();

public abstract boolean isReal();

public interface MarioButton {
boolean isPressed();
boolean isHeld();
}

protected MarioInputs(MarioButton jump, MarioButton duck, MarioButton spin) {
JUMP = jump;
DUCK = duck;
SPIN = spin;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
package com.fqf.mario_qua_mario.mariodata;

public interface IMarioTravelData extends IMarioData {
double getForwardVel();
double getStrafeVel();
double getYVel();

public interface IMarioTravelData extends IMarioReadableMotionData {
void setForwardVel(double forward);
void setStrafeVel(double strafe);
default void setForwardStrafeVel(double forward, double strafe) {
this.setForwardVel(forward);
this.setStrafeVel(strafe);
}
void setYVel(double vertical);

abstract class MarioInputs {
public final MarioButton JUMP;
public final MarioButton DUCK;
public final MarioButton SPIN;

public abstract double getForwardInput();
public abstract double getStrafeInput();

public abstract boolean isReal();

public interface MarioButton {
boolean isPressed();
boolean isHeld();
}

protected MarioInputs(MarioButton jump, MarioButton duck, MarioButton spin) {
JUMP = jump;
DUCK = duck;
SPIN = spin;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ public static void clearInstance() {

private ClientPlayerEntity mario;
public MarioMainClientData(ClientPlayerEntity mario) {
super();
this.mario = mario;
instance = this;
}

@Override
public ClientPlayerEntity getMario() {
@Override public ClientPlayerEntity getMario() {
return mario;
}
@Override public void setMario(PlayerEntity mario) {
this.mario = (ClientPlayerEntity) mario;
}

@Override
public void setMario(PlayerEntity mario) {
this.mario = (ClientPlayerEntity) mario;
public void tick() {

}
}
Loading

0 comments on commit 4199844

Please sign in to comment.