Skip to content

Commit

Permalink
The turbine makes a continuous sound when the lever is turned off. #177
Browse files Browse the repository at this point in the history
  • Loading branch information
igentuman committed Mar 10, 2025
1 parent a16b0f3 commit 1fe218b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import static igentuman.nc.handler.config.CommonConfig.ENERGY_GENERATION;
import static igentuman.nc.handler.config.TurbineConfig.TURBINE_CONFIG;
import static igentuman.nc.multiblock.turbine.TurbineRegistration.TURBINE_BLOCKS;
import static igentuman.nc.setup.registration.NCSounds.FISSION_REACTOR;
import static igentuman.nc.setup.registration.NCSounds.TURBINE;
import static igentuman.nc.util.ModUtil.isCcLoaded;
import static net.minecraft.core.particles.ParticleTypes.*;
import static net.minecraftforge.fluids.capability.IFluidHandler.FluidAction.EXECUTE;
Expand Down Expand Up @@ -220,17 +220,17 @@ public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable D
}

protected void playRunningSound() {
if(isRemoved() || (currentSound != null && !currentSound.getLocation().equals(FISSION_REACTOR.get().getLocation()))) {
if(isRemoved() || (currentSound != null && !currentSound.getLocation().equals(TURBINE.get().getLocation()))) {
SoundHandler.stopTileSound(getBlockPos());
currentSound = null;
}
if((currentSound == null || !Minecraft.getInstance().getSoundManager().isActive(currentSound))) {
if(currentSound != null && currentSound.getLocation().equals(FISSION_REACTOR.get().getLocation())) {
if(currentSound != null && currentSound.getLocation().equals(TURBINE.get().getLocation())) {
return;
}

playSoundCooldown = 20;
currentSound = SoundHandler.startTileSound(FISSION_REACTOR.get(), SoundSource.BLOCKS, 0.2f, level.getRandom(), getBlockPos());
currentSound = SoundHandler.startTileSound(TURBINE.get(), SoundSource.BLOCKS, 0.2f, level.getRandom(), getBlockPos());
}
}

Expand All @@ -242,6 +242,8 @@ public void tickClient() {
if(rotationSpeed > 0) {
spawnSteamParticles();
playRunningSound();
} else {
stopSound();
}
}
protected int reValidateCounter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private NCSounds() {
public static final RegistryObject<SoundEvent> FUSION_READY = SOUND_EVENTS.register("tile.fusion_ready", () -> SoundEvent.createVariableRangeEvent(rl( "tile.fusion_ready")));
public static final RegistryObject<SoundEvent> FUSION_RUNNING = SOUND_EVENTS.register("tile.fusion_running", () -> SoundEvent.createVariableRangeEvent(rl( "tile.fusion_running")));
public static final RegistryObject<SoundEvent> FUSION_SWITCH = SOUND_EVENTS.register("tile.fusion_switch", () -> SoundEvent.createVariableRangeEvent(rl( "tile.fusion_switch")));
public static final RegistryObject<SoundEvent> TURBINE = SOUND_EVENTS.register("tile.turbine", () -> SoundEvent.createVariableRangeEvent(rl( "tile.turbine")));
public static final RegistryObject<SoundEvent> FISSION_REACTOR = SOUND_EVENTS.register("tile.fission_reactor", () -> SoundEvent.createVariableRangeEvent(rl( "tile.fission_reactor")));
public static final RegistryObject<SoundEvent> RECORD_WANDERER = SOUND_EVENTS.register("music.wanderer", () -> SoundEvent.createVariableRangeEvent(rl( "music.wanderer")));
public static final RegistryObject<SoundEvent> RECORD_END_OF_THE_WORLD = SOUND_EVENTS.register("music.end_of_the_world", () -> SoundEvent.createVariableRangeEvent(rl( "music.end_of_the_world")));
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/assets/nuclearcraft/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
],
"subtitle": "sound_event.nuclearcraft.fusion.ready"
},
"tile.turbine": {
"sounds": [
"nuclearcraft:block/turbine"
],
"subtitle": "sound_event.nuclearcraft.turbine"
},
"tile.fission_reactor": {
"sounds": [
"nuclearcraft:block/fission_reactor"
Expand Down

0 comments on commit 1fe218b

Please sign in to comment.