From cb88e0c327fb3ab3413d8bfd765ae37bab9629fd Mon Sep 17 00:00:00 2001 From: Floral <49110090+floral-qua-floral@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:56:45 -0400 Subject: [PATCH] Stomp collisions now use a move() mixin --- .../com/floralquafloral/MarioCommand.java | 2 +- .../com/floralquafloral/MarioQuaMario.java | 41 ++++++----- .../mariodata/MarioDataManager.java | 3 +- .../mariodata/MarioPlayerData.java | 5 +- .../mixin/ClientPlayNetworkHandlerMixin.java | 5 +- .../floralquafloral/mixin/EntityMixin.java | 23 ++++++ .../registries/RegistryManager.java | 20 ------ .../action/GroundedActionDefinition.java | 2 + .../states/action/ParsedAction.java | 3 +- .../states/powerup/ParsedPowerUp.java | 4 +- .../registries/stomp/ParsedStomp.java | 64 +++++++++-------- .../com/floralquafloral/util/MarioSFX.java | 48 +++++++++++++ .../assets/qua_mario/lang/en_us.json | 20 +++--- .../resources/assets/qua_mario/sounds.json | 66 +++++++++--------- .../sounds/sfx/{ => action}/duck.ogg | Bin .../ground_pound.ogg} | Bin .../ground_pound_pre.ogg} | Bin .../sounds/sfx/{ => movement}/flip.ogg | Bin .../sounds/sfx/{ => movement}/jump.ogg | Bin .../normal_power.ogg} | Bin .../{revert_wii.ogg => power_up/revert.ogg} | Bin .../sfx/{stomp_jump.ogg => stomp/bound.ogg} | Bin .../sfx/{stomp_heavy.ogg => stomp/heavy.ogg} | Bin .../sfx/{stomp_spike.ogg => stomp/pointy.ogg} | Bin .../sfx/{stomp_spin.ogg => stomp/spin.ogg} | Bin .../sounds/sfx/{ => stomp}/stomp.ogg | Bin .../sfx/{stomp_yoshi.ogg => stomp/yoshi.ogg} | Bin .../qua_mario/tags/entity/hurts_to_stomp.json | 8 --- .../tags/entity_type/hurts_to_stomp.json | 7 ++ .../immune_to_basic_stomp.json | 0 .../{entity => entity_type}/unstompable.json | 0 31 files changed, 197 insertions(+), 124 deletions(-) create mode 100644 src/main/java/com/floralquafloral/util/MarioSFX.java rename src/main/resources/assets/qua_mario/sounds/sfx/{ => action}/duck.ogg (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{ground_pound_land.ogg => action/ground_pound.ogg} (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{ground_pound_flip.ogg => action/ground_pound_pre.ogg} (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{ => movement}/flip.ogg (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{ => movement}/jump.ogg (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{power_up_wii.ogg => power_up/normal_power.ogg} (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{revert_wii.ogg => power_up/revert.ogg} (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{stomp_jump.ogg => stomp/bound.ogg} (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{stomp_heavy.ogg => stomp/heavy.ogg} (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{stomp_spike.ogg => stomp/pointy.ogg} (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{stomp_spin.ogg => stomp/spin.ogg} (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{ => stomp}/stomp.ogg (100%) rename src/main/resources/assets/qua_mario/sounds/sfx/{stomp_yoshi.ogg => stomp/yoshi.ogg} (100%) delete mode 100644 src/main/resources/data/qua_mario/tags/entity/hurts_to_stomp.json create mode 100644 src/main/resources/data/qua_mario/tags/entity_type/hurts_to_stomp.json rename src/main/resources/data/qua_mario/tags/{entity => entity_type}/immune_to_basic_stomp.json (100%) rename src/main/resources/data/qua_mario/tags/{entity => entity_type}/unstompable.json (100%) diff --git a/src/main/java/com/floralquafloral/MarioCommand.java b/src/main/java/com/floralquafloral/MarioCommand.java index 645143c..fa0725f 100644 --- a/src/main/java/com/floralquafloral/MarioCommand.java +++ b/src/main/java/com/floralquafloral/MarioCommand.java @@ -120,7 +120,7 @@ private static int executeStomp(CommandContext context, boo Entity target = EntityArgumentType.getEntity(context, "goomba"); ParsedStomp stompType = RegistryEntryReferenceArgumentType.getRegistryEntry(context, "stomp", RegistryManager.STOMP_TYPES_KEY).value(); - stomper.teleport((ServerWorld) target.getWorld(), target.getX(), target.getY(), target.getZ(), target.getPitch(), target.getYaw()); + stomper.teleport((ServerWorld) target.getWorld(), target.getX(), target.getY() + target.getHeight(), target.getZ(), target.getPitch(), target.getYaw()); long seed = RandomSeed.getSeed(); StompHandler.networkStomp(stomper, target, stompType, false, seed); stompType.executeServer((MarioPlayerData) MarioDataManager.getMarioData(stomper), target, false, seed); diff --git a/src/main/java/com/floralquafloral/MarioQuaMario.java b/src/main/java/com/floralquafloral/MarioQuaMario.java index a050a67..7a50b7e 100644 --- a/src/main/java/com/floralquafloral/MarioQuaMario.java +++ b/src/main/java/com/floralquafloral/MarioQuaMario.java @@ -2,14 +2,16 @@ import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.MarioDataManager; +import com.floralquafloral.mariodata.MarioDataPackets; import com.floralquafloral.registries.RegistryManager; +import com.floralquafloral.registries.states.powerup.ParsedPowerUp; import com.floralquafloral.util.ModConfig; +import com.floralquafloral.util.MarioSFX; import me.shedaniel.autoconfig.AutoConfig; import me.shedaniel.autoconfig.serializer.GsonConfigSerializer; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents; -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; @@ -17,6 +19,7 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; import net.minecraft.world.GameRules; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,26 +67,30 @@ public void onInitialize() { MarioDataManager.registerEventListeners(); RegistryManager.register(); + MarioSFX.staticInitialize(); MarioPackets.registerCommon(); MarioCommand.registerMarioCommand(); -// ServerLivingEntityEvents.ALLOW_DEATH.register((livingEntity, damageSource, damageAmount) -> { -// if(livingEntity instanceof ServerPlayerEntity player) { -// MarioData data = MarioDataManager.getMarioData(player); -// if(data.isEnabled()) { -// // Revert if possible -// boolean canRevert = player.isOnGround(); -// if(canRevert) { -// player.playSound(RegistryManager.POWER_UP_SFX); -// data.setYVel(0.5); -// player.setHealth(20.0F); -// return false; -// } -// } -// } -// return true; -// }); + ServerLivingEntityEvents.ALLOW_DEATH.register((livingEntity, damageSource, damageAmount) -> { + if(livingEntity instanceof ServerPlayerEntity player) { + MarioData data = MarioDataManager.getMarioData(player); + if(data.isEnabled()) { + // Revert if possible + Identifier revertTargetID = data.getPowerUp().REVERT_TARGET; + if(revertTargetID != null) { + MarioDataPackets.setMarioPowerUp(player, RegistryManager.POWER_UPS.get(revertTargetID)); + + player.playSound(MarioSFX.REVERT); + + data.setYVel(0.5); + player.setHealth(player.getMaxHealth()); + return false; + } + } + } + return true; + }); } } \ No newline at end of file diff --git a/src/main/java/com/floralquafloral/mariodata/MarioDataManager.java b/src/main/java/com/floralquafloral/mariodata/MarioDataManager.java index be66371..b832fa7 100644 --- a/src/main/java/com/floralquafloral/mariodata/MarioDataManager.java +++ b/src/main/java/com/floralquafloral/mariodata/MarioDataManager.java @@ -72,7 +72,8 @@ public static void registerEventListeners() { ClientEntityEvents.ENTITY_LOAD.register((entity, world) -> { if(entity instanceof ClientPlayerEntity clientPlayer) { - MarioClientData data = (MarioClientData) getMarioData(clientPlayer); + MarioClientData data = MarioClientData.getInstance(); + if(data == null) return; CLIENT_PLAYERS_DATA.remove(clientPlayer); CLIENT_PLAYERS_DATA.remove(data.getMario()); data.setMario(clientPlayer); diff --git a/src/main/java/com/floralquafloral/mariodata/MarioPlayerData.java b/src/main/java/com/floralquafloral/mariodata/MarioPlayerData.java index 9b62cd1..3a6e422 100644 --- a/src/main/java/com/floralquafloral/mariodata/MarioPlayerData.java +++ b/src/main/java/com/floralquafloral/mariodata/MarioPlayerData.java @@ -7,6 +7,7 @@ import com.floralquafloral.registries.states.powerup.ParsedPowerUp; import com.floralquafloral.util.CPMIntegration; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; @@ -118,6 +119,7 @@ private void apply() { this.VELOCITIES.isGenerated = false; } +// private double prevY; public void tick() { if(this.getMario().getWorld().isClient) { this.action.otherClientsTick(this); @@ -129,7 +131,8 @@ public void tick() { this.powerUp.serverTick(this); this.character.serverTick(this); - if(this.action.STOMP != null) this.action.STOMP.attempt(this); +// if(this.action.STOMP != null) this.action.STOMP.attempt(this, prevY); +// prevY = getMario().getY(); this.applyModifiedVelocity(); } diff --git a/src/main/java/com/floralquafloral/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/com/floralquafloral/mixin/ClientPlayNetworkHandlerMixin.java index 2016ecd..3519e3b 100644 --- a/src/main/java/com/floralquafloral/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/com/floralquafloral/mixin/ClientPlayNetworkHandlerMixin.java @@ -1,6 +1,7 @@ package com.floralquafloral.mixin; import com.floralquafloral.MarioQuaMarioClient; +import com.floralquafloral.registries.stomp.StompHandler; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.damage.DamageSource; @@ -13,9 +14,9 @@ public abstract class ClientPlayNetworkHandlerMixin { // Code stolen from FlatteringAnvils by ItsFelix5 @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)) { + if(damageSource.isIn(StompHandler.FLATTENS_ENTITIES_TAG)) { MarioQuaMarioClient.SQUASHED_ENTITIES.add(instance); -// } + } instance.onDamaged(damageSource); } } diff --git a/src/main/java/com/floralquafloral/mixin/EntityMixin.java b/src/main/java/com/floralquafloral/mixin/EntityMixin.java index 8f1e6e9..f6e0ef0 100644 --- a/src/main/java/com/floralquafloral/mixin/EntityMixin.java +++ b/src/main/java/com/floralquafloral/mixin/EntityMixin.java @@ -2,12 +2,17 @@ import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.MarioDataManager; +import com.floralquafloral.registries.states.action.ParsedAction; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityPose; +import net.minecraft.entity.MovementType; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -47,4 +52,22 @@ private void preventStepSounds(BlockPos pos, BlockState state, CallbackInfo ci) ci.cancel(); } } + + @Unique + private static boolean shouldStompHook = true; + + @Inject(method = "move", at = @At("HEAD")) + private void executeStompsOnServer(MovementType movementType, Vec3d movement, CallbackInfo ci) { + if((Entity) (Object) this instanceof ServerPlayerEntity player && shouldStompHook) { + MarioData data = MarioDataManager.getMarioData(player); + if(data.useMarioPhysics()) { + ParsedAction action = data.getAction(); + if(action.STOMP != null) { + shouldStompHook = false; + action.STOMP.attempt(data, movement); + shouldStompHook = true; + } + } + } + } } diff --git a/src/main/java/com/floralquafloral/registries/RegistryManager.java b/src/main/java/com/floralquafloral/registries/RegistryManager.java index 1b8576e..acf061a 100644 --- a/src/main/java/com/floralquafloral/registries/RegistryManager.java +++ b/src/main/java/com/floralquafloral/registries/RegistryManager.java @@ -1,7 +1,6 @@ package com.floralquafloral.registries; import com.floralquafloral.MarioQuaMario; -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; @@ -15,12 +14,8 @@ import net.fabricmc.fabric.api.event.registry.RegistryAttribute; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.entrypoint.EntrypointContainer; -import net.minecraft.entity.damage.DamageType; -import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.RegistryKeys; -import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import java.util.ArrayList; @@ -36,21 +31,6 @@ public static void register() { registerCharacters(); } - public static final SoundEvent JUMP_SFX = makeAndRegisterSound("sfx.jump"); - - public static final SoundEvent STOMP_SFX = makeAndRegisterSound("sfx.stomp"); - - public static final SoundEvent POWER_UP_SFX = makeAndRegisterSound("sfx.power_up_wii"); - - private static SoundEvent makeAndRegisterSound(String id) { - Identifier identifier = Identifier.of(MarioQuaMario.MOD_ID, id); - SoundEvent event = SoundEvent.of(identifier); - - Registry.register(Registries.SOUND_EVENT, identifier, event); - - return event; - } - 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) diff --git a/src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java b/src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java index 0f17809..abe6252 100644 --- a/src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java +++ b/src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java @@ -3,6 +3,7 @@ import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.client.Input; import com.floralquafloral.mariodata.client.MarioClientData; +import com.floralquafloral.util.MarioSFX; import net.minecraft.util.math.BlockPos; import org.joml.Vector2d; @@ -27,6 +28,7 @@ protected abstract static class GroundedTransitions { (data) -> Input.DUCK.isHeld(), (data, isSelf, seed) -> { // Play duck voiceline + data.getMario().playSound(MarioSFX.DUCK); LOGGER.info("Ducking voiceline with seed {}", seed); }, (data, seed) -> { diff --git a/src/main/java/com/floralquafloral/registries/states/action/ParsedAction.java b/src/main/java/com/floralquafloral/registries/states/action/ParsedAction.java index 2a9e12a..92772e2 100644 --- a/src/main/java/com/floralquafloral/registries/states/action/ParsedAction.java +++ b/src/main/java/com/floralquafloral/registries/states/action/ParsedAction.java @@ -30,7 +30,8 @@ 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()); + Identifier stompID = definition.getStompType(); + this.STOMP = stompID == null ? null : RegistryManager.STOMP_TYPES.get(stompID); this.TRANSITION_LISTS = new EnumMap<>(TransitionPhase.class); } diff --git a/src/main/java/com/floralquafloral/registries/states/powerup/ParsedPowerUp.java b/src/main/java/com/floralquafloral/registries/states/powerup/ParsedPowerUp.java index b89b8cb..dd0cdeb 100644 --- a/src/main/java/com/floralquafloral/registries/states/powerup/ParsedPowerUp.java +++ b/src/main/java/com/floralquafloral/registries/states/powerup/ParsedPowerUp.java @@ -2,7 +2,7 @@ import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.registries.states.ParsedMajorMarioState; -import com.floralquafloral.registries.RegistryManager; +import com.floralquafloral.util.MarioSFX; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import org.jetbrains.annotations.NotNull; @@ -24,7 +24,7 @@ public ParsedPowerUp(PowerUpDefinition definition) { this.VALUE = definition.getValue(); SoundEvent acquisitionSound = definition.getAcquisitionSound(); - this.ACQUISITION_SOUND = acquisitionSound == null ? RegistryManager.POWER_UP_SFX : acquisitionSound; + this.ACQUISITION_SOUND = acquisitionSound == null ? MarioSFX.NORMAL_POWER : acquisitionSound; this.REVERT_TARGET = definition.getRevertTarget(); this.HEART = definition.getHeart(); diff --git a/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java b/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java index 0bae153..0781d74 100644 --- a/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java +++ b/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java @@ -19,9 +19,11 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.EntityTypeTags; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; +import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.random.RandomSeed; import java.util.List; @@ -77,47 +79,53 @@ public void executeClient(MarioPlayerData data, boolean isSelf, Entity target, b this.DEFINITION.executeClient(data, isSelf, target, harmless, seed); } - public void attempt(MarioData data) { + public void attempt(MarioData data, Vec3d movement) { 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().stretch(movement)); - List targets = mario.getWorld().getOtherEntities(mario, mario.getBoundingBox()); - - boolean enteredStompAction = false; long seed = RandomSeed.getSeed(); for(Entity target : targets) { + if(attemptOnTarget(mario, data, target, seed)) break; + } + } - if(target.getType().isIn(StompHandler.UNSTOMPABLE_TAG)) continue; + private boolean attemptOnTarget(ServerPlayerEntity mario, MarioData data, Entity target, long seed) { + if(target.getType().isIn(StompHandler.UNSTOMPABLE_TAG)) return false; - if(this.MUST_FALL_ON_TARGET && target.getY() + target.getHeight() > mario.getY() - yVel) continue; + if(this.MUST_FALL_ON_TARGET && target.getY() + target.getHeight() > mario.getY()) return false; - if(this.SHOULD_ATTEMPT_MOUNTING) { - if((target instanceof Saddleable saddleableTarget && saddleableTarget.isSaddled()) - || target instanceof VehicleEntity) { - if(mario.startRiding(target)) return; - } + if(this.SHOULD_ATTEMPT_MOUNTING) { + if((target instanceof Saddleable saddleableTarget && saddleableTarget.isSaddled()) + || target instanceof VehicleEntity) { + if(mario.startRiding(target)) return false; } + } - if(!(target instanceof LivingEntity livingTarget && !livingTarget.isDead())) continue; - if(!this.DEFINITION.canStompTarget(data, target)) continue; - livingTarget.isDead(); - - 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; - } + if(!(target instanceof LivingEntity livingTarget && !livingTarget.isDead())) return false; + if(!this.DEFINITION.canStompTarget(data, target)) return false; + livingTarget.isDead(); + + boolean targetHurtsToStomp = target.getType().isIn(StompHandler.HURTS_TO_STOMP_TAG); + MarioQuaMario.LOGGER.info("hurts:" + + "\ntarget type: " + target.getType() + + "\ntag: " + StompHandler.HURTS_TO_STOMP_TAG + + "\ninTag: " + target.getType().isIn(StompHandler.HURTS_TO_STOMP_TAG) + + "\ninVanillaTag: " + target.getType().isIn(EntityTypeTags.AQUATIC) + + "\nresponse: " + this.PAINFUL_STOMP_RESPONSE + ); + if(this.PAINFUL_STOMP_RESPONSE == StompDefinition.PainfulStompResponse.INJURY && targetHurtsToStomp) { + // Hurt Mario + mario.damage(makeDamageSource(mario.getServerWorld(), DamageTypes.THORNS, target), 2.8F); + return false; + } - boolean harmless = targetHurtsToStomp && this.PAINFUL_STOMP_RESPONSE == StompDefinition.PainfulStompResponse.BOUNCE; - StompHandler.networkStomp(mario, target, this, harmless, seed); - executeServer((MarioPlayerData) data, target, true, seed); + boolean harmless = targetHurtsToStomp && this.PAINFUL_STOMP_RESPONSE == StompDefinition.PainfulStompResponse.BOUNCE; + StompHandler.networkStomp(mario, target, this, harmless, seed); + executeServer((MarioPlayerData) data, target, true, seed); - return; - } + return true; } private static DamageSource makeDamageSource(ServerWorld world, RegistryKey key, Entity attacker) { diff --git a/src/main/java/com/floralquafloral/util/MarioSFX.java b/src/main/java/com/floralquafloral/util/MarioSFX.java new file mode 100644 index 0000000..e6fc432 --- /dev/null +++ b/src/main/java/com/floralquafloral/util/MarioSFX.java @@ -0,0 +1,48 @@ +package com.floralquafloral.util; + +import com.floralquafloral.MarioQuaMario; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.sound.SoundEvent; +import net.minecraft.util.Identifier; + +public abstract class MarioSFX { + public static final SoundEvent JUMP = makeMovementSound("jump"); + public static final SoundEvent FLIP = makeMovementSound("flip"); + + public static final SoundEvent NORMAL_POWER = makePowerSound("normal_power"); + public static final SoundEvent REVERT = makePowerSound("revert"); + + public static final SoundEvent STOMP = makeStompSound("stomp"); + public static final SoundEvent STOMP_POINTY = makeStompSound("pointy"); + public static final SoundEvent STOMP_SPIN = makeStompSound("spin"); + public static final SoundEvent STOMP_HEAVY = makeStompSound("heavy"); + public static final SoundEvent STOMP_YOSHI = makeStompSound("yoshi"); + + public static final SoundEvent DUCK = makeAndRegisterSound(""); + + private static SoundEvent makeMovementSound(String name) { + return makeAndRegisterSound("sfx.movement." + name); + } + private static SoundEvent makePowerSound(String name) { + return makeAndRegisterSound("sfx.power_up." + name); + } + private static SoundEvent makeStompSound(String name) { + return makeAndRegisterSound("sfx.stomp." + name); + } + private static SoundEvent makeActionSound(String name) { + return makeAndRegisterSound("sfx.action." + name); + } + + private static SoundEvent makeAndRegisterSound(String id) { + Identifier identifier = Identifier.of(MarioQuaMario.MOD_ID, id); + SoundEvent event = SoundEvent.of(identifier); + + Registry.register(Registries.SOUND_EVENT, identifier, event); + + return event; + } + public static void staticInitialize() { + + } +} diff --git a/src/main/resources/assets/qua_mario/lang/en_us.json b/src/main/resources/assets/qua_mario/lang/en_us.json index 5db4300..4d8c132 100644 --- a/src/main/resources/assets/qua_mario/lang/en_us.json +++ b/src/main/resources/assets/qua_mario/lang/en_us.json @@ -24,16 +24,16 @@ "tag.item.qua_mario.enchantable.pulverizing": "Enchantable with Pulverizing", - "subtitles.qua_mario.power_up_wii": "Powering up", - "subtitles.qua_mario.revert_wii": "Powering down", - "subtitles.qua_mario.jump": "Jumping", - "subtitles.qua_mario.stomp": "Something gets stomped", - "subtitles.qua_mario.stomp_spike": "Something pointy gets stomped", - "subtitles.qua_mario.stomp_spin": "Something gets stomped", - "subtitles.qua_mario.stomp_yoshi": "Something gets crushed", - "subtitles.qua_mario.ground_pound_flip": "Aerial flip", - "subtitles.qua_mario.ground_pound_land": "Ground pounded", - "subtitles.qua_mario.flip": "Aerial flip", + "subtitles.qua_mario.movement.jump": "Jumping", + "subtitles.qua_mario.movement.flip": "Aerial flip", + "subtitles.qua_mario.power_up.normal_power": "Powering up", + "subtitles.qua_mario.power_up.revert": "Powering down", + "subtitles.qua_mario.stomp.stomp": "Something gets stomped", + "subtitles.qua_mario.stomp.pointy": "Something pointy gets stomped", + "subtitles.qua_mario.stomp.spin": "Something gets stomped", + "subtitles.qua_mario.stomp.yoshi": "Something gets crushed", + "subtitles.qua_mario.action.ground_pound_pre": "Aerial flip", + "subtitles.qua_mario.action.ground_pound": "Ground pounded", "subtitles.qua_mario.voice_luigi_backflip": "Luigi cheers", "subtitles.qua_mario.voice_luigi_burnt": "Luigi gets burned", diff --git a/src/main/resources/assets/qua_mario/sounds.json b/src/main/resources/assets/qua_mario/sounds.json index eb52a04..86b90e9 100644 --- a/src/main/resources/assets/qua_mario/sounds.json +++ b/src/main/resources/assets/qua_mario/sounds.json @@ -1,68 +1,68 @@ { - "sfx.power_up_wii": { - "subtitle": "subtitles.qua_mario.power_up_wii", + "sfx.movement.jump": { + "subtitle": "subtitles.qua_mario.movement.jump", "sounds": [ - "qua_mario:sfx/power_up_wii" + "qua_mario:sfx/movement/jump" ] }, - "sfx.revert_wii": { - "subtitle": "subtitles.qua_mario.revert_wii", + "sfx.movement.flip": { + "subtitle": "subtitles.qua_mario.movement.flip", "sounds": [ - "qua_mario:sfx/revert_wii" + "qua_mario:sfx/movement/flip" ] }, - "sfx.jump": { - "subtitle": "subtitles.qua_mario.jump", + "sfx.power_up.normal_power": { + "subtitle": "subtitles.qua_mario.power_up.normal_power", "sounds": [ - "qua_mario:sfx/jump" + "qua_mario:sfx/power_up/normal_power" ] }, - "sfx.stomp": { - "subtitle": "subtitles.qua_mario.stomp", + "sfx.power_up.revert": { + "subtitle": "subtitles.qua_mario.power_up.revert", "sounds": [ - "qua_mario:sfx/stomp" + "qua_mario:sfx/power_up/revert" ] }, - "sfx.stomp_spike": { - "subtitle": "subtitles.qua_mario.stomp_spike", + "sfx.stomp.stomp": { + "subtitle": "subtitles.qua_mario.stomp.stomp", "sounds": [ - "qua_mario:sfx/stomp_spike" + "qua_mario:sfx/stomp/stomp" ] }, - "sfx.stomp_spin": { - "subtitle": "subtitles.qua_mario.stomp_spin", + "sfx.stomp.pointy": { + "subtitle": "subtitles.qua_mario.stomp.pointy", "sounds": [ - "qua_mario:sfx/stomp_spin" + "qua_mario:sfx/stomp/pointy" ] }, - "sfx.stomp_yoshi": { - "subtitle": "subtitles.qua_mario.stomp_yoshi", + "sfx.stomp.spin": { + "subtitle": "subtitles.qua_mario.stomp.spin", "sounds": [ - "qua_mario:sfx/stomp_yoshi" + "qua_mario:sfx/stomp/spin" ] }, - "sfx.ground_pound_flip": { - "subtitle": "subtitles.qua_mario.ground_pound_flip", + "sfx.stomp.heavy": { + "subtitle": "subtitles.qua_mario.stomp.heavy", "sounds": [ - "qua_mario:sfx/ground_pound_flip" + "qua_mario:sfx/stomp/heavy" ] }, - "sfx.ground_pound_land": { - "subtitle": "subtitles.qua_mario.ground_pound_land", + "sfx.stomp.yoshi": { + "subtitle": "subtitles.qua_mario.stomp.yoshi", "sounds": [ - "qua_mario:sfx/ground_pound_land" + "qua_mario:sfx/stomp/yoshi" ] }, - "sfx.duck": { - "subtitle": "subtitles.qua_mario.duck", + "sfx.action.ground_pound_pre": { + "subtitle": "subtitles.qua_mario.action.ground_pound_pre", "sounds": [ - "qua_mario:sfx/flip" + "qua_mario:sfx/action/ground_pound_pre" ] }, - "sfx.flip": { - "subtitle": "subtitles.qua_mario.flip", + "sfx.action.ground_pound": { + "subtitle": "subtitles.qua_mario.action.ground_pound", "sounds": [ - "qua_mario:sfx/flip" + "qua_mario:sfx/action/ground_pound" ] }, diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/duck.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/action/duck.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/duck.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/action/duck.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/ground_pound_land.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/action/ground_pound.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/ground_pound_land.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/action/ground_pound.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/ground_pound_flip.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/action/ground_pound_pre.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/ground_pound_flip.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/action/ground_pound_pre.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/flip.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/movement/flip.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/flip.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/movement/flip.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/jump.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/movement/jump.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/jump.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/movement/jump.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/power_up_wii.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/power_up/normal_power.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/power_up_wii.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/power_up/normal_power.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/revert_wii.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/power_up/revert.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/revert_wii.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/power_up/revert.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/stomp_jump.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/stomp/bound.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/stomp_jump.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/stomp/bound.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/stomp_heavy.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/stomp/heavy.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/stomp_heavy.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/stomp/heavy.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/stomp_spike.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/stomp/pointy.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/stomp_spike.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/stomp/pointy.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/stomp_spin.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/stomp/spin.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/stomp_spin.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/stomp/spin.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/stomp.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/stomp/stomp.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/stomp.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/stomp/stomp.ogg diff --git a/src/main/resources/assets/qua_mario/sounds/sfx/stomp_yoshi.ogg b/src/main/resources/assets/qua_mario/sounds/sfx/stomp/yoshi.ogg similarity index 100% rename from src/main/resources/assets/qua_mario/sounds/sfx/stomp_yoshi.ogg rename to src/main/resources/assets/qua_mario/sounds/sfx/stomp/yoshi.ogg diff --git a/src/main/resources/data/qua_mario/tags/entity/hurts_to_stomp.json b/src/main/resources/data/qua_mario/tags/entity/hurts_to_stomp.json deleted file mode 100644 index 648ab1a..0000000 --- a/src/main/resources/data/qua_mario/tags/entity/hurts_to_stomp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "replace": "false", - "values": [ - "minecraft:guardian", - "minecraft:elder_guardian", - "minecraft:pufferfish" - ] -} \ No newline at end of file diff --git a/src/main/resources/data/qua_mario/tags/entity_type/hurts_to_stomp.json b/src/main/resources/data/qua_mario/tags/entity_type/hurts_to_stomp.json new file mode 100644 index 0000000..92b0dbc --- /dev/null +++ b/src/main/resources/data/qua_mario/tags/entity_type/hurts_to_stomp.json @@ -0,0 +1,7 @@ +{ + "values": [ + "minecraft:guardian", + "minecraft:elder_guardian", + "minecraft:pufferfish" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/qua_mario/tags/entity/immune_to_basic_stomp.json b/src/main/resources/data/qua_mario/tags/entity_type/immune_to_basic_stomp.json similarity index 100% rename from src/main/resources/data/qua_mario/tags/entity/immune_to_basic_stomp.json rename to src/main/resources/data/qua_mario/tags/entity_type/immune_to_basic_stomp.json diff --git a/src/main/resources/data/qua_mario/tags/entity/unstompable.json b/src/main/resources/data/qua_mario/tags/entity_type/unstompable.json similarity index 100% rename from src/main/resources/data/qua_mario/tags/entity/unstompable.json rename to src/main/resources/data/qua_mario/tags/entity_type/unstompable.json