diff --git a/src/main/java/com/floralquafloral/MarioPackets.java b/src/main/java/com/floralquafloral/MarioPackets.java index 80611c5..106fe02 100644 --- a/src/main/java/com/floralquafloral/MarioPackets.java +++ b/src/main/java/com/floralquafloral/MarioPackets.java @@ -1,6 +1,7 @@ package com.floralquafloral; import com.floralquafloral.mariodata.MarioDataPackets; +import com.floralquafloral.registries.stomp.StompHandler; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.PlayerLookup; @@ -20,6 +21,7 @@ public class MarioPackets { public static void registerCommon() { SyncUseCharacterStatsS2CPayload.register(); MarioDataPackets.registerCommon(); + StompHandler.registerPackets(); ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { MarioQuaMario.LOGGER.info(""); @@ -28,6 +30,7 @@ public static void registerCommon() { public static void registerClient() { SyncUseCharacterStatsS2CPayload.registerReceiver(); MarioDataPackets.registerClient(); + StompHandler.registerPacketsClient(); } public static PlayerEntity getPlayerFromInt(ClientPlayNetworking.Context context, int playerID) { diff --git a/src/main/java/com/floralquafloral/MarioQuaMario.java b/src/main/java/com/floralquafloral/MarioQuaMario.java index eb0a1ca..08c2d10 100644 --- a/src/main/java/com/floralquafloral/MarioQuaMario.java +++ b/src/main/java/com/floralquafloral/MarioQuaMario.java @@ -1,5 +1,6 @@ package com.floralquafloral; +import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.MarioDataManager; import com.floralquafloral.registries.RegistryManager; import com.floralquafloral.util.ModConfig; @@ -7,6 +8,7 @@ import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory; import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry; import net.fabricmc.fabric.api.gamerule.v1.rule.DoubleRule; @@ -59,6 +61,7 @@ public class MarioQuaMario implements ModInitializer { public void onInitialize() { LOGGER.info("MarioQuaMario.java loaded on environment type " + FabricLoader.getInstance().getEnvironmentType()); MarioDataManager.wipePlayerData(); + MarioDataManager.registerEventListeners(); RegistryManager.register(); diff --git a/src/main/java/com/floralquafloral/VoiceLine.java b/src/main/java/com/floralquafloral/VoiceLine.java index 5eb32ba..b7b244d 100644 --- a/src/main/java/com/floralquafloral/VoiceLine.java +++ b/src/main/java/com/floralquafloral/VoiceLine.java @@ -1,7 +1,7 @@ package com.floralquafloral; import com.floralquafloral.registries.RegistryManager; -import com.floralquafloral.registries.character.ParsedCharacter; +import com.floralquafloral.registries.states.character.ParsedCharacter; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.registry.Registries; diff --git a/src/main/java/com/floralquafloral/mariodata/MarioData.java b/src/main/java/com/floralquafloral/mariodata/MarioData.java index b17a81c..0560960 100644 --- a/src/main/java/com/floralquafloral/mariodata/MarioData.java +++ b/src/main/java/com/floralquafloral/mariodata/MarioData.java @@ -1,8 +1,8 @@ package com.floralquafloral.mariodata; -import com.floralquafloral.registries.action.ParsedAction; -import com.floralquafloral.registries.character.ParsedCharacter; -import com.floralquafloral.registries.powerup.ParsedPowerUp; +import com.floralquafloral.registries.states.action.ParsedAction; +import com.floralquafloral.registries.states.character.ParsedCharacter; +import com.floralquafloral.registries.states.powerup.ParsedPowerUp; import net.minecraft.entity.player.PlayerEntity; public interface MarioData { diff --git a/src/main/java/com/floralquafloral/mariodata/MarioDataManager.java b/src/main/java/com/floralquafloral/mariodata/MarioDataManager.java index f2a9d74..7419b49 100644 --- a/src/main/java/com/floralquafloral/mariodata/MarioDataManager.java +++ b/src/main/java/com/floralquafloral/mariodata/MarioDataManager.java @@ -1,9 +1,15 @@ package com.floralquafloral.mariodata; import com.floralquafloral.MarioPackets; +import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.client.MarioClientData; import com.floralquafloral.mixin.PlayerEntityMixin; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; +import net.fabricmc.fabric.api.networking.v1.EntityTrackingEvents; +import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.player.PlayerEntity; @@ -16,6 +22,34 @@ public class MarioDataManager { private static final Map SERVER_PLAYERS_DATA = new HashMap<>(); private static final Map CLIENT_PLAYERS_DATA = new HashMap<>(); + public static void registerEventListeners() { + ServerTickEvents.START_SERVER_TICK.register((server) -> { + for(Map.Entry entry : SERVER_PLAYERS_DATA.entrySet()) { + ServerPlayerEntity player = (ServerPlayerEntity) entry.getKey(); + if(player.isDisconnected()) { + SERVER_PLAYERS_DATA.remove(player); + continue; + } + + ((MarioPlayerData) entry.getValue()).tick(); + } + }); + + ClientTickEvents.START_CLIENT_TICK.register((client) -> { + for(Map.Entry entry : CLIENT_PLAYERS_DATA.entrySet()) { + ((MarioPlayerData) entry.getValue()).tick(); + } + }); + + + +// ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> { +// +// }); + + + } + public static void wipePlayerData() { SERVER_PLAYERS_DATA.clear(); CLIENT_PLAYERS_DATA.clear(); diff --git a/src/main/java/com/floralquafloral/mariodata/MarioDataPackets.java b/src/main/java/com/floralquafloral/mariodata/MarioDataPackets.java index eaef2b1..8b8e0a5 100644 --- a/src/main/java/com/floralquafloral/mariodata/MarioDataPackets.java +++ b/src/main/java/com/floralquafloral/mariodata/MarioDataPackets.java @@ -3,13 +3,14 @@ import com.floralquafloral.MarioPackets; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.registries.RegistryManager; -import com.floralquafloral.registries.action.ParsedAction; -import com.floralquafloral.registries.character.ParsedCharacter; -import com.floralquafloral.registries.powerup.ParsedPowerUp; +import com.floralquafloral.registries.states.action.ParsedAction; +import com.floralquafloral.registries.states.character.ParsedCharacter; +import com.floralquafloral.registries.states.powerup.ParsedPowerUp; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.networking.v1.EntityTrackingEvents; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.RegistryByteBuf; import net.minecraft.network.codec.PacketCodec; @@ -32,6 +33,20 @@ public static void registerCommon() { // C2S SetActionC2SPayload.register(); SetActionC2SPayload.registerReceiver(); + + // Listeners + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { + sendAllData(handler.player, handler.player); + ServerPlayNetworking.send(handler.player, + new MarioPackets.SyncUseCharacterStatsS2CPayload( + handler.player.getWorld().getGameRules().getBoolean(MarioQuaMario.USE_CHARACTER_STATS))); + }); + + EntityTrackingEvents.START_TRACKING.register((trackingTarget, tracker) -> { + if(trackingTarget instanceof PlayerEntity trackingPlayer) { + sendAllData(tracker, trackingPlayer); + } + }); } public static void registerClient() { SetEnabledS2CPayload.registerReceiver(); @@ -40,6 +55,15 @@ public static void registerClient() { SetCharacterS2CPayload.registerReceiver(); } + private static void sendAllData(ServerPlayerEntity toWho, PlayerEntity aboutWho) { + MarioData data = getMarioData(aboutWho); + // am I supposed to send one packet with all this data or is this fine???? + ServerPlayNetworking.send(toWho, new SetEnabledS2CPayload(aboutWho, data.isEnabled())); + ServerPlayNetworking.send(toWho, new SetActionS2CPayload(aboutWho, data.getAction(), true, 0)); + ServerPlayNetworking.send(toWho, new SetPowerUpS2CPayload(aboutWho, data.getPowerUp())); + ServerPlayNetworking.send(toWho, new SetCharacterS2CPayload(aboutWho, data.getCharacter())); + } + public static String setMarioEnabled(ServerPlayerEntity player, boolean enabled) { getMarioData(player).setEnabled(enabled); MarioPackets.sendPacketToTrackers(player, new MarioDataPackets.SetEnabledS2CPayload(player, enabled)); diff --git a/src/main/java/com/floralquafloral/mariodata/MarioPlayerData.java b/src/main/java/com/floralquafloral/mariodata/MarioPlayerData.java index e9ebc54..dd607d0 100644 --- a/src/main/java/com/floralquafloral/mariodata/MarioPlayerData.java +++ b/src/main/java/com/floralquafloral/mariodata/MarioPlayerData.java @@ -2,9 +2,9 @@ import com.floralquafloral.MarioQuaMario; import com.floralquafloral.registries.RegistryManager; -import com.floralquafloral.registries.action.ParsedAction; -import com.floralquafloral.registries.character.ParsedCharacter; -import com.floralquafloral.registries.powerup.ParsedPowerUp; +import com.floralquafloral.registries.states.action.ParsedAction; +import com.floralquafloral.registries.states.character.ParsedCharacter; +import com.floralquafloral.registries.states.powerup.ParsedPowerUp; import com.floralquafloral.util.CPMIntegration; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; @@ -86,7 +86,8 @@ private void apply() { return this.VELOCITIES.ensure().strafe; } @Override public double getYVel() { - return this.VELOCITIES.ensure().vertical; + if(this.VELOCITIES.isGenerated) return this.VELOCITIES.vertical; + else return this.MARIO.getVelocity().y; } @Override public void setForwardVel(double forward) { VELOCITIES.ensureDirty().forward = forward; @@ -95,7 +96,11 @@ private void apply() { this.VELOCITIES.ensureDirty().strafe = strafe; } @Override public void setYVel(double vertical) { - this.VELOCITIES.ensureDirty().vertical = vertical; + if(this.VELOCITIES.isGenerated) this.VELOCITIES.ensureDirty().vertical = vertical; + else { + Vec3d oldVel = this.MARIO.getVelocity(); + this.MARIO.setVelocity(oldVel.x, vertical, oldVel.y); + } } @Override public void applyModifiedVelocity() { this.VELOCITIES.apply(); @@ -107,12 +112,16 @@ public void tick() { if(this.getMario().getWorld().isClient) { this.action.otherClientsTick(this); this.powerUp.otherClientsTick(this); -// this.character.otherClientsTick(this); + this.character.otherClientsTick(this); } else { this.action.serverTick(this); this.powerUp.serverTick(this); -// this.character.serverTick(this); + this.character.serverTick(this); + + if(this.action.STOMP != null) this.action.STOMP.attempt(this); + + this.applyModifiedVelocity(); } } @@ -150,11 +159,13 @@ public void tick() { powerUp.acquirePower(this); this.MARIO.setHealth(this.MARIO.getMaxHealth()); this.powerUp = powerUp; + this.MARIO.calculateDimensions(); } @Override public ParsedCharacter getCharacter() { return character; } @Override public void setCharacter(ParsedCharacter character) { this.character = character; + this.MARIO.calculateDimensions(); } } diff --git a/src/main/java/com/floralquafloral/mariodata/client/MarioClientData.java b/src/main/java/com/floralquafloral/mariodata/client/MarioClientData.java index 45f9f85..e0c0225 100644 --- a/src/main/java/com/floralquafloral/mariodata/client/MarioClientData.java +++ b/src/main/java/com/floralquafloral/mariodata/client/MarioClientData.java @@ -2,16 +2,13 @@ import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioPlayerData; -import com.floralquafloral.registries.action.ParsedAction; -import com.floralquafloral.registries.action.TransitionPhase; +import com.floralquafloral.registries.states.action.ParsedAction; +import com.floralquafloral.registries.states.action.TransitionPhase; import com.floralquafloral.util.CPMIntegration; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.MovementType; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.joml.Vector2d; public class MarioClientData extends MarioPlayerData { @@ -50,17 +47,12 @@ public MarioClientData(ClientPlayerEntity mario) { } public boolean travel(Vec3d movementInput) { - tick(); Input.updateDirections(movementInput.z, movementInput.x); getAction().attemptTransitions(this, TransitionPhase.PRE_TICK); getAction().selfTick(this); getAction().attemptTransitions(this, TransitionPhase.POST_TICK); -// MarioVelocityContainer cachedVelocities = getVelocities(); -// this.clearCachedVelocities(); -// setVelocities(cachedVelocities); - applyModifiedVelocity(); MARIO_CLIENT.move(MovementType.PLAYER, MARIO_CLIENT.getVelocity()); if(getAction().attemptTransitions(this, TransitionPhase.POST_MOVE)) diff --git a/src/main/java/com/floralquafloral/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/com/floralquafloral/mixin/ClientPlayNetworkHandlerMixin.java index 1199707..2016ecd 100644 --- a/src/main/java/com/floralquafloral/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/com/floralquafloral/mixin/ClientPlayNetworkHandlerMixin.java @@ -1,5 +1,6 @@ package com.floralquafloral.mixin; +import com.floralquafloral.MarioQuaMarioClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.damage.DamageSource; @@ -13,7 +14,7 @@ public abstract class ClientPlayNetworkHandlerMixin { @Redirect(method = "onEntityDamage", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;onDamaged(Lnet/minecraft/entity/damage/DamageSource;)V")) private void onDamaged(Entity instance, DamageSource damageSource) { // if(damageSource.isIn(StompHandler.FLATTENS_ENTITIES_TAG)) { -// MarioQuaMarioClient.SQUASHED_ENTITIES.add(instance); + MarioQuaMarioClient.SQUASHED_ENTITIES.add(instance); // } instance.onDamaged(damageSource); } diff --git a/src/main/java/com/floralquafloral/mixin/GameOptionsMixin.java b/src/main/java/com/floralquafloral/mixin/GameOptionsMixin.java index 8443974..773daa3 100644 --- a/src/main/java/com/floralquafloral/mixin/GameOptionsMixin.java +++ b/src/main/java/com/floralquafloral/mixin/GameOptionsMixin.java @@ -2,7 +2,6 @@ import com.floralquafloral.MarioQuaMarioClient; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.action.ActionDefinition; import net.minecraft.client.option.GameOptions; import net.minecraft.client.option.SimpleOption; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/floralquafloral/mixin/InGameHudMixin.java b/src/main/java/com/floralquafloral/mixin/InGameHudMixin.java index 0d397b8..abd48b8 100644 --- a/src/main/java/com/floralquafloral/mixin/InGameHudMixin.java +++ b/src/main/java/com/floralquafloral/mixin/InGameHudMixin.java @@ -1,7 +1,7 @@ package com.floralquafloral.mixin; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.powerup.PowerUpDefinition; +import com.floralquafloral.registries.states.powerup.PowerUpDefinition; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.minecraft.client.gui.hud.InGameHud; diff --git a/src/main/java/com/floralquafloral/mixin/LivingEntityRendererMixin.java b/src/main/java/com/floralquafloral/mixin/LivingEntityRendererMixin.java new file mode 100644 index 0000000..3ae736c --- /dev/null +++ b/src/main/java/com/floralquafloral/mixin/LivingEntityRendererMixin.java @@ -0,0 +1,23 @@ +package com.floralquafloral.mixin; + +import com.floralquafloral.MarioQuaMarioClient; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.LivingEntity; +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.CallbackInfo; + +@Mixin(LivingEntityRenderer.class) +public abstract class LivingEntityRendererMixin> { + + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;getLyingAngle(Lnet/minecraft/entity/LivingEntity;)F"), method = "setupTransforms", cancellable = true) + private void squashedDeathAnimation(T entity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, float scale, CallbackInfo ci) { + if(MarioQuaMarioClient.SQUASHED_ENTITIES.contains(entity)) { + matrices.scale(1.4F, 0.25F, 1.4F); + ci.cancel(); + } + } +} diff --git a/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java b/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java index 7fc9109..95afdca 100644 --- a/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java @@ -3,9 +3,8 @@ import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.client.MarioClientData; import com.floralquafloral.mariodata.MarioDataManager; -import com.floralquafloral.registries.action.ActionDefinition; -import com.floralquafloral.registries.character.ParsedCharacter; -import com.floralquafloral.registries.powerup.ParsedPowerUp; +import com.floralquafloral.registries.states.character.ParsedCharacter; +import com.floralquafloral.registries.states.powerup.ParsedPowerUp; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityPose; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/com/floralquafloral/registries/RegistryManager.java b/src/main/java/com/floralquafloral/registries/RegistryManager.java index 84a2f29..118234b 100644 --- a/src/main/java/com/floralquafloral/registries/RegistryManager.java +++ b/src/main/java/com/floralquafloral/registries/RegistryManager.java @@ -1,13 +1,16 @@ package com.floralquafloral.registries; import com.floralquafloral.MarioQuaMario; -import com.floralquafloral.registries.action.ActionDefinition; -import com.floralquafloral.registries.action.GroundedActionDefinition; -import com.floralquafloral.registries.action.ParsedAction; -import com.floralquafloral.registries.character.CharacterDefinition; -import com.floralquafloral.registries.character.ParsedCharacter; -import com.floralquafloral.registries.powerup.ParsedPowerUp; -import com.floralquafloral.registries.powerup.PowerUpDefinition; +import com.floralquafloral.registries.states.MarioStateDefinition; +import com.floralquafloral.registries.states.action.ActionDefinition; +import com.floralquafloral.registries.states.action.GroundedActionDefinition; +import com.floralquafloral.registries.states.action.ParsedAction; +import com.floralquafloral.registries.states.character.CharacterDefinition; +import com.floralquafloral.registries.states.character.ParsedCharacter; +import com.floralquafloral.registries.states.powerup.ParsedPowerUp; +import com.floralquafloral.registries.states.powerup.PowerUpDefinition; +import com.floralquafloral.registries.stomp.ParsedStomp; +import com.floralquafloral.registries.stomp.StompDefinition; import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; import net.fabricmc.fabric.api.event.registry.RegistryAttribute; import net.fabricmc.loader.api.FabricLoader; @@ -25,11 +28,10 @@ public class RegistryManager { public static void register() { + registerStomps(); registerActions(); registerPowerUps(); registerCharacters(); - - registerSounds(); } public static final SoundEvent JUMP_SFX = makeAndRegisterSound("sfx.jump"); @@ -38,10 +40,6 @@ public static void register() { public static final SoundEvent POWER_UP_SFX = makeAndRegisterSound("sfx.power_up_wii"); - public static void registerSounds() { - - } - private static SoundEvent makeAndRegisterSound(String id) { Identifier identifier = Identifier.of(MarioQuaMario.MOD_ID, id); SoundEvent event = SoundEvent.of(identifier); @@ -51,7 +49,12 @@ private static SoundEvent makeAndRegisterSound(String id) { return event; } - // STATE REGISTRIES: + public static final RegistryKey> STOMP_TYPES_KEY = RegistryKey.ofRegistry( + Identifier.of(MarioQuaMario.MOD_ID, "stomp_types")); + public static final Registry STOMP_TYPES = FabricRegistryBuilder.createSimple(STOMP_TYPES_KEY) + .attribute(RegistryAttribute.SYNCED) + .buildAndRegister(); + public static final RegistryKey> ACTIONS_KEY = RegistryKey.ofRegistry( Identifier.of(MarioQuaMario.MOD_ID, "actions")); public static final Registry ACTIONS = FabricRegistryBuilder.createSimple(ACTIONS_KEY) @@ -70,10 +73,19 @@ private static SoundEvent makeAndRegisterSound(String id) { .attribute(RegistryAttribute.SYNCED) .buildAndRegister(); - private static List getEntrypoints(String key, Class clazz) { + private static List getEntrypoints(String key, Class clazz) { return FabricLoader.getInstance().getEntrypointContainers(key, clazz).stream().map(EntrypointContainer::getEntrypoint).toList(); } + private static void registerStomps() { + for(StompDefinition definition : getEntrypoints("mario-stomp-types", StompDefinition.class)) { + MarioQuaMario.LOGGER.info("Registering stomp type {}...", definition.getID()); + + ParsedStomp stompType = new ParsedStomp(definition); + Registry.register(STOMP_TYPES, stompType.ID, stompType); + } + } + private static void parseAction(ActionDefinition definition, Map> transitionInjections) { MarioQuaMario.LOGGER.info("Registering action {}...", definition.getID()); diff --git a/src/main/java/com/floralquafloral/registries/character/CharacterDefinition.java b/src/main/java/com/floralquafloral/registries/character/CharacterDefinition.java deleted file mode 100644 index d83cc2c..0000000 --- a/src/main/java/com/floralquafloral/registries/character/CharacterDefinition.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.floralquafloral.registries.character; - -import com.floralquafloral.registries.MarioMajorStateDefinition; - -public interface CharacterDefinition extends MarioMajorStateDefinition { - -} diff --git a/src/main/java/com/floralquafloral/registries/character/ParsedCharacter.java b/src/main/java/com/floralquafloral/registries/character/ParsedCharacter.java deleted file mode 100644 index 77c401d..0000000 --- a/src/main/java/com/floralquafloral/registries/character/ParsedCharacter.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.floralquafloral.registries.character; - -import com.floralquafloral.CharaStat; -import com.floralquafloral.registries.ParsedMajorMarioState; -import com.floralquafloral.registries.ParsedMarioState; -import net.minecraft.util.Identifier; - -public class ParsedCharacter extends ParsedMajorMarioState { - public ParsedCharacter(CharacterDefinition definition) { - super(definition); - } - -// public double getStatFactor(CharaStat stat) { -// -// } -} diff --git a/src/main/java/com/floralquafloral/registries/MarioMajorStateDefinition.java b/src/main/java/com/floralquafloral/registries/states/MarioMajorStateDefinition.java similarity index 84% rename from src/main/java/com/floralquafloral/registries/MarioMajorStateDefinition.java rename to src/main/java/com/floralquafloral/registries/states/MarioMajorStateDefinition.java index b295cfb..e64203e 100644 --- a/src/main/java/com/floralquafloral/registries/MarioMajorStateDefinition.java +++ b/src/main/java/com/floralquafloral/registries/states/MarioMajorStateDefinition.java @@ -1,4 +1,4 @@ -package com.floralquafloral.registries; +package com.floralquafloral.registries.states; import com.floralquafloral.CharaStat; diff --git a/src/main/java/com/floralquafloral/registries/MarioStateDefinition.java b/src/main/java/com/floralquafloral/registries/states/MarioStateDefinition.java similarity index 89% rename from src/main/java/com/floralquafloral/registries/MarioStateDefinition.java rename to src/main/java/com/floralquafloral/registries/states/MarioStateDefinition.java index d2f340f..ef605ce 100644 --- a/src/main/java/com/floralquafloral/registries/MarioStateDefinition.java +++ b/src/main/java/com/floralquafloral/registries/states/MarioStateDefinition.java @@ -1,4 +1,4 @@ -package com.floralquafloral.registries; +package com.floralquafloral.registries.states; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.MarioClientData; diff --git a/src/main/java/com/floralquafloral/registries/ParsedMajorMarioState.java b/src/main/java/com/floralquafloral/registries/states/ParsedMajorMarioState.java similarity index 92% rename from src/main/java/com/floralquafloral/registries/ParsedMajorMarioState.java rename to src/main/java/com/floralquafloral/registries/states/ParsedMajorMarioState.java index 1915b4e..c6f865a 100644 --- a/src/main/java/com/floralquafloral/registries/ParsedMajorMarioState.java +++ b/src/main/java/com/floralquafloral/registries/states/ParsedMajorMarioState.java @@ -1,4 +1,4 @@ -package com.floralquafloral.registries; +package com.floralquafloral.registries.states; import com.floralquafloral.CharaStat; diff --git a/src/main/java/com/floralquafloral/registries/ParsedMarioState.java b/src/main/java/com/floralquafloral/registries/states/ParsedMarioState.java similarity index 93% rename from src/main/java/com/floralquafloral/registries/ParsedMarioState.java rename to src/main/java/com/floralquafloral/registries/states/ParsedMarioState.java index d456769..1924b8f 100644 --- a/src/main/java/com/floralquafloral/registries/ParsedMarioState.java +++ b/src/main/java/com/floralquafloral/registries/states/ParsedMarioState.java @@ -1,4 +1,4 @@ -package com.floralquafloral.registries; +package com.floralquafloral.registries.states; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.MarioClientData; diff --git a/src/main/java/com/floralquafloral/registries/action/ActionDefinition.java b/src/main/java/com/floralquafloral/registries/states/action/ActionDefinition.java similarity index 96% rename from src/main/java/com/floralquafloral/registries/action/ActionDefinition.java rename to src/main/java/com/floralquafloral/registries/states/action/ActionDefinition.java index 0c36eae..521dbc8 100644 --- a/src/main/java/com/floralquafloral/registries/action/ActionDefinition.java +++ b/src/main/java/com/floralquafloral/registries/states/action/ActionDefinition.java @@ -1,8 +1,8 @@ -package com.floralquafloral.registries.action; +package com.floralquafloral.registries.states.action; import com.floralquafloral.mariodata.client.MarioClientData; import com.floralquafloral.mariodata.MarioPlayerData; -import com.floralquafloral.registries.MarioStateDefinition; +import com.floralquafloral.registries.states.MarioStateDefinition; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,6 +13,7 @@ public interface ActionDefinition extends MarioStateDefinition { @Nullable String getAnimationName(); SneakLegalityRule getSneakLegalityRule(); SlidingStatus getConstantSlidingStatus(); + @Nullable Identifier getStompType(); List getPreTickTransitions(); List getPostTickTransitions(); diff --git a/src/main/java/com/floralquafloral/registries/action/GroundedActionDefinition.java b/src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java similarity index 95% rename from src/main/java/com/floralquafloral/registries/action/GroundedActionDefinition.java rename to src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java index 5f5020d..0f17809 100644 --- a/src/main/java/com/floralquafloral/registries/action/GroundedActionDefinition.java +++ b/src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java @@ -1,13 +1,11 @@ -package com.floralquafloral.registries.action; +package com.floralquafloral.registries.states.action; import com.floralquafloral.mariodata.MarioData; -import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.Input; import com.floralquafloral.mariodata.client.MarioClientData; import net.minecraft.util.math.BlockPos; import org.joml.Vector2d; -import static com.floralquafloral.CharaStat.*; import static com.floralquafloral.MarioQuaMario.LOGGER; public abstract class GroundedActionDefinition implements ActionDefinition { diff --git a/src/main/java/com/floralquafloral/registries/action/ParsedAction.java b/src/main/java/com/floralquafloral/registries/states/action/ParsedAction.java similarity index 95% rename from src/main/java/com/floralquafloral/registries/action/ParsedAction.java rename to src/main/java/com/floralquafloral/registries/states/action/ParsedAction.java index ebd9954..2a9e12a 100644 --- a/src/main/java/com/floralquafloral/registries/action/ParsedAction.java +++ b/src/main/java/com/floralquafloral/registries/states/action/ParsedAction.java @@ -1,12 +1,12 @@ -package com.floralquafloral.registries.action; +package com.floralquafloral.registries.states.action; import com.floralquafloral.MarioQuaMario; -import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.MarioDataPackets; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.ParsedMarioState; +import com.floralquafloral.registries.states.ParsedMarioState; import com.floralquafloral.registries.RegistryManager; +import com.floralquafloral.registries.stomp.ParsedStomp; import net.minecraft.util.Identifier; import net.minecraft.util.math.random.RandomSeed; @@ -20,6 +20,7 @@ public class ParsedAction extends ParsedMarioState { public final ActionDefinition.SneakLegalityRule SNEAK_LEGALITY; public final ActionDefinition.SlidingStatus SLIDING_STATUS; + public final ParsedStomp STOMP; private final EnumMap> TRANSITION_LISTS; @@ -29,6 +30,7 @@ public ParsedAction(ActionDefinition definition) { this.ANIMATION = definition.getAnimationName(); this.SNEAK_LEGALITY = definition.getSneakLegalityRule(); this.SLIDING_STATUS = definition.getConstantSlidingStatus(); + this.STOMP = RegistryManager.STOMP_TYPES.get(definition.getStompType()); this.TRANSITION_LISTS = new EnumMap<>(TransitionPhase.class); } diff --git a/src/main/java/com/floralquafloral/registries/action/TransitionPhase.java b/src/main/java/com/floralquafloral/registries/states/action/TransitionPhase.java similarity index 55% rename from src/main/java/com/floralquafloral/registries/action/TransitionPhase.java rename to src/main/java/com/floralquafloral/registries/states/action/TransitionPhase.java index 203a45a..e18be28 100644 --- a/src/main/java/com/floralquafloral/registries/action/TransitionPhase.java +++ b/src/main/java/com/floralquafloral/registries/states/action/TransitionPhase.java @@ -1,4 +1,4 @@ -package com.floralquafloral.registries.action; +package com.floralquafloral.registries.states.action; public enum TransitionPhase { PRE_TICK, diff --git a/src/main/java/com/floralquafloral/registries/action/baseactions/ActionDebug.java b/src/main/java/com/floralquafloral/registries/states/action/baseactions/ActionDebug.java similarity index 92% rename from src/main/java/com/floralquafloral/registries/action/baseactions/ActionDebug.java rename to src/main/java/com/floralquafloral/registries/states/action/baseactions/ActionDebug.java index 42a68e2..29e45f7 100644 --- a/src/main/java/com/floralquafloral/registries/action/baseactions/ActionDebug.java +++ b/src/main/java/com/floralquafloral/registries/states/action/baseactions/ActionDebug.java @@ -1,10 +1,10 @@ -package com.floralquafloral.registries.action.baseactions; +package com.floralquafloral.registries.states.action.baseactions; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.client.Input; import com.floralquafloral.mariodata.client.MarioClientData; import com.floralquafloral.mariodata.MarioPlayerData; -import com.floralquafloral.registries.action.ActionDefinition; +import com.floralquafloral.registries.states.action.ActionDefinition; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; @@ -42,6 +42,9 @@ public void serverTick(MarioPlayerData data) { @Override public SlidingStatus getConstantSlidingStatus() { return SlidingStatus.SLIDING_SILENT; } + @Override public @Nullable Identifier getStompType() { + return null; + } @Override public List getPreTickTransitions() { diff --git a/src/main/java/com/floralquafloral/registries/action/baseactions/ActionDebugAlt.java b/src/main/java/com/floralquafloral/registries/states/action/baseactions/ActionDebugAlt.java similarity index 92% rename from src/main/java/com/floralquafloral/registries/action/baseactions/ActionDebugAlt.java rename to src/main/java/com/floralquafloral/registries/states/action/baseactions/ActionDebugAlt.java index 5acce06..15c869a 100644 --- a/src/main/java/com/floralquafloral/registries/action/baseactions/ActionDebugAlt.java +++ b/src/main/java/com/floralquafloral/registries/states/action/baseactions/ActionDebugAlt.java @@ -1,10 +1,10 @@ -package com.floralquafloral.registries.action.baseactions; +package com.floralquafloral.registries.states.action.baseactions; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.Input; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.action.ActionDefinition; +import com.floralquafloral.registries.states.action.ActionDefinition; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; @@ -45,6 +45,9 @@ public void serverTick(MarioPlayerData data) { @Override public SlidingStatus getConstantSlidingStatus() { return SlidingStatus.SLIDING_SILENT; } + @Override public @Nullable Identifier getStompType() { + return null; + } @Override public List getPreTickTransitions() { diff --git a/src/main/java/com/floralquafloral/registries/action/baseactions/grounded/ActionBasic.java b/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/ActionBasic.java similarity index 94% rename from src/main/java/com/floralquafloral/registries/action/baseactions/grounded/ActionBasic.java rename to src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/ActionBasic.java index 2b41a28..34525ae 100644 --- a/src/main/java/com/floralquafloral/registries/action/baseactions/grounded/ActionBasic.java +++ b/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/ActionBasic.java @@ -1,10 +1,10 @@ -package com.floralquafloral.registries.action.baseactions.grounded; +package com.floralquafloral.registries.states.action.baseactions.grounded; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.Input; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.action.GroundedActionDefinition; +import com.floralquafloral.registries.states.action.GroundedActionDefinition; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -126,6 +126,9 @@ else if(data.getForwardVel() < BACKPEDAL_SPEED.getAsLimit(data)) { @Override public SlidingStatus getConstantSlidingStatus() { return SlidingStatus.NOT_SLIDING; } + @Override public @Nullable Identifier getStompType() { + return Identifier.of("qua_mario:stomp"); + } @Override public List getPreTickTransitions() { diff --git a/src/main/java/com/floralquafloral/registries/action/baseactions/grounded/DuckSlide.java b/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/DuckSlide.java similarity index 91% rename from src/main/java/com/floralquafloral/registries/action/baseactions/grounded/DuckSlide.java rename to src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/DuckSlide.java index 7ea7268..89280c3 100644 --- a/src/main/java/com/floralquafloral/registries/action/baseactions/grounded/DuckSlide.java +++ b/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/DuckSlide.java @@ -1,10 +1,10 @@ -package com.floralquafloral.registries.action.baseactions.grounded; +package com.floralquafloral.registries.states.action.baseactions.grounded; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.Input; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.action.GroundedActionDefinition; +import com.floralquafloral.registries.states.action.GroundedActionDefinition; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import org.jetbrains.annotations.NotNull; @@ -44,6 +44,9 @@ public void groundedSelfTick(MarioClientData data) { @Override public SlidingStatus getConstantSlidingStatus() { return SlidingStatus.SLIDING; } + @Override public @Nullable Identifier getStompType() { + return null; + } @Override public List getPreTickTransitions() { diff --git a/src/main/java/com/floralquafloral/registries/action/baseactions/grounded/DuckWaddle.java b/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/DuckWaddle.java similarity index 89% rename from src/main/java/com/floralquafloral/registries/action/baseactions/grounded/DuckWaddle.java rename to src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/DuckWaddle.java index 21e6457..2a49c7f 100644 --- a/src/main/java/com/floralquafloral/registries/action/baseactions/grounded/DuckWaddle.java +++ b/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/DuckWaddle.java @@ -1,10 +1,10 @@ -package com.floralquafloral.registries.action.baseactions.grounded; +package com.floralquafloral.registries.states.action.baseactions.grounded; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.Input; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.action.GroundedActionDefinition; +import com.floralquafloral.registries.states.action.GroundedActionDefinition; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,6 +47,9 @@ public void groundedSelfTick(MarioClientData data) { @Override public SlidingStatus getConstantSlidingStatus() { return SlidingStatus.NOT_SLIDING; } + @Override public @Nullable Identifier getStompType() { + return null; + } @Override public List getPreTickTransitions() { diff --git a/src/main/java/com/floralquafloral/registries/states/character/CharacterDefinition.java b/src/main/java/com/floralquafloral/registries/states/character/CharacterDefinition.java new file mode 100644 index 0000000..23583f4 --- /dev/null +++ b/src/main/java/com/floralquafloral/registries/states/character/CharacterDefinition.java @@ -0,0 +1,7 @@ +package com.floralquafloral.registries.states.character; + +import com.floralquafloral.registries.states.MarioMajorStateDefinition; + +public interface CharacterDefinition extends MarioMajorStateDefinition { + +} diff --git a/src/main/java/com/floralquafloral/registries/states/character/ParsedCharacter.java b/src/main/java/com/floralquafloral/registries/states/character/ParsedCharacter.java new file mode 100644 index 0000000..2db8e43 --- /dev/null +++ b/src/main/java/com/floralquafloral/registries/states/character/ParsedCharacter.java @@ -0,0 +1,13 @@ +package com.floralquafloral.registries.states.character; + +import com.floralquafloral.registries.states.ParsedMajorMarioState; + +public class ParsedCharacter extends ParsedMajorMarioState { + public ParsedCharacter(CharacterDefinition definition) { + super(definition); + } + +// public double getStatFactor(CharaStat stat) { +// +// } +} diff --git a/src/main/java/com/floralquafloral/registries/character/basecharacters/Mario.java b/src/main/java/com/floralquafloral/registries/states/character/basecharacters/Mario.java similarity index 85% rename from src/main/java/com/floralquafloral/registries/character/basecharacters/Mario.java rename to src/main/java/com/floralquafloral/registries/states/character/basecharacters/Mario.java index 0bc4529..c9d5ab1 100644 --- a/src/main/java/com/floralquafloral/registries/character/basecharacters/Mario.java +++ b/src/main/java/com/floralquafloral/registries/states/character/basecharacters/Mario.java @@ -1,10 +1,10 @@ -package com.floralquafloral.registries.character.basecharacters; +package com.floralquafloral.registries.states.character.basecharacters; import com.floralquafloral.CharaStat; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.character.CharacterDefinition; +import com.floralquafloral.registries.states.character.CharacterDefinition; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/floralquafloral/registries/powerup/ParsedPowerUp.java b/src/main/java/com/floralquafloral/registries/states/powerup/ParsedPowerUp.java similarity index 86% rename from src/main/java/com/floralquafloral/registries/powerup/ParsedPowerUp.java rename to src/main/java/com/floralquafloral/registries/states/powerup/ParsedPowerUp.java index faa8577..b89b8cb 100644 --- a/src/main/java/com/floralquafloral/registries/powerup/ParsedPowerUp.java +++ b/src/main/java/com/floralquafloral/registries/states/powerup/ParsedPowerUp.java @@ -1,17 +1,13 @@ -package com.floralquafloral.registries.powerup; +package com.floralquafloral.registries.states.powerup; -import com.floralquafloral.CharaStat; import com.floralquafloral.mariodata.MarioData; -import com.floralquafloral.registries.ParsedMajorMarioState; -import com.floralquafloral.registries.ParsedMarioState; +import com.floralquafloral.registries.states.ParsedMajorMarioState; import com.floralquafloral.registries.RegistryManager; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.EnumMap; - public class ParsedPowerUp extends ParsedMajorMarioState { public final int VALUE; diff --git a/src/main/java/com/floralquafloral/registries/powerup/PowerUpDefinition.java b/src/main/java/com/floralquafloral/registries/states/powerup/PowerUpDefinition.java similarity index 92% rename from src/main/java/com/floralquafloral/registries/powerup/PowerUpDefinition.java rename to src/main/java/com/floralquafloral/registries/states/powerup/PowerUpDefinition.java index 513fa9e..e6659a0 100644 --- a/src/main/java/com/floralquafloral/registries/powerup/PowerUpDefinition.java +++ b/src/main/java/com/floralquafloral/registries/states/powerup/PowerUpDefinition.java @@ -1,8 +1,7 @@ -package com.floralquafloral.registries.powerup; +package com.floralquafloral.registries.states.powerup; import com.floralquafloral.mariodata.MarioData; -import com.floralquafloral.registries.MarioMajorStateDefinition; -import com.floralquafloral.registries.MarioStateDefinition; +import com.floralquafloral.registries.states.MarioMajorStateDefinition; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/floralquafloral/registries/powerup/basepowerups/SmallForm.java b/src/main/java/com/floralquafloral/registries/states/powerup/basepowerups/SmallForm.java similarity index 92% rename from src/main/java/com/floralquafloral/registries/powerup/basepowerups/SmallForm.java rename to src/main/java/com/floralquafloral/registries/states/powerup/basepowerups/SmallForm.java index 6cbcd91..52ac197 100644 --- a/src/main/java/com/floralquafloral/registries/powerup/basepowerups/SmallForm.java +++ b/src/main/java/com/floralquafloral/registries/states/powerup/basepowerups/SmallForm.java @@ -1,11 +1,11 @@ -package com.floralquafloral.registries.powerup.basepowerups; +package com.floralquafloral.registries.states.powerup.basepowerups; import com.floralquafloral.CharaStat; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.powerup.PowerUpDefinition; +import com.floralquafloral.registries.states.powerup.PowerUpDefinition; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/floralquafloral/registries/powerup/basepowerups/SuperForm.java b/src/main/java/com/floralquafloral/registries/states/powerup/basepowerups/SuperForm.java similarity index 93% rename from src/main/java/com/floralquafloral/registries/powerup/basepowerups/SuperForm.java rename to src/main/java/com/floralquafloral/registries/states/powerup/basepowerups/SuperForm.java index 1465cdb..37b692f 100644 --- a/src/main/java/com/floralquafloral/registries/powerup/basepowerups/SuperForm.java +++ b/src/main/java/com/floralquafloral/registries/states/powerup/basepowerups/SuperForm.java @@ -1,11 +1,11 @@ -package com.floralquafloral.registries.powerup.basepowerups; +package com.floralquafloral.registries.states.powerup.basepowerups; import com.floralquafloral.CharaStat; import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.client.MarioClientData; -import com.floralquafloral.registries.powerup.PowerUpDefinition; +import com.floralquafloral.registries.states.powerup.PowerUpDefinition; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java b/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java new file mode 100644 index 0000000..7687a18 --- /dev/null +++ b/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java @@ -0,0 +1,109 @@ +package com.floralquafloral.registries.stomp; + +import com.floralquafloral.mariodata.MarioData; +import com.floralquafloral.mariodata.MarioPlayerData; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.Saddleable; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.damage.DamageType; +import net.minecraft.entity.damage.DamageTypes; +import net.minecraft.entity.vehicle.VehicleEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.random.RandomSeed; + +import java.util.List; + +public class ParsedStomp { + public final Identifier ID; + private final StompDefinition DEFINITION; + + private final boolean MUST_FALL_ON_TARGET; + private final StompDefinition.PainfulStompResponse PAINFUL_STOMP_RESPONSE; + private final boolean SHOULD_ATTEMPT_MOUNTING; + private final boolean HITS_NONLIVING_ENTITIES; + + private final RegistryKey DAMAGE_TYPE; + private final Identifier POST_STOMP_ACTION; + + public ParsedStomp(StompDefinition definition) { + this.ID = definition.getID(); + this.DEFINITION = definition; + + this.MUST_FALL_ON_TARGET = definition.mustFallOnTarget(); + this.PAINFUL_STOMP_RESPONSE = definition.getPainfulStompResponse(); + this.SHOULD_ATTEMPT_MOUNTING = definition.shouldAttemptMounting(); + this.HITS_NONLIVING_ENTITIES = definition.canHitNonLiving(); + + this.DAMAGE_TYPE = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, definition.getDamageType()); + this.POST_STOMP_ACTION = definition.getPostStompAction(); + } + + public void executeServer(MarioPlayerData data, Entity target, boolean harmless, long seed) { + this.DEFINITION.executeServer(data, target, harmless, seed); + } + public void executeClient(MarioPlayerData data, boolean isSelf, Entity target, boolean harmless, long seed) { + this.DEFINITION.executeClient(data, isSelf, target, harmless, seed); + } + + public void attempt(MarioData data) { + ServerPlayerEntity mario = (ServerPlayerEntity) data.getMario(); + double yVel = data.getYVel(); + if(this.MUST_FALL_ON_TARGET && yVel > 0) return; + + List targets = mario.getWorld().getOtherEntities(mario, mario.getBoundingBox()); + + boolean enteredStompAction = false; + long seed = RandomSeed.getSeed(); + for(Entity target : targets) { + + if(target.getType().isIn(StompHandler.UNSTOMPABLE_TAG)) continue; + + if(this.MUST_FALL_ON_TARGET && target.getY() + target.getHeight() > mario.getHeight() - yVel) continue; + + + if(this.SHOULD_ATTEMPT_MOUNTING) { + if((target instanceof Saddleable saddleableTarget && saddleableTarget.isSaddled()) + || target instanceof VehicleEntity) { + if(mario.startRiding(target)) return; + } + } + + if(!(target instanceof LivingEntity)) continue; + if(!this.DEFINITION.canStompTarget(data, target)) continue; + + boolean targetHurtsToStomp = target.getType().isIn(StompHandler.HURTS_TO_STOMP_TAG); + if(this.PAINFUL_STOMP_RESPONSE == StompDefinition.PainfulStompResponse.INJURY && targetHurtsToStomp) { + // Hurt Mario + mario.damage(makeDamageSource(mario.getServerWorld(), DamageTypes.THORNS, target), 2.8F); + return; + } + + DamageSource damageSource = makeDamageSource(mario.getServerWorld(), this.DAMAGE_TYPE, mario); + boolean useLegsItem = damageSource.isIn(StompHandler.USES_LEGS_ITEM_TAG); + + ItemStack attackingArmor = mario.getEquippedStack(useLegsItem ? EquipmentSlot.LEGS : EquipmentSlot.FEET); + + + float damage = this.DEFINITION.calculateDamage(data, mario, attackingArmor, 0, 0, target); + + target.damage(damageSource, damage); + + boolean harmless = targetHurtsToStomp && this.PAINFUL_STOMP_RESPONSE == StompDefinition.PainfulStompResponse.BOUNCE; + StompHandler.networkStomp(mario, target, this, harmless, seed); + executeServer((MarioPlayerData) data, target, true, seed); + + return; + } + } + + private static DamageSource makeDamageSource(ServerWorld world, RegistryKey key, Entity attacker) { + return new DamageSource(world.getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).entryOf(key), attacker); + } +} diff --git a/src/main/java/com/floralquafloral/registries/stomp/StompDefinition.java b/src/main/java/com/floralquafloral/registries/stomp/StompDefinition.java new file mode 100644 index 0000000..00e991d --- /dev/null +++ b/src/main/java/com/floralquafloral/registries/stomp/StompDefinition.java @@ -0,0 +1,35 @@ +package com.floralquafloral.registries.stomp; + +import com.floralquafloral.mariodata.MarioData; +import com.floralquafloral.mariodata.MarioPlayerData; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface StompDefinition { + @NotNull Identifier getID(); + + boolean mustFallOnTarget(); + @NotNull PainfulStompResponse getPainfulStompResponse(); + boolean shouldAttemptMounting(); + boolean canHitNonLiving(); + + @NotNull Identifier getDamageType(); + @Nullable Identifier getPostStompAction(); + + boolean canStompTarget(MarioData data, Entity target); + + float calculateDamage(MarioData data, ServerPlayerEntity mario, ItemStack equipment, double equipmentArmor, double equipmentToughness, Entity target); + + void executeServer(MarioPlayerData data, Entity target, boolean harmless, long seed); + void executeClient(MarioPlayerData data, boolean isSelf, Entity target, boolean harmless, long seed); + + enum PainfulStompResponse { + INJURY, + BOUNCE, + STOMP + } +} diff --git a/src/main/java/com/floralquafloral/registries/stomp/StompHandler.java b/src/main/java/com/floralquafloral/registries/stomp/StompHandler.java new file mode 100644 index 0000000..a48fb14 --- /dev/null +++ b/src/main/java/com/floralquafloral/registries/stomp/StompHandler.java @@ -0,0 +1,81 @@ +package com.floralquafloral.registries.stomp; + +import com.floralquafloral.MarioPackets; +import com.floralquafloral.MarioQuaMario; +import com.floralquafloral.mariodata.MarioPlayerData; +import com.floralquafloral.registries.RegistryManager; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.damage.DamageType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.codec.PacketCodec; +import net.minecraft.network.codec.PacketCodecs; +import net.minecraft.network.packet.CustomPayload; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; + +import static com.floralquafloral.mariodata.MarioDataManager.getMarioData; + +public class StompHandler { + public static final TagKey USES_FEET_ITEM_TAG = TagKey.of(RegistryKeys.DAMAGE_TYPE, Identifier.of(MarioQuaMario.MOD_ID, "uses_feet_item")); + public static final TagKey USES_LEGS_ITEM_TAG = TagKey.of(RegistryKeys.DAMAGE_TYPE, Identifier.of(MarioQuaMario.MOD_ID, "uses_legs_item")); + public static final TagKey FLATTENS_ENTITIES_TAG = TagKey.of(RegistryKeys.DAMAGE_TYPE, Identifier.of(MarioQuaMario.MOD_ID, "flattens_entities")); + + public static final TagKey> UNSTOMPABLE_TAG = TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of(MarioQuaMario.MOD_ID, "unstompable")); + public static final TagKey> HURTS_TO_STOMP_TAG = TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of(MarioQuaMario.MOD_ID, "hurts_to_stomp")); + public static final TagKey> IMMUNE_TO_BASIC_STOMP_TAG = TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier.of(MarioQuaMario.MOD_ID, "immune_to_basic_stomp")); + + public static void registerPackets() { + ExecuteStompS2CPayload.register(); + } + public static void registerPacketsClient() { + ExecuteStompS2CPayload.registerReceiver(); + } + + public static void networkStomp(ServerPlayerEntity mario, Entity target, ParsedStomp stompType, boolean harmless, long seed) { + MarioPackets.sendPacketToTrackers(mario, new ExecuteStompS2CPayload(mario, stompType, target, harmless, seed)); + } + + private record ExecuteStompS2CPayload(int player, int stompType, int target, boolean harmless, long seed) implements CustomPayload { + public static final Id ID = new Id<>(Identifier.of(MarioQuaMario.MOD_ID, "execute_stomp")); + public static final PacketCodec CODEC = PacketCodec.tuple( + PacketCodecs.INTEGER, ExecuteStompS2CPayload::player, + PacketCodecs.INTEGER, ExecuteStompS2CPayload::stompType, + PacketCodecs.INTEGER, ExecuteStompS2CPayload::target, + PacketCodecs.BOOL, ExecuteStompS2CPayload::harmless, + PacketCodecs.VAR_LONG, ExecuteStompS2CPayload::seed, + ExecuteStompS2CPayload::new + ); + public ExecuteStompS2CPayload(PlayerEntity player, ParsedStomp stompType, Entity target, boolean harmless, long seed) { + this(player.getId(), RegistryManager.STOMP_TYPES.getRawIdOrThrow(stompType), target.getId(), harmless, seed); + } + public static void registerReceiver() { + ClientPlayNetworking.registerGlobalReceiver(ID, (payload, context) -> { + ParsedStomp stompType = RegistryManager.STOMP_TYPES.get(payload.stompType); + PlayerEntity mario = (PlayerEntity) context.player().getWorld().getEntityById(payload.player); + Entity target = context.player().getWorld().getEntityById(payload.target); + + if(mario == null || stompType == null || target == null) { + MarioQuaMario.LOGGER.error("Execute Stomp S2C packet had invalid information!"); + MarioQuaMario.LOGGER.error("Mario: {}", mario); + MarioQuaMario.LOGGER.error("Stomp Type: {}", stompType); + MarioQuaMario.LOGGER.error("Target: {}", target); + return; + } + stompType.executeClient((MarioPlayerData) getMarioData(mario), mario.isMainPlayer(), target, payload.harmless, payload.seed); + }); + } + + @Override public Id getId() { + return ID; + } + public static void register() { + PayloadTypeRegistry.playS2C().register(ID, CODEC); + } + } +} diff --git a/src/main/java/com/floralquafloral/registries/stomp/basestomptypes/JumpStomp.java b/src/main/java/com/floralquafloral/registries/stomp/basestomptypes/JumpStomp.java new file mode 100644 index 0000000..7e8ff44 --- /dev/null +++ b/src/main/java/com/floralquafloral/registries/stomp/basestomptypes/JumpStomp.java @@ -0,0 +1,70 @@ +package com.floralquafloral.registries.stomp.basestomptypes; + +import com.floralquafloral.MarioQuaMario; +import com.floralquafloral.mariodata.MarioData; +import com.floralquafloral.mariodata.MarioPlayerData; +import com.floralquafloral.registries.stomp.StompDefinition; +import com.floralquafloral.registries.stomp.StompHandler; +import net.minecraft.entity.Entity; +import net.minecraft.entity.MovementType; +import net.minecraft.item.ItemStack; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.Vec3d; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class JumpStomp implements StompDefinition { + @Override public @NotNull Identifier getID() { + return Identifier.of(MarioQuaMario.MOD_ID, "stomp"); + } + + @Override public boolean mustFallOnTarget() { + return true; + } + + @Override public @NotNull PainfulStompResponse getPainfulStompResponse() { + return PainfulStompResponse.INJURY; + } + + @Override public boolean shouldAttemptMounting() { + return true; + } + + @Override public boolean canHitNonLiving() { + return false; + } + + @Override public @NotNull Identifier getDamageType() { + return Identifier.of(MarioQuaMario.MOD_ID, "basic"); + } + + @Override public @Nullable Identifier getPostStompAction() { + return null; + } + + @Override + public boolean canStompTarget(MarioData data, Entity target) { + return !target.getType().isIn(StompHandler.IMMUNE_TO_BASIC_STOMP_TAG); + } + + @Override + public float calculateDamage(MarioData data, ServerPlayerEntity mario, ItemStack equipment, double equipmentArmor, double equipmentToughness, Entity target) { + return 1000; + } + + @Override + public void executeServer(MarioPlayerData data, Entity target, boolean harmless, long seed) { + executeCommon(data, target); + } + + @Override + public void executeClient(MarioPlayerData data, boolean isSelf, Entity target, boolean harmless, long seed) { + executeCommon(data, target); + } + + private void executeCommon(MarioPlayerData data, Entity target) { + data.getMario().move(MovementType.PISTON, new Vec3d(data.getMario().getX(), target.getY() + target.getHeight(), data.getMario().getZ())); + data.setYVel(1.0); + } +} diff --git a/src/main/java/com/floralquafloral/stomp/StompHandler.java b/src/main/java/com/floralquafloral/stomp/StompHandler.java deleted file mode 100644 index 8eef53e..0000000 --- a/src/main/java/com/floralquafloral/stomp/StompHandler.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.floralquafloral.stomp; - -public class StompHandler { -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7ab43db..28b13e7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -15,14 +15,18 @@ "icon": "assets/qua_mario/icon.png", "environment": "*", "entrypoints": { + "mario-stomp-types": [ + "com.floralquafloral.registries.stomp.basestomptypes.JumpStomp" + ], + "mario-actions-uncategorized": [ - "com.floralquafloral.registries.action.baseactions.ActionDebug", - "com.floralquafloral.registries.action.baseactions.ActionDebugAlt" + "com.floralquafloral.registries.states.action.baseactions.ActionDebug", + "com.floralquafloral.registries.states.action.baseactions.ActionDebugAlt" ], "mario-actions-grounded": [ - "com.floralquafloral.registries.action.baseactions.grounded.ActionBasic", - "com.floralquafloral.registries.action.baseactions.grounded.DuckWaddle", - "com.floralquafloral.registries.action.baseactions.grounded.DuckSlide" + "com.floralquafloral.registries.states.action.baseactions.grounded.ActionBasic", + "com.floralquafloral.registries.states.action.baseactions.grounded.DuckWaddle", + "com.floralquafloral.registries.states.action.baseactions.grounded.DuckSlide" ], "mario-actions-airborne" : [ @@ -32,11 +36,11 @@ ], "mario-power-ups": [ - "com.floralquafloral.registries.powerup.basepowerups.SuperForm", - "com.floralquafloral.registries.powerup.basepowerups.SmallForm" + "com.floralquafloral.registries.states.powerup.basepowerups.SuperForm", + "com.floralquafloral.registries.states.powerup.basepowerups.SmallForm" ], "mario-characters": [ - "com.floralquafloral.registries.character.basecharacters.Mario" + "com.floralquafloral.registries.states.character.basecharacters.Mario" ], "main": [ diff --git a/src/main/resources/qua_mario.mixins.json b/src/main/resources/qua_mario.mixins.json index f346687..a291041 100644 --- a/src/main/resources/qua_mario.mixins.json +++ b/src/main/resources/qua_mario.mixins.json @@ -15,6 +15,7 @@ "ClientPlayerEntityMixin", "ClientPlayNetworkHandlerMixin", "GameOptionsMixin", - "InGameHudMixin" + "InGameHudMixin", + "LivingEntityRendererMixin" ] } \ No newline at end of file