diff --git a/gradle.properties b/gradle.properties index 5537308..7ecf135 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,6 @@ loader_version=0.12.12 fabric_version=0.45.2+1.18 satin_version=1.7.2 -mod_version = 4.1.2 +mod_version = 4.2.0 maven_group = net.ludocrypt archives_base_name = limlib \ No newline at end of file diff --git a/src/main/java/net/ludocrypt/limlib/api/LimLibClient.java b/src/main/java/net/ludocrypt/limlib/api/LimLibClient.java index 36c0b1e..62913b3 100644 --- a/src/main/java/net/ludocrypt/limlib/api/LimLibClient.java +++ b/src/main/java/net/ludocrypt/limlib/api/LimLibClient.java @@ -11,11 +11,8 @@ import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.sound.SoundCategory; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.chunk.ChunkStatus; public class LimLibClient implements ClientModInitializer { @@ -34,18 +31,15 @@ public void onInitializeClient() { ClientTickEvents.START_WORLD_TICK.register((world) -> { MinecraftClient client = MinecraftClient.getInstance(); ClientPlayerEntity player = client.player; - Iterable iterable = BlockPos.iterateInSquare(player.getBlockPos(), 8, Direction.DOWN, Direction.NORTH); - for (BlockPos.Mutable mutable : iterable) { - BlockPos pos = mutable.toImmutable(); + Iterable iterable = BlockPos.iterateOutwards(player.getBlockPos(), 8, 8, 8); + for (BlockPos pos : iterable) { if (pos.isWithinDistance(player.getBlockPos(), 16)) { - if (world.getChunk(pos).getStatus().isAtLeast(ChunkStatus.FULL)) { - BlockState state = world.getBlockState(pos); - if (state != null) { - if (state.getBlock()instanceof RandomSoundEmitter rse) { - if (world.getRandom().nextDouble() < rse.getChance(world, state)) { - Vec3d relativePos = rse.getRelativePos(world, state); - world.playSound(pos.getX() + relativePos.getX(), pos.getY() + relativePos.getY(), pos.getZ() + relativePos.getZ(), rse.getSound(world, state), SoundCategory.AMBIENT, rse.getVolume(world, state), rse.getPitch(world, state), true); - } + BlockState state = world.getBlockState(pos); + if (state != null) { + if (state.getBlock()instanceof RandomSoundEmitter rse) { + if (world.getRandom().nextDouble() < rse.getChance(world, state, pos)) { + Vec3d relativePos = rse.getRelativePos(world, state, pos); + world.playSound(pos.getX() + relativePos.getX(), pos.getY() + relativePos.getY(), pos.getZ() + relativePos.getZ(), rse.getSound(world, state, pos), rse.getSoundCategory(world, state, pos), rse.getVolume(world, state, pos), rse.getPitch(world, state, pos), true); } } } diff --git a/src/main/java/net/ludocrypt/limlib/api/sound/RandomSoundEmitter.java b/src/main/java/net/ludocrypt/limlib/api/sound/RandomSoundEmitter.java index 1d59d2c..b1869cb 100644 --- a/src/main/java/net/ludocrypt/limlib/api/sound/RandomSoundEmitter.java +++ b/src/main/java/net/ludocrypt/limlib/api/sound/RandomSoundEmitter.java @@ -1,20 +1,24 @@ package net.ludocrypt.limlib.api.sound; import net.minecraft.block.BlockState; +import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; public interface RandomSoundEmitter { - public SoundEvent getSound(World world, BlockState state); + public SoundEvent getSound(World world, BlockState state, BlockPos pos); - public Vec3d getRelativePos(World world, BlockState state); + public Vec3d getRelativePos(World world, BlockState state, BlockPos pos); - public double getChance(World world, BlockState state); + public double getChance(World world, BlockState state, BlockPos pos); - public float getVolume(World world, BlockState state); + public float getVolume(World world, BlockState state, BlockPos pos); - public float getPitch(World world, BlockState state); + public float getPitch(World world, BlockState state, BlockPos pos); + + public SoundCategory getSoundCategory(World world, BlockState state, BlockPos pos); }