From 9143d32d59cc9bf85ee6cc1546916b41485c4d0c Mon Sep 17 00:00:00 2001 From: Gordon-Frohman Date: Sun, 2 Jun 2024 00:38:47 +0700 Subject: [PATCH] Remove ALL client-related stuff from TileEntityTFCicada --- src/main/java/twilightforest/TFCommonProxy.java | 4 ++++ .../twilightforest/client/TFClientProxy.java | 16 ++++++++++++++++ .../tileentity/TileEntityTFCicada.java | 14 ++++---------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/java/twilightforest/TFCommonProxy.java b/src/main/java/twilightforest/TFCommonProxy.java index 49bc597f2e..ce3199c8c9 100644 --- a/src/main/java/twilightforest/TFCommonProxy.java +++ b/src/main/java/twilightforest/TFCommonProxy.java @@ -3,6 +3,7 @@ import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; @@ -167,4 +168,7 @@ public boolean checkForSound(ChunkCoordinates chunkcoordinates) { public void stopSound(World worldIn, int x, int y, int z) {} + public void playSound(World worldObj, ChunkCoordinates chunkcoordinates, ResourceLocation soundResource, + float xPosition, float yPosition, float zPosition) {} + } diff --git a/src/main/java/twilightforest/client/TFClientProxy.java b/src/main/java/twilightforest/client/TFClientProxy.java index 64cb4bbe7f..e9f7fb4491 100644 --- a/src/main/java/twilightforest/client/TFClientProxy.java +++ b/src/main/java/twilightforest/client/TFClientProxy.java @@ -2,6 +2,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelPig; import net.minecraft.client.model.ModelSilverfish; @@ -14,6 +15,7 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.MinecraftForge; @@ -875,4 +877,18 @@ public void stopSound(World worldIn, int x, int y, int z) { } } + public void playSound(World worldObj, ChunkCoordinates chunkcoordinates, ResourceLocation soundResource, + float xPosition, float yPosition, float zPosition) { + PositionedSoundRecord positionedsoundrecord = new PositionedSoundRecord( + soundResource, + 1.0f, + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F + 1.0F, + (float) xPosition, + (float) yPosition, + (float) zPosition); + Minecraft mc = Minecraft.getMinecraft(); + mc.renderGlobal.mapSoundPositions.put(chunkcoordinates, positionedsoundrecord); + mc.getSoundHandler().playSound(positionedsoundrecord); + } + } diff --git a/src/main/java/twilightforest/tileentity/TileEntityTFCicada.java b/src/main/java/twilightforest/tileentity/TileEntityTFCicada.java index 28a4ba943a..a75cf0c9cb 100644 --- a/src/main/java/twilightforest/tileentity/TileEntityTFCicada.java +++ b/src/main/java/twilightforest/tileentity/TileEntityTFCicada.java @@ -1,7 +1,5 @@ package twilightforest.tileentity; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ResourceLocation; @@ -98,17 +96,13 @@ public void playSong() { if (!TwilightForestMod.silentCicadas) { ChunkCoordinates chunkcoordinates = new ChunkCoordinates(xCoord, yCoord, zCoord); if (!TwilightForestMod.proxy.checkForSound(chunkcoordinates)) { - ResourceLocation resource = new ResourceLocation(TwilightForestMod.ID + ":mob.cicada"); - PositionedSoundRecord positionedsoundrecord = new PositionedSoundRecord( - resource, - 1.0f, - (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F + 1.0F, + TwilightForestMod.proxy.playSound( + worldObj, + chunkcoordinates, + new ResourceLocation(TwilightForestMod.ID + ":mob.cicada"), (float) xCoord, (float) yCoord, (float) zCoord); - Minecraft mc = Minecraft.getMinecraft(); - mc.renderGlobal.mapSoundPositions.put(chunkcoordinates, positionedsoundrecord); - mc.getSoundHandler().playSound(positionedsoundrecord); } } }