Skip to content

Commit

Permalink
Stomp attacks now play a special sound effect if the target is killed…
Browse files Browse the repository at this point in the history
… by the attack.
  • Loading branch information
floral-qua-floral committed Dec 4, 2024
1 parent 6d02934 commit 08f1e69
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -21,7 +20,7 @@ public interface StompDefinition {
boolean canHitNonLiving();

@NotNull Identifier getDamageType();
@Nullable SoundEvent getSoundEvent();

@Nullable Identifier getPostStompAction();

boolean canStompTarget(MarioData data, Entity target);
Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/com/floralquafloral/util/MarioSFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class MarioSFX {
public static final SoundEvent REVERT = makePowerSound("revert");

public static final SoundEvent STOMP = makeStompSound("stomp");
public static final SoundEvent STOMP_LAST = makeStompSound("last");
public static final SoundEvent STOMP_POINTY = makeStompSound("pointy");
public static final SoundEvent STOMP_SPIN = makeStompSound("spin");
public static final SoundEvent STOMP_HEAVY = makeStompSound("heavy");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class ParsedStomp {
private final boolean HITS_NONLIVING_ENTITIES;

private final RegistryKey<DamageType> DAMAGE_TYPE;
private final SoundEvent SOUND_EVENT;
public final Identifier POST_STOMP_ACTION;

public ParsedStomp(StompDefinition definition) {
Expand All @@ -59,7 +58,6 @@ public ParsedStomp(StompDefinition definition) {
this.HITS_NONLIVING_ENTITIES = definition.canHitNonLiving();

this.DAMAGE_TYPE = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, definition.getDamageType());
this.SOUND_EVENT = definition.getSoundEvent();
this.POST_STOMP_ACTION = definition.getPostStompAction();
}

Expand Down Expand Up @@ -117,18 +115,18 @@ else if (entry.attribute().value().equals(EntityAttributes.GENERIC_ARMOR_TOUGHNE
}
public void executeClient(MarioClientSideData data, boolean isSelf, Entity target, StompableEntity.StompResult result, long seed) {
data.getMario().fallDistance = 0;
if(this.SOUND_EVENT != null) {
data.playSoundEvent(
this.SOUND_EVENT,
SoundCategory.PLAYERS,
data.getMario().getX(),
target.getY() + target.getHeight(),
data.getMario().getZ(),
1.0F,
1.0F,
seed
);
}
// if(this.SOUND_EVENT != null) {
// data.playSoundEvent(
// this.SOUND_EVENT,
// SoundCategory.PLAYERS,
// data.getMario().getX(),
// target.getY() + target.getHeight(),
// data.getMario().getZ(),
// 1.0F,
// 1.0F,
// seed
// );
// }

this.DEFINITION.executeClients(data, isSelf, target, result, seed);
if(data instanceof MarioMoveableData moveableData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
import com.floralquafloral.registries.stomp.StompHandler;
import com.floralquafloral.util.MarioSFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MovementType;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -47,9 +48,6 @@ public class AquaticGroundPoundStomp implements StompDefinition {
@Override public @NotNull Identifier getDamageType() {
return Identifier.of(MarioQuaMario.MOD_ID, "aquatic_ground_pound");
}
@Override public @Nullable SoundEvent getSoundEvent() {
return MarioSFX.STOMP;
}

@Override public @Nullable Identifier getPostStompAction() {
return null;
Expand All @@ -71,5 +69,27 @@ public class AquaticGroundPoundStomp implements StompDefinition {

@Override public void executeClients(MarioClientSideData data, boolean isSelf, Entity target, StompableEntity.StompResult result, long seed) {
data.stopStoredSound(MarioSFX.DIVE);
if(target instanceof LivingEntity livingTarget && livingTarget.isDead())
data.playSoundEvent(
MarioSFX.STOMP_LAST,
SoundCategory.PLAYERS,
target.getX(),
target.getY(),
target.getZ(),
0.85F,
1,
seed
);
else
data.playSoundEvent(
MarioSFX.STOMP,
SoundCategory.PLAYERS,
target.getX(),
target.getY(),
target.getZ(),
0.825F,
1,
seed
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -44,9 +44,6 @@ public class GroundPoundStomp implements StompDefinition {
@Override public @NotNull Identifier getDamageType() {
return Identifier.of(MarioQuaMario.MOD_ID, "ground_pound");
}
@Override public @Nullable SoundEvent getSoundEvent() {
return MarioSFX.KICK;
}

@Override public @Nullable Identifier getPostStompAction() {
return null;
Expand All @@ -65,6 +62,6 @@ public class GroundPoundStomp implements StompDefinition {
}

@Override public void executeClients(MarioClientSideData data, boolean isSelf, Entity target, StompableEntity.StompResult result, long seed) {

data.playSoundEvent(MarioSFX.KICK, target, SoundCategory.PLAYERS, seed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
import com.floralquafloral.definitions.actions.StatCategory;
import com.floralquafloral.util.MarioSFX;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MovementType;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -47,9 +48,6 @@ public class JumpStomp implements StompDefinition {
@Override public @NotNull Identifier getDamageType() {
return Identifier.of(MarioQuaMario.MOD_ID, "stomp");
}
@Override public @Nullable SoundEvent getSoundEvent() {
return MarioSFX.STOMP;
}

@Override public @Nullable Identifier getPostStompAction() {
return Identifier.of(MarioQuaMario.MOD_ID, "stomp");
Expand All @@ -70,6 +68,9 @@ public class JumpStomp implements StompDefinition {
}

@Override public void executeClients(MarioClientSideData data, boolean isSelf, Entity target, StompableEntity.StompResult result, long seed) {

if(target instanceof LivingEntity livingTarget && livingTarget.isDead())
data.playSoundEvent(MarioSFX.STOMP_LAST, target, SoundCategory.PLAYERS, seed);
else
data.playSoundEvent(MarioSFX.STOMP, target, SoundCategory.PLAYERS, seed);
}
}
1 change: 1 addition & 0 deletions mod/src/main/resources/assets/qua_mario/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"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.last": "Something gets stomped flat",
"subtitles.qua_mario.stomp.pointy": "Something pointy gets stomped",
"subtitles.qua_mario.stomp.spin": "Something gets stomped",
"subtitles.qua_mario.stomp.heavy": "Something gets stomped",
Expand Down
6 changes: 6 additions & 0 deletions mod/src/main/resources/assets/qua_mario/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
"qua_mario:sfx/stomp/stomp"
]
},
"sfx.stomp.last": {
"subtitle": "subtitles.qua_mario.stomp.last",
"sounds": [
"qua_mario:sfx/stomp/last"
]
},
"sfx.stomp.pointy": {
"subtitle": "subtitles.qua_mario.stomp.pointy",
"sounds": [
Expand Down
Binary file not shown.

0 comments on commit 08f1e69

Please sign in to comment.