Skip to content

Commit

Permalink
Primordial Sounding
Browse files Browse the repository at this point in the history
  • Loading branch information
Azzyypaaras committed Dec 1, 2024
1 parent be4ead9 commit a22c0c5
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 13 deletions.
4 changes: 4 additions & 0 deletions credits/Freesound - primfire0 by qubodup.URL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[InternetShortcut]
https://freesound.org/people/qubodup/sounds/442677/

Used for primordial fire ambient sounds
4 changes: 4 additions & 0 deletions credits/Freesound - primfire1 by qubodup.URL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[InternetShortcut]
https://freesound.org/people/qubodup/sounds/739487/

Used for primordial fire ambient sounds
4 changes: 4 additions & 0 deletions credits/Freesound - primfire2 by GregorQuendel.URL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[InternetShortcut]
https://freesound.org/people/GregorQuendel/sounds/671309/

Used for primordial fire ambient sounds
4 changes: 4 additions & 0 deletions credits/Freesound - primfire3 by GregorQuendel.URL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[InternetShortcut]
https://freesound.org/people/GregorQuendel/sounds/421879/

Used for primordial fire ambient sounds
4 changes: 4 additions & 0 deletions credits/Freesound - primfire4 by GregorQuendel.URL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[InternetShortcut]
https://freesound.org/people/GregorQuendel/sounds/671311/

Used for primordial fire ambient sounds
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private static int getFireTickDelay(Random random) {

public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
if (random.nextInt(24) == 0) {
world.playSound((double) pos.getX() + 0.5, (double) pos.getY() + 0.5, (double) pos.getZ() + 0.5, SpectrumSoundEvents.PRIMORDIAL_FIRE_CRACKLE, SoundCategory.BLOCKS, 0.4F + random.nextFloat(), random.nextFloat() * 0.7F + 0.3F, false);
world.playSound((double) pos.getX() + 0.5, (double) pos.getY() + 0.5, (double) pos.getZ() + 0.5, SpectrumSoundEvents.PRIMORDIAL_FIRE_CRACKLE, SoundCategory.BLOCKS, 0.175F + random.nextFloat(), random.nextFloat() * 0.7F + 0.3F, false);
}

BlockPos blockPos = pos.down();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
import de.dafuqs.spectrum.*;
import de.dafuqs.spectrum.cca.azure_dike.*;
import de.dafuqs.spectrum.registries.*;
import de.dafuqs.spectrum.sound.*;
import dev.onyxstudios.cca.api.v3.component.*;
import dev.onyxstudios.cca.api.v3.component.sync.*;
import dev.onyxstudios.cca.api.v3.component.tick.*;
import net.fabricmc.api.*;
import net.fabricmc.fabric.api.tag.convention.v1.*;
import net.minecraft.client.*;
import net.minecraft.enchantment.*;
import net.minecraft.entity.*;
import net.minecraft.entity.effect.*;
import net.minecraft.entity.player.*;
import net.minecraft.nbt.*;
import net.minecraft.particle.*;
import net.minecraft.registry.tag.*;
Expand All @@ -31,6 +34,9 @@ public class OnPrimordialFireComponent implements AutoSyncedComponent, ServerTic
public static final float FIRE_RESISTANCE_DAMAGE_RESISTANCE = 0.25F;
// Per-level damage reduction added by fire prot. Caps at 50%
public static final float FIRE_PROT_DAMAGE_RESISTANCE = 0.05F;

@Environment(EnvType.CLIENT)
private static Optional<OnPrimordialFireSoundInstance> soundInstance = Optional.empty();

public static final ComponentKey<OnPrimordialFireComponent> ON_PRIMORDIAL_FIRE_COMPONENT = ComponentRegistry.getOrCreate(SpectrumCommon.locate("on_primordial_fire"), OnPrimordialFireComponent.class);

Expand Down Expand Up @@ -175,9 +181,13 @@ public float getDamageBonuses(LivingEntity entity) {
@Environment(EnvType.CLIENT)
public void clientTick() {
if (this.primordialFireTicks > 0) {
if (provider.equals(MinecraftClient.getInstance().player) && primordialFireTicks > 2 && soundInstance.isEmpty()) {
soundInstance = Optional.of(new OnPrimordialFireSoundInstance((PlayerEntity) provider));
MinecraftClient.getInstance().getSoundManager().play(soundInstance.get());
}

double fluidHeight = this.provider.getFluidHeight(FluidTags.WATER);
if (fluidHeight > 0) {

World world = this.provider.getWorld();
Random random = world.random;
Vec3d pos = this.provider.getPos();
Expand All @@ -191,6 +201,9 @@ public void clientTick() {
}
}
}
else if(provider.equals(MinecraftClient.getInstance().player) && soundInstance.isPresent()) {
soundInstance = Optional.empty();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public class SpectrumSoundEvents {

public static final SoundEvent SHOOTING_STAR_CRACKER = register("shooting_star_cracker");
public static final SoundEvent PRIMORDIAL_FIRE_CRACKLE = register("primordial_fire_crackle");
public static final SoundEvent PRIMORDIAL_FIRE_DOT = register("primordial_fire_dot");
public static final SoundEvent TEXT_REVEALED = register("spectrum.ui.text_revealed");
public static final SoundEvent USE_FAIL = register("use_fail");
public static final SoundEvent NEW_REVELATION = register("spectrum.ui.new_revelation");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package de.dafuqs.spectrum.sound;

import de.dafuqs.spectrum.cca.*;
import de.dafuqs.spectrum.registries.*;
import net.minecraft.client.sound.*;
import net.minecraft.entity.player.*;
import net.minecraft.sound.*;
import net.minecraft.util.math.*;

public class OnPrimordialFireSoundInstance extends AbstractSoundInstance implements TickableSoundInstance {

private final PlayerEntity player;
private int fadeInTicks;

public OnPrimordialFireSoundInstance(PlayerEntity player) {
super(SpectrumSoundEvents.PRIMORDIAL_FIRE_DOT, SoundCategory.PLAYERS, player.getRandom());
this.repeat = true;
this.repeatDelay = 0;
this.volume = 0.05F;
this.player = player;
this.relative = true;
}

@Override
public void tick() {
if (player != null) {
this.pitch = (float) (1 + Math.sin(player.age % 240000 / (Math.E * 100)) / 5);
}
this.volume = MathHelper.clampedLerp(0.05F, 0.92F, fadeInTicks / 20F);
fadeInTicks++;
}

@Override
public boolean isDone() {
return player == null || !OnPrimordialFireComponent.isOnPrimordialFire(player);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/assets/spectrum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -5320,7 +5320,8 @@
"spectrum.subtitles.paintbrush_paint": "Paintbrush paints",
"spectrum.subtitles.paintbrush_trigger": "Paintbrush activation",
"spectrum.subtitles.player_teleports": "Player teleports",
"spectrum.subtitles.primordial_fire_crackle": "Primordial Fire crackles",
"spectrum.subtitles.primordial_fire_crackle": "Primordial Fire growls",
"spectrum.subtitles.primordial_fire_dot": "Primordial Fire scorches your soul",
"spectrum.subtitles.primordial_lighter.use": "Primordial Lighter click",
"spectrum.subtitles.puff_circlet": "Puff Circlet pffts",
"spectrum.subtitles.radiance_pin_trigger": "Radiance Pin triggers",
Expand Down
23 changes: 13 additions & 10 deletions src/main/resources/assets/spectrum/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,19 @@
"primordial_fire_crackle": {
"subtitle": "spectrum.subtitles.primordial_fire_crackle",
"sounds": [
"spectrum:cracker1",
"spectrum:cracker2",
"spectrum:cracker3",
"spectrum:cracker4",
"spectrum:cracker5",
"spectrum:cracker6",
"spectrum:cracker7",
"spectrum:cracker8"
]
},
"spectrum:primfire0",
"spectrum:primfire1",
"spectrum:primfire2",
"spectrum:primfire3",
"spectrum:primfire4"
]
},
"primordial_fire_dot": {
"subtitle": "spectrum.subtitles.primordial_fire_dot",
"sounds": [
"spectrum:primfire_dot"
]
},
"radiance_staff_charging": {
"subtitle": "spectrum.subtitles.radiance_staff_charging",
"sounds": [
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit a22c0c5

Please sign in to comment.