Skip to content

Commit

Permalink
Superior hum
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Nov 16, 2023
1 parent eac7572 commit 6b9c9ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/dev/enjarai/minitardis/ModSounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class ModSounds {
public static SoundEvent TARDIS_TAKEOFF = createSound("tardis_takeoff");
public static SoundEvent TARDIS_LANDING = createSound("tardis_landing");
public static SoundEvent TARDIS_FLY_LOOP = createSound("tardis_fly_loop");
public static SoundEvent CORAL_HUM = createSound("coral_hum");

private static SoundEvent createSound(String path) {
return SoundEvent.of(MiniTardis.id(path));
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/dev/enjarai/minitardis/component/Tardis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import dev.enjarai.minitardis.MiniTardis;
import dev.enjarai.minitardis.ModSounds;
import dev.enjarai.minitardis.block.InteriorDoorBlock;
import dev.enjarai.minitardis.block.ModBlocks;
import dev.enjarai.minitardis.block.TardisExteriorBlock;
Expand All @@ -12,6 +13,7 @@
import net.minecraft.block.FacingBlock;
import net.minecraft.block.enums.DoubleBlockHalf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.packet.s2c.play.PositionFlag;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
Expand Down Expand Up @@ -105,7 +107,9 @@ public void tick() {
}

// Interior hum
state.playForInterior(this, SoundEvents.ENTITY_GUARDIAN_AMBIENT, SoundCategory.AMBIENT, 0.3f, 0f);
if (world.getTime() % (20 * 12) == 0) {
state.playForInterior(this, ModSounds.CORAL_HUM, SoundCategory.AMBIENT, 0.3f, 1);
}
}

public ServerWorld getInteriorWorld() {
Expand Down Expand Up @@ -196,6 +200,11 @@ public void teleportEntityIn(Entity entity) {

var entityPos = Vec3d.ofBottomCenter(targetPos);
entity.teleport(world, entityPos.getX(), entityPos.getY(), entityPos.getZ(), Set.of(), yaw, 0);

// Play a loop of hum to the player the moment they enter to ensure a seamless experience™
if (entity instanceof PlayerEntity player) {
world.playSoundFromEntity(null, player, ModSounds.CORAL_HUM, SoundCategory.AMBIENT, 0.3f, 1);
}
}
}

Expand Down

0 comments on commit 6b9c9ad

Please sign in to comment.