From 3af28800ceed7279c662bb9332bff97a2a32c4f6 Mon Sep 17 00:00:00 2001 From: Floral <49110090+floral-qua-floral@users.noreply.github.com> Date: Fri, 8 Nov 2024 23:07:13 -0500 Subject: [PATCH] Implemented armor protection checks and stomp damage formula. Attempted to balance it based on vanilla swords - taking into account attack speed, crits, & material cost --- .../com/floralquafloral/MarioCommand.java | 4 +- .../java/com/floralquafloral/VoiceLine.java | 116 ------------------ .../moveable/MarioMainClientData.java | 4 + .../mixin/GameOptionsMixin.java | 20 --- .../mixin/LivingEntityMixin.java | 21 ++++ .../mixin/PlayerEntityMixin.java | 1 - .../action/GroundedActionDefinition.java | 6 +- .../action/baseactions/airborne/LongJump.java | 2 +- .../action/baseactions/airborne/Stomp.java | 23 ++++ .../baseactions/grounded/ActionBasic.java | 2 +- .../registries/stomp/ParsedStomp.java | 86 ++++++++++--- .../registries/stomp/StompDefinition.java | 2 +- .../registries/stomp/StompHandler.java | 4 +- .../stomp/basestomptypes/JumpStomp.java | 24 ++-- .../floralquafloral/stats/StatCategory.java | 6 +- .../tags/damage_type/damages_helmet.json | 6 + src/main/resources/fabric.mod.json | 3 +- src/main/resources/qua_mario.mixins.json | 2 +- 18 files changed, 151 insertions(+), 181 deletions(-) delete mode 100644 src/main/java/com/floralquafloral/VoiceLine.java delete mode 100644 src/main/java/com/floralquafloral/mixin/GameOptionsMixin.java create mode 100644 src/main/java/com/floralquafloral/mixin/LivingEntityMixin.java create mode 100644 src/main/java/com/floralquafloral/registries/states/action/baseactions/airborne/Stomp.java create mode 100644 src/main/resources/data/minecraft/tags/damage_type/damages_helmet.json diff --git a/src/main/java/com/floralquafloral/MarioCommand.java b/src/main/java/com/floralquafloral/MarioCommand.java index 145c7b0..34445c6 100644 --- a/src/main/java/com/floralquafloral/MarioCommand.java +++ b/src/main/java/com/floralquafloral/MarioCommand.java @@ -122,9 +122,7 @@ private static int executeStomp(CommandContext context, boo ParsedStomp stompType = RegistryEntryReferenceArgumentType.getRegistryEntry(context, "stomp", RegistryManager.STOMP_TYPES_KEY).value(); 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((MarioServerData) MarioDataManager.getMarioData(stomper), target, false, seed); + stompType.executeServer((MarioServerData) MarioDataManager.getMarioData(stomper), target, true, false, RandomSeed.getSeed()); return sendFeedback(context, "Made " + stomper.getName().getString() + " perform a stomp of type " + stompType.ID + " on " + target.getName().getString()); } diff --git a/src/main/java/com/floralquafloral/VoiceLine.java b/src/main/java/com/floralquafloral/VoiceLine.java deleted file mode 100644 index 1b09ec4..0000000 --- a/src/main/java/com/floralquafloral/VoiceLine.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.floralquafloral; - -import com.floralquafloral.mariodata.MarioData; -import com.floralquafloral.registries.RegistryManager; -import com.floralquafloral.registries.states.character.ParsedCharacter; -import com.floralquafloral.util.ClientSoundPlayer; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.sound.PositionedSoundInstance; -import net.minecraft.client.sound.SoundManager; -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.Registries; -import net.minecraft.registry.Registry; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.sound.SoundCategory; -import net.minecraft.sound.SoundEvent; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.random.Random; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -public enum VoiceLine { - SELECT, - DUCK, - - DOUBLE_JUMP, - TRIPLE_JUMP, - GYMNAST_SALUTE, - - DUCK_JUMP, - LONG_JUMP, - BACKFLIP, - SIDEFLIP, - WALL_JUMP, - - REVERT, - BURNT, - - FIREBALL, - GET_STAR; - - private static final Map PLAYER_VOICE_LINES = new HashMap<>(); - private final Map SOUND_EVENTS; - - VoiceLine() { - SOUND_EVENTS = new HashMap<>(); - - for(ParsedCharacter character : RegistryManager.CHARACTERS) { - Identifier id = Identifier.of(character.ID.getNamespace(), "voice." + character.ID.getPath() + "." + this.name().toLowerCase(Locale.ROOT)); - MarioQuaMario.LOGGER.info("Automatically registering VoiceLine sound event {}...", id); - SoundEvent event = SoundEvent.of(id); - SOUND_EVENTS.put(character, event); - Registry.register(Registries.SOUND_EVENT, id, event); - } - } - - public void play(MarioData data, long seed) { - PlayerEntity mario = data.getMario(); - - if(mario.getWorld().isClient) { - ClientSoundPlayer.SOUND_MANAGER.stop(PLAYER_VOICE_LINES.get(mario)); - - PLAYER_VOICE_LINES.put(mario, ClientSoundPlayer.playSound( - SOUND_EVENTS.get(data.getCharacter()), - SoundCategory.VOICE, - mario, - 1.0F, - data.getPowerUp().VOICE_PITCH, - seed - )); - } - else { - MarioPackets.sendPacketToTrackers((ServerPlayerEntity) data.getMario(), new PlayVoiceLineS2CPayload(data.getMario(), this, seed)); - } - } - - public static void registerPackets() { - PlayVoiceLineS2CPayload.register(); - } - public static void registerPacketsClient() { - PlayVoiceLineS2CPayload.registerReceiver(); - } - - private record PlayVoiceLineS2CPayload(int player, int voiceLineOrdinal, long seed) implements CustomPayload { - public static final Id ID = new Id<>(Identifier.of(MarioQuaMario.MOD_ID, "play_voice_line")); - public static final PacketCodec CODEC = PacketCodec.tuple( - PacketCodecs.INTEGER, PlayVoiceLineS2CPayload::player, - PacketCodecs.INTEGER, PlayVoiceLineS2CPayload::voiceLineOrdinal, - PacketCodecs.VAR_LONG, PlayVoiceLineS2CPayload::seed, - PlayVoiceLineS2CPayload::new - ); - public PlayVoiceLineS2CPayload(PlayerEntity player, VoiceLine voiceLine, long seed) { - this(player.getId(), voiceLine.ordinal(), seed); - } - public static void registerReceiver() { - ClientPlayNetworking.registerGlobalReceiver(ID, (payload, context) -> { - - }); - } - - @Override public Id getId() { - return ID; - } - public static void register() { - PayloadTypeRegistry.playS2C().register(ID, CODEC); - } - } -} diff --git a/src/main/java/com/floralquafloral/mariodata/moveable/MarioMainClientData.java b/src/main/java/com/floralquafloral/mariodata/moveable/MarioMainClientData.java index 53365fe..924e962 100644 --- a/src/main/java/com/floralquafloral/mariodata/moveable/MarioMainClientData.java +++ b/src/main/java/com/floralquafloral/mariodata/moveable/MarioMainClientData.java @@ -35,6 +35,10 @@ public MarioMainClientData(ClientPlayerEntity mario) { } @Override public void setAction(ParsedAction action, long seed) { + this.setActionTransitionless(action); + } + + @Override public void setActionTransitionless(ParsedAction action) { MarioQuaMario.LOGGER.info("MarioMainClientData setAction to " + action.ID); if(action != getAction()) getTimers().actionTimer = 0; if(this.getAction().ANIMATION != null) diff --git a/src/main/java/com/floralquafloral/mixin/GameOptionsMixin.java b/src/main/java/com/floralquafloral/mixin/GameOptionsMixin.java deleted file mode 100644 index 79b67bb..0000000 --- a/src/main/java/com/floralquafloral/mixin/GameOptionsMixin.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.floralquafloral.mixin; - -import com.floralquafloral.MarioQuaMarioClient; -import com.floralquafloral.mariodata.moveable.MarioMainClientData; -import net.minecraft.client.option.GameOptions; -import net.minecraft.client.option.SimpleOption; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(GameOptions.class) -public abstract class GameOptionsMixin { -// @Inject(method = "getBobView", at = @At("HEAD"), cancellable = true) -// public void preventViewBobbing(CallbackInfoReturnable> cir) { -// MarioMainClientData data = MarioMainClientData.getInstance(); -// if(data != null && !data.getAction().SLIDING_STATUS.doViewBobbing()) -// cir.setReturnValue(MarioQuaMarioClient.ALWAYS_FALSE); -// } -} diff --git a/src/main/java/com/floralquafloral/mixin/LivingEntityMixin.java b/src/main/java/com/floralquafloral/mixin/LivingEntityMixin.java new file mode 100644 index 0000000..0b19c95 --- /dev/null +++ b/src/main/java/com/floralquafloral/mixin/LivingEntityMixin.java @@ -0,0 +1,21 @@ +package com.floralquafloral.mixin; + +import com.floralquafloral.MarioQuaMario; +import com.floralquafloral.registries.stomp.ParsedStomp; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(LivingEntity.class) +public class LivingEntityMixin { + @Inject(method = "applyArmorToDamage", at = @At("RETURN"), cancellable = true) + private void addStompPiercingDamage(DamageSource source, float amount, CallbackInfoReturnable cir) { + if(source instanceof ParsedStomp.StompDamageSource stompDamageSource) { + MarioQuaMario.LOGGER.info("Added piercing damage from Stomp: {}", stompDamageSource.getPiercing()); + cir.setReturnValue(cir.getReturnValue() + stompDamageSource.getPiercing()); + } + } +} diff --git a/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java b/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java index c98704a..a5cae88 100644 --- a/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/floralquafloral/mixin/PlayerEntityMixin.java @@ -78,7 +78,6 @@ public void slideOffLedges(CallbackInfoReturnable cir) { public void uwuuber(CallbackInfo ci) { MarioData data = MarioDataManager.getMarioData(this); if(data.isClient() && !data.getAction().SLIDING_STATUS.doViewBobbing()) { -// prevStrideDistance = 0; strideDistance = prevStrideDistance * 0.6F; } } 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 8b42a0d..8e8e13f 100644 --- a/src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java +++ b/src/main/java/com/floralquafloral/registries/states/action/GroundedActionDefinition.java @@ -49,11 +49,13 @@ public static void performJump(MarioTravelData data, CharaStat velocityStat, @Nu } @Override public final void travelHook(MarioTravelData data) { - if(data.isClient()) + if(data.isClient()) { + AirborneActionDefinition.jumpCapped = false; data.setYVel(data.getYVel() + AirborneActionDefinition.AerialStats.GRAVITY.get(data)); + } else data.setYVel(-0.1); - AirborneActionDefinition.jumpCapped = false; + this.groundedTravel(data); } diff --git a/src/main/java/com/floralquafloral/registries/states/action/baseactions/airborne/LongJump.java b/src/main/java/com/floralquafloral/registries/states/action/baseactions/airborne/LongJump.java index 1e6af99..d43e34e 100644 --- a/src/main/java/com/floralquafloral/registries/states/action/baseactions/airborne/LongJump.java +++ b/src/main/java/com/floralquafloral/registries/states/action/baseactions/airborne/LongJump.java @@ -28,7 +28,7 @@ public class LongJump extends AirborneActionDefinition { public static final CharaStat LONG_JUMP_THRESHOLD = new CharaStat(0.285, StatCategory.THRESHOLD); @Override public SneakLegalityRule getSneakLegalityRule() { - return SneakLegalityRule.ALLOW; + return SneakLegalityRule.PROHIBIT; } @Override public SlidingStatus getConstantSlidingStatus() { return SlidingStatus.NOT_SLIDING; diff --git a/src/main/java/com/floralquafloral/registries/states/action/baseactions/airborne/Stomp.java b/src/main/java/com/floralquafloral/registries/states/action/baseactions/airborne/Stomp.java new file mode 100644 index 0000000..43509b2 --- /dev/null +++ b/src/main/java/com/floralquafloral/registries/states/action/baseactions/airborne/Stomp.java @@ -0,0 +1,23 @@ +package com.floralquafloral.registries.states.action.baseactions.airborne; + +import com.floralquafloral.MarioQuaMario; +import com.floralquafloral.registries.states.action.baseactions.grounded.DuckWaddle; +import com.floralquafloral.stats.CharaStat; +import com.floralquafloral.stats.StatCategory; +import net.minecraft.util.Identifier; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class Stomp extends Jump { + @Override public @NotNull Identifier getID() { + return Identifier.of(MarioQuaMario.MOD_ID, "stomp"); + } + + public static final CharaStat CAP = new CharaStat(0.65, StatCategory.JUMP_CAP); + + @Override protected @Nullable CharaStat getJumpCap() { + return CAP; + } +} diff --git a/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/ActionBasic.java b/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/ActionBasic.java index d4d6d5d..84f4e29 100644 --- a/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/ActionBasic.java +++ b/src/main/java/com/floralquafloral/registries/states/action/baseactions/grounded/ActionBasic.java @@ -175,7 +175,7 @@ public List getPostTickTransitions() { new ActionTransitionDefinition("qua_mario:p_run", (data) -> data.getForwardVel() >= RUN_SPEED.getAsThreshold(data), data -> data.setForwardVel(Math.max(PRun.P_SPEED.get(data), data.getForwardVel())), - (data, isSelf, seed) -> data.playSoundEvent(SoundEvents.ENTITY_ARROW_SHOOT, seed) + null ) ); } diff --git a/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java b/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java index cae43ab..e87a426 100644 --- a/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java +++ b/src/main/java/com/floralquafloral/registries/stomp/ParsedStomp.java @@ -1,22 +1,26 @@ package com.floralquafloral.registries.stomp; +import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioClientSideData; -import com.floralquafloral.mariodata.MarioData; import com.floralquafloral.mariodata.MarioDataPackets; -import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.moveable.MarioMoveableData; import com.floralquafloral.mariodata.moveable.MarioServerData; -import com.floralquafloral.mariodata.moveable.MarioTravelData; import com.floralquafloral.registries.RegistryManager; -import com.floralquafloral.util.ClientSoundPlayer; +import com.floralquafloral.registries.states.action.AirborneActionDefinition; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.AttributeModifierSlot; +import net.minecraft.component.type.AttributeModifiersComponent; import net.minecraft.entity.Entity; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.Saddleable; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.attribute.EntityAttributes; 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.ArmorItem; import net.minecraft.item.ItemStack; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; @@ -27,6 +31,7 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.random.RandomSeed; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -41,7 +46,7 @@ public class ParsedStomp { private final RegistryKey DAMAGE_TYPE; private final SoundEvent SOUND_EVENT; - private final Identifier POST_STOMP_ACTION; + public final Identifier POST_STOMP_ACTION; public ParsedStomp(StompDefinition definition) { this.ID = definition.getID(); @@ -57,27 +62,53 @@ public ParsedStomp(StompDefinition definition) { this.POST_STOMP_ACTION = definition.getPostStompAction(); } - public void executeServer(MarioServerData data, Entity target, boolean harmless, long seed) { + public void executeServer(MarioServerData data, Entity target, boolean affectMario, boolean harmless, long seed) { ServerPlayerEntity mario = data.getMario(); - DamageSource damageSource = makeDamageSource(mario.getServerWorld(), this.DAMAGE_TYPE, mario); - boolean useLegsItem = damageSource.isIn(StompHandler.USES_LEGS_ITEM_TAG); +// DamageSource damageSource = makeDamageSource(mario.getServerWorld(), this.DAMAGE_TYPE, mario); + StompDamageSource stompDamageSource = new StompDamageSource(mario.getServerWorld(), this.DAMAGE_TYPE, mario); + boolean useLegsItem = stompDamageSource.isIn(StompHandler.USES_LEGS_ITEM_TAG); ItemStack attackingArmor = mario.getEquippedStack(useLegsItem ? EquipmentSlot.LEGS : EquipmentSlot.FEET); + float armor = 0.0F; + float toughness = 0.0F; + boolean attributeModifierFound = false; + + for(AttributeModifiersComponent.Entry entry : attackingArmor.getOrDefault( + DataComponentTypes.ATTRIBUTE_MODIFIERS, AttributeModifiersComponent.DEFAULT).modifiers()) { + attributeModifierFound = true; + if( + entry.modifier().operation() == EntityAttributeModifier.Operation.ADD_VALUE && + (entry.slot() == AttributeModifierSlot.ANY + || entry.slot() == AttributeModifierSlot.ARMOR + || entry.slot() == (useLegsItem ? AttributeModifierSlot.LEGS : AttributeModifierSlot.FEET)) + ) { + if (entry.attribute().value().equals(EntityAttributes.GENERIC_ARMOR.value())) + armor += (float) entry.modifier().value(); + else if (entry.attribute().value().equals(EntityAttributes.GENERIC_ARMOR_TOUGHNESS.value())) + toughness += (float) entry.modifier().value(); + } + } + + if(!attributeModifierFound && attackingArmor.getItem() instanceof ArmorItem trueArmor) { + armor = trueArmor.getProtection(); + toughness = trueArmor.getToughness(); + } - float damage = this.DEFINITION.calculateDamage(data, mario, attackingArmor, 0, 0, target); -// for(RegistryEntry ick : attackingArmor.getEnchantments().getEnchantments()) { -// int level = attackingArmor.getEnchantments().getLevel(ick); -//// ick. -// } + float damage = this.DEFINITION.calculateDamage(data, mario, attackingArmor, armor, target); + stompDamageSource.piercing = 2.0F * toughness; - target.damage(damageSource, damage); + target.damage(stompDamageSource, Math.max(1.0F, damage - 0.6F * stompDamageSource.piercing)); - this.DEFINITION.executeTravellers(data, target, harmless); + if(affectMario) { + this.DEFINITION.executeTravellers(data, target, harmless); + data.setActionTransitionless(RegistryManager.ACTIONS.get(this.POST_STOMP_ACTION)); + StompHandler.networkStomp(data.getMario(), target, this, harmless, seed); + } } public void executeClient(MarioClientSideData data, boolean isSelf, Entity target, boolean harmless, long seed) { if(this.SOUND_EVENT != null) { - ClientSoundPlayer.playSound( + data.playSoundEvent( this.SOUND_EVENT, SoundCategory.PLAYERS, data.getMario().getX(), @@ -94,20 +125,23 @@ public void executeClient(MarioClientSideData data, boolean isSelf, Entity targe this.DEFINITION.executeTravellers(moveableData, target, harmless); moveableData.applyModifiedVelocity(); } + + if(data.getMario().isMainPlayer()) AirborneActionDefinition.jumpCapped = false; } public boolean attempt(MarioServerData data, Vec3d movement) { ServerPlayerEntity mario = data.getMario(); List targets = mario.getWorld().getOtherEntities(mario, mario.getBoundingBox().stretch(movement)); + boolean affectMario = true; long seed = RandomSeed.getSeed(); for(Entity target : targets) { - if(attemptOnTarget(mario, data, target, seed)) return true; + if(attemptOnTarget(mario, data, target, affectMario, seed)) affectMario = false; } return false; } - private boolean attemptOnTarget(ServerPlayerEntity mario, MarioServerData data, Entity target, long seed) { + private boolean attemptOnTarget(ServerPlayerEntity mario, MarioServerData data, Entity target, boolean affectMario, long seed) { if(target.getType().isIn(StompHandler.UNSTOMPABLE_TAG)) return false; if(this.MUST_FALL_ON_TARGET && target.getY() + target.getHeight() > mario.getY()) return false; @@ -139,8 +173,8 @@ else if(this.PAINFUL_STOMP_RESPONSE == StompDefinition.PainfulStompResponse.BOUN } - StompHandler.networkStomp(mario, target, this, harmless, seed); - executeServer(data, target, true, seed); + + executeServer(data, target, affectMario, harmless, seed); return true; } @@ -148,4 +182,16 @@ else if(this.PAINFUL_STOMP_RESPONSE == StompDefinition.PainfulStompResponse.BOUN private static DamageSource makeDamageSource(ServerWorld world, RegistryKey key, Entity attacker) { return new DamageSource(world.getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).entryOf(key), attacker); } + + public static class StompDamageSource extends DamageSource { + private float piercing; + + public StompDamageSource(ServerWorld world, RegistryKey key, @Nullable Entity attacker) { + super(world.getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).entryOf(key), attacker); + } + + public float getPiercing() { + return this.piercing; + } + } } diff --git a/src/main/java/com/floralquafloral/registries/stomp/StompDefinition.java b/src/main/java/com/floralquafloral/registries/stomp/StompDefinition.java index abf8df0..5b4adaa 100644 --- a/src/main/java/com/floralquafloral/registries/stomp/StompDefinition.java +++ b/src/main/java/com/floralquafloral/registries/stomp/StompDefinition.java @@ -25,7 +25,7 @@ public interface StompDefinition { boolean canStompTarget(MarioData data, Entity target); - float calculateDamage(MarioData data, ServerPlayerEntity mario, ItemStack equipment, double equipmentArmor, double equipmentToughness, Entity target); + float calculateDamage(MarioData data, ServerPlayerEntity mario, ItemStack equipment, float equipmentArmorValue, Entity target); void executeTravellers(MarioTravelData data, Entity target, boolean harmless); void executeClients(MarioClientSideData data, boolean isSelf, Entity target, boolean harmless, long seed); diff --git a/src/main/java/com/floralquafloral/registries/stomp/StompHandler.java b/src/main/java/com/floralquafloral/registries/stomp/StompHandler.java index 115be53..a740ad1 100644 --- a/src/main/java/com/floralquafloral/registries/stomp/StompHandler.java +++ b/src/main/java/com/floralquafloral/registries/stomp/StompHandler.java @@ -68,7 +68,9 @@ public static void registerReceiver() { MarioQuaMario.LOGGER.error("Target: {}", target); return; } - stompType.executeClient((MarioClientSideData) getMarioData(mario), mario.isMainPlayer(), target, payload.harmless, payload.seed); + MarioPlayerData data = getMarioData(mario); + stompType.executeClient((MarioClientSideData) data, mario.isMainPlayer(), target, payload.harmless, payload.seed); + data.setActionTransitionless(RegistryManager.ACTIONS.get(stompType.POST_STOMP_ACTION)); }); } diff --git a/src/main/java/com/floralquafloral/registries/stomp/basestomptypes/JumpStomp.java b/src/main/java/com/floralquafloral/registries/stomp/basestomptypes/JumpStomp.java index bd5bfc4..6a56316 100644 --- a/src/main/java/com/floralquafloral/registries/stomp/basestomptypes/JumpStomp.java +++ b/src/main/java/com/floralquafloral/registries/stomp/basestomptypes/JumpStomp.java @@ -3,10 +3,11 @@ import com.floralquafloral.MarioQuaMario; import com.floralquafloral.mariodata.MarioClientSideData; import com.floralquafloral.mariodata.MarioData; -import com.floralquafloral.mariodata.MarioPlayerData; import com.floralquafloral.mariodata.moveable.MarioTravelData; import com.floralquafloral.registries.stomp.StompDefinition; import com.floralquafloral.registries.stomp.StompHandler; +import com.floralquafloral.stats.CharaStat; +import com.floralquafloral.stats.StatCategory; import com.floralquafloral.util.MarioSFX; import net.minecraft.entity.Entity; import net.minecraft.entity.MovementType; @@ -23,6 +24,9 @@ public class JumpStomp implements StompDefinition { return Identifier.of(MarioQuaMario.MOD_ID, "stomp"); } + public final CharaStat BASE_DAMAGE = new CharaStat(4.5, StatCategory.STOMP_BASE_DAMAGE); + public final CharaStat BOUNCE_VEL = new CharaStat(1.15, StatCategory.STOMP_BOUNCE); + @Override public boolean mustFallOnTarget() { return true; } @@ -47,28 +51,24 @@ public class JumpStomp implements StompDefinition { } @Override public @Nullable Identifier getPostStompAction() { - return null; + return Identifier.of(MarioQuaMario.MOD_ID, "stomp"); } - @Override - public boolean canStompTarget(MarioData data, Entity target) { + @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 float calculateDamage(MarioData data, ServerPlayerEntity mario, ItemStack equipment, float equipmentArmorValue, Entity target) { + return ((float) BASE_DAMAGE.get(data)) + equipmentArmorValue * 2.25F; } - @Override - public void executeTravellers(MarioTravelData data, Entity target, boolean harmless) { + @Override public void executeTravellers(MarioTravelData data, Entity target, boolean harmless) { double deltaY = data.getMario().getY() - (target.getY() - target.getHeight()); data.getMario().move(MovementType.PISTON, new Vec3d(0, deltaY, 0)); - data.setYVel(1.0); + data.setYVel(BOUNCE_VEL.get(data)); } - @Override - public void executeClients(MarioClientSideData data, boolean isSelf, Entity target, boolean harmless, long seed) { + @Override public void executeClients(MarioClientSideData data, boolean isSelf, Entity target, boolean harmless, long seed) { } } diff --git a/src/main/java/com/floralquafloral/stats/StatCategory.java b/src/main/java/com/floralquafloral/stats/StatCategory.java index 3ecbbc7..96986d3 100644 --- a/src/main/java/com/floralquafloral/stats/StatCategory.java +++ b/src/main/java/com/floralquafloral/stats/StatCategory.java @@ -28,5 +28,9 @@ public enum StatCategory { JUMPING_GRAVITY, NORMAL_GRAVITY, - TERMINAL_VELOCITY + TERMINAL_VELOCITY, + + STOMP_BASE_DAMAGE, + STOMP_ARMOR_MULTIPLIER, + STOMP_BOUNCE } diff --git a/src/main/resources/data/minecraft/tags/damage_type/damages_helmet.json b/src/main/resources/data/minecraft/tags/damage_type/damages_helmet.json new file mode 100644 index 0000000..f4d56bd --- /dev/null +++ b/src/main/resources/data/minecraft/tags/damage_type/damages_helmet.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "#qua_mario:flattens_entities" + ] +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b7c8e52..12e6af7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,7 +36,8 @@ "com.floralquafloral.registries.states.action.baseactions.airborne.PJump", "com.floralquafloral.registries.states.action.baseactions.airborne.DuckFall", "com.floralquafloral.registries.states.action.baseactions.airborne.DuckJump", - "com.floralquafloral.registries.states.action.baseactions.airborne.LongJump" + "com.floralquafloral.registries.states.action.baseactions.airborne.LongJump", + "com.floralquafloral.registries.states.action.baseactions.airborne.Stomp" ], "mario-actions-aquatic": [ diff --git a/src/main/resources/qua_mario.mixins.json b/src/main/resources/qua_mario.mixins.json index e1b8080..74a73a5 100644 --- a/src/main/resources/qua_mario.mixins.json +++ b/src/main/resources/qua_mario.mixins.json @@ -6,6 +6,7 @@ "DamageSourceMixin", "EntityMixin", "JumpMixin", + "LivingEntityMixin", "PlayerEntityMixin" ], "injectors": { @@ -14,7 +15,6 @@ "client": [ "ClientPlayerEntityMixin", "ClientPlayNetworkHandlerMixin", - "GameOptionsMixin", "InGameHudMixin", "LivingEntityRendererMixin" ]