diff --git a/src/main/java/twilightforest/TFCommonProxy.java b/src/main/java/twilightforest/TFCommonProxy.java index 087a19624d..49bc597f2e 100644 --- a/src/main/java/twilightforest/TFCommonProxy.java +++ b/src/main/java/twilightforest/TFCommonProxy.java @@ -165,4 +165,6 @@ public boolean checkForSound(ChunkCoordinates chunkcoordinates) { return true; } + public void stopSound(World worldIn, int x, int y, int z) {} + } diff --git a/src/main/java/twilightforest/block/BlockTFCicada.java b/src/main/java/twilightforest/block/BlockTFCicada.java index 1afc073565..e882dd8609 100644 --- a/src/main/java/twilightforest/block/BlockTFCicada.java +++ b/src/main/java/twilightforest/block/BlockTFCicada.java @@ -1,15 +1,13 @@ package twilightforest.block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.ISound; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.Explosion; import net.minecraft.world.World; +import twilightforest.TwilightForestMod; import twilightforest.tileentity.TileEntityTFCicada; public class BlockTFCicada extends BlockTFCritter { @@ -33,13 +31,13 @@ public TileEntity createTileEntity(World world, int metadata) { @Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { super.onEntityCollidedWithBlock(world, x, y, z, entity); - // stopSinging(worldIn, x, y, z); + // TwilightForestMod.proxy.stopSound(worldIn, x, y, z); } @Override public boolean dropCritterIfCantStay(World world, int x, int y, int z) { if (super.dropCritterIfCantStay(world, x, y, z)) { - stopSinging(world, x, y, z); + TwilightForestMod.proxy.stopSound(world, x, y, z); return true; } return false; @@ -49,21 +47,21 @@ public boolean dropCritterIfCantStay(World world, int x, int y, int z) { * Called when the block is attempted to be harvested */ public void onBlockHarvested(World worldIn, int x, int y, int z, int meta, EntityPlayer player) { - stopSinging(worldIn, x, y, z); + TwilightForestMod.proxy.stopSound(worldIn, x, y, z); } /** * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData */ public void onBlockDestroyedByPlayer(World worldIn, int x, int y, int z, int meta) { - stopSinging(worldIn, x, y, z); + TwilightForestMod.proxy.stopSound(worldIn, x, y, z); } /** * Called upon the block being destroyed by an explosion */ public void onBlockDestroyedByExplosion(World worldIn, int x, int y, int z, Explosion explosionIn) { - stopSinging(worldIn, x, y, z); + TwilightForestMod.proxy.stopSound(worldIn, x, y, z); } /** @@ -72,24 +70,10 @@ public void onBlockDestroyedByExplosion(World worldIn, int x, int y, int z, Expl public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) { if (super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ)) { - stopSinging(worldIn, x, y, z); + TwilightForestMod.proxy.stopSound(worldIn, x, y, z); return true; } return false; } - public void stopSinging(World worldIn, int x, int y, int z) { - if (worldIn.isRemote) { - ChunkCoordinates chunkcoordinates = new ChunkCoordinates(x, y, z); - Minecraft mc = Minecraft.getMinecraft(); - ISound isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates); - - while (isound != null) { - mc.getSoundHandler().stopSound(isound); - mc.renderGlobal.mapSoundPositions.remove(chunkcoordinates); - isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates); - } - } - } - } diff --git a/src/main/java/twilightforest/client/TFClientProxy.java b/src/main/java/twilightforest/client/TFClientProxy.java index 2af6ca611d..64cb4bbe7f 100644 --- a/src/main/java/twilightforest/client/TFClientProxy.java +++ b/src/main/java/twilightforest/client/TFClientProxy.java @@ -863,4 +863,16 @@ public boolean checkForSound(ChunkCoordinates chunkcoordinates) { return isound != null; } + public void stopSound(World worldIn, int x, int y, int z) { + ChunkCoordinates chunkcoordinates = new ChunkCoordinates(x, y, z); + Minecraft mc = Minecraft.getMinecraft(); + ISound isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates); + + while (isound != null) { + mc.getSoundHandler().stopSound(isound); + mc.renderGlobal.mapSoundPositions.remove(chunkcoordinates); + isound = (ISound) mc.renderGlobal.mapSoundPositions.get(chunkcoordinates); + } + } + }