Skip to content

Commit 540e297

Browse files
committed
Added sound effects and victus spell effect
1 parent 6de9a99 commit 540e297

File tree

9 files changed

+158
-0
lines changed

9 files changed

+158
-0
lines changed

src/main/java/dev/overgrown/thaumaturge/Thaumaturge.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import dev.overgrown.aspectslib.AspectsLib;
44
import dev.overgrown.thaumaturge.registry.ModItems;
5+
import dev.overgrown.thaumaturge.registry.ModSounds;
56
import dev.overgrown.thaumaturge.spell.impl.ignis.IgnisEffect;
7+
import dev.overgrown.thaumaturge.spell.impl.victus.VictusEffect;
68
import dev.overgrown.thaumaturge.spell.modifier.ModifierRegistry;
79
import dev.overgrown.thaumaturge.spell.modifier.PowerModifierEffect;
810
import dev.overgrown.thaumaturge.spell.modifier.ScatterModifierEffect;
@@ -26,6 +28,9 @@ public void onInitialize() {
2628
// Items
2729
ModItems.initialize();
2830

31+
// Sounds
32+
ModSounds.initialize();
33+
2934
// Spell components
3035
registerAspectEffects();
3136
registerModifierEffects();
@@ -38,6 +43,7 @@ public void onInitialize() {
3843

3944
private void registerAspectEffects() {
4045
AspectRegistry.register(AspectsLib.identifier("ignis"), new IgnisEffect());
46+
AspectRegistry.register(AspectsLib.identifier("victus"), new VictusEffect());
4147
}
4248

4349
private void registerModifierEffects() {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dev.overgrown.thaumaturge.registry;
2+
3+
import dev.overgrown.thaumaturge.Thaumaturge;
4+
import net.minecraft.registry.Registries;
5+
import net.minecraft.registry.Registry;
6+
import net.minecraft.sound.SoundEvent;
7+
import net.minecraft.util.Identifier;
8+
9+
public class ModSounds {
10+
public static final SoundEvent VICTUS_SPELL_CAST = register("victus_spell_cast");
11+
public static final SoundEvent AER_SPELL_CAST = register("aer_spell_cast");
12+
public static final SoundEvent ALIENIS_SPELL_CAST = register("alienis_spell_cast");
13+
public static final SoundEvent GELUM_SPELL_CAST = register("gelum_spell_cast");
14+
public static final SoundEvent POTENTIA_SPELL_CAST = register("potentia_spell_cast");
15+
16+
private static SoundEvent register(String path) {
17+
Identifier id = Thaumaturge.identifier(path);
18+
return Registry.register(Registries.SOUND_EVENT, id, SoundEvent.of(id));
19+
}
20+
21+
public static void initialize() {
22+
Thaumaturge.LOGGER.info("Registering Thaumaturge sounds");
23+
}
24+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package dev.overgrown.thaumaturge.spell.impl.victus;
2+
3+
import dev.overgrown.thaumaturge.registry.ModSounds;
4+
import dev.overgrown.thaumaturge.spell.modifier.ModifierEffect;
5+
import dev.overgrown.thaumaturge.spell.modifier.PowerModifierEffect;
6+
import dev.overgrown.thaumaturge.spell.pattern.AspectEffect;
7+
import dev.overgrown.thaumaturge.spell.tier.AoeSpellDelivery;
8+
import dev.overgrown.thaumaturge.spell.tier.SelfSpellDelivery;
9+
import dev.overgrown.thaumaturge.spell.tier.TargetedSpellDelivery;
10+
import net.minecraft.entity.LivingEntity;
11+
import net.minecraft.particle.ParticleTypes;
12+
import net.minecraft.server.network.ServerPlayerEntity;
13+
import net.minecraft.server.world.ServerWorld;
14+
import net.minecraft.sound.SoundCategory;
15+
import net.minecraft.util.math.BlockPos;
16+
import net.minecraft.world.World;
17+
18+
import java.util.List;
19+
20+
public class VictusEffect implements AspectEffect {
21+
private static final float BASE_HEALING = 2.0F; // 1 heart
22+
private static final float BASE_DAMAGE = 2.0F; // 1 heart of damage
23+
24+
@Override
25+
public void applySelf(SelfSpellDelivery delivery) {
26+
ServerPlayerEntity caster = delivery.getCaster();
27+
playSound(caster.getWorld(), caster.getX(), caster.getY(), caster.getZ());
28+
applyVictusEffect(caster, getPowerMultiplier(delivery.getModifiers()), caster);
29+
}
30+
31+
@Override
32+
public void applyTargeted(TargetedSpellDelivery delivery) {
33+
if (delivery.isEntityTarget() && delivery.getTargetEntity() instanceof LivingEntity target) {
34+
playSound(delivery.getWorld(), target.getX(), target.getY(), target.getZ());
35+
applyVictusEffect(target, getPowerMultiplier(delivery.getModifiers()), delivery.getCaster());
36+
} else if (delivery.isBlockTarget()) {
37+
BlockPos pos = delivery.getBlockPos();
38+
playSound(delivery.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
39+
}
40+
}
41+
42+
@Override
43+
public void applyAoe(AoeSpellDelivery delivery) {
44+
BlockPos center = delivery.getCenter();
45+
playSound(delivery.getWorld(), center.getX() + 0.5, center.getY() + 0.5, center.getZ() + 0.5);
46+
47+
float multiplier = getPowerMultiplier(delivery.getModifiers());
48+
List<LivingEntity> entities = delivery.getEntitiesInAabb(LivingEntity.class, entity -> true);
49+
50+
for (LivingEntity entity : entities) {
51+
applyVictusEffect(entity, multiplier, delivery.getCaster());
52+
}
53+
}
54+
55+
private void playSound(World world, double x, double y, double z) {
56+
if (world instanceof ServerWorld serverWorld) {
57+
serverWorld.playSound(
58+
null, // No specific player
59+
x, y, z,
60+
ModSounds.VICTUS_SPELL_CAST,
61+
SoundCategory.PLAYERS,
62+
1.0F, 1.0F,
63+
serverWorld.random.nextLong()
64+
);
65+
}
66+
}
67+
68+
private float getPowerMultiplier(List<ModifierEffect> modifiers) {
69+
for (ModifierEffect mod : modifiers) {
70+
if (mod instanceof PowerModifierEffect powerMod) {
71+
return powerMod.getMultiplier();
72+
}
73+
}
74+
return 1.0F;
75+
}
76+
77+
private void applyVictusEffect(LivingEntity target, float powerMultiplier, ServerPlayerEntity caster) {
78+
float amount = target.isUndead() ? BASE_DAMAGE * powerMultiplier : BASE_HEALING * powerMultiplier;
79+
80+
if (target.isUndead()) {
81+
target.damage(target.getWorld().getDamageSources().magic(), amount);
82+
} else {
83+
target.heal(amount);
84+
if (target.isAlive()) {
85+
spawnHealParticles((ServerWorld) target.getWorld(), target);
86+
}
87+
}
88+
}
89+
90+
private void spawnHealParticles(ServerWorld world, LivingEntity entity) {
91+
double x = entity.getX();
92+
double y = entity.getY() + entity.getHeight() * 0.5;
93+
double z = entity.getZ();
94+
world.spawnParticles(ParticleTypes.HEART, x, y, z, 5, 0.5, 0.5, 0.5, 0.0);
95+
}
96+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"aer_spell_cast": {
3+
"subtitle": "subtitles.thaumaturge.aer_spell_cast",
4+
"sounds": [
5+
"thaumaturge:spells/aspects/aer/aer_spell_cast"
6+
]
7+
},
8+
"alienis_spell_cast": {
9+
"subtitle": "subtitles.thaumaturge.alienis_spell_cast",
10+
"sounds": [
11+
"thaumaturge:spells/aspects/alienis/alienis_spell_cast"
12+
]
13+
},
14+
"gelum_spell_cast": {
15+
"subtitle": "subtitles.thaumaturge.gelum_spell_cast",
16+
"sounds": [
17+
"thaumaturge:spells/aspects/gelum/gelum_spell_cast"
18+
]
19+
},
20+
"potentia_spell_cast": {
21+
"subtitle": "subtitles.thaumaturge.potentia_spell_cast",
22+
"sounds": [
23+
"thaumaturge:spells/aspects/potentia/potentia_spell_cast"
24+
]
25+
},
26+
"victus_spell_cast": {
27+
"subtitle": "subtitles.thaumaturge.victus_spell_cast",
28+
"sounds": [
29+
"thaumaturge:spells/aspects/victus/victus_spell_cast"
30+
]
31+
}
32+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)