diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 9cef0f9fc..a3ea2bd6e 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -197,7 +197,7 @@ public class ClientProxy extends CommonProxy @Override public void registerSound(Object obj) { - if(MekanismClient.enableSounds && Minecraft.getMinecraft().sndManager.sndSystem != null) + if(MekanismClient.enableSounds && MekanismClient.audioHandler != null) { synchronized(MekanismClient.audioHandler.sounds) { @@ -209,7 +209,7 @@ public class ClientProxy extends CommonProxy @Override public void unregisterSound(TileEntity tileEntity) { - if(MekanismClient.enableSounds && Minecraft.getMinecraft().sndManager.sndSystem != null) + if(MekanismClient.enableSounds && MekanismClient.audioHandler != null) { synchronized(MekanismClient.audioHandler.sounds) { @@ -234,7 +234,7 @@ public class ClientProxy extends CommonProxy entityplayer.openContainer.windowId = windowId; } else { - FMLClientHandler.instance().getClient().sndManager.playSoundFX("random.chestopen", 1.0F, 1.0F); + SoundHandler.playSound("random.chestopen"); ItemStack stack = entityplayer.getCurrentEquippedItem(); if(stack != null && stack.getItem() instanceof IElectricChest && MachineType.get(stack) == MachineType.ELECTRIC_CHEST) diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index 17cdead6a..6a39e9513 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -92,7 +92,7 @@ public class ClientTickHandler public void tickStart() { - if(!preloadedSounds && mc.sndManager.sndSystem != null && MekanismClient.enableSounds) + if(!preloadedSounds && MekanismClient.enableSounds && MekanismClient.audioHandler != null) { new Thread(new Runnable() { @Override diff --git a/src/main/java/mekanism/client/sound/SoundHandler.java b/src/main/java/mekanism/client/sound/SoundHandler.java index 4c302bf33..fae2f4631 100644 --- a/src/main/java/mekanism/client/sound/SoundHandler.java +++ b/src/main/java/mekanism/client/sound/SoundHandler.java @@ -17,10 +17,12 @@ import mekanism.api.Coord4D; import mekanism.client.HolidayManager; import mekanism.client.MekanismClient; import mekanism.common.Mekanism; +import mekanism.common.ObfuscatedNames; +import mekanism.common.util.MekanismUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.SoundCategory; -import net.minecraft.client.gui.GuiOptions; +import net.minecraft.client.audio.SoundManager; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; @@ -47,7 +49,7 @@ public class SoundHandler /** The current base volume Minecraft is using. */ public float masterVolume = 0; - public Minecraft mc = Minecraft.getMinecraft(); + public static Minecraft mc = Minecraft.getMinecraft(); /** * SoundHandler -- a class that handles all Sounds used by Mekanism. @@ -82,7 +84,7 @@ public class SoundHandler System.out.println("[Mekanism] Preloaded " + listings.size() + " object sounds."); - listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sounds/etc"); + /*listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sounds/etc"); for(String s : listings) { @@ -94,7 +96,7 @@ public class SoundHandler mc.sndManager.addSound("mekanism:etc/" + s); } - System.out.println("[Mekanism] Initialized " + listings.size() + " sound effects."); + System.out.println("[Mekanism] Initialized " + listings.size() + " sound effects.");*/ if(MekanismClient.holidays) { @@ -322,12 +324,17 @@ public class SoundHandler public static SoundSystem getSoundSystem() { - return Minecraft.getMinecraft().sndManager.sndSystem; + try { + SoundManager manager = (SoundManager)MekanismUtils.getPrivateValue(mc.getSoundHandler(), SoundManager.class, ObfuscatedNames.SoundHandler_sndManager); + return (SoundSystem)MekanismUtils.getPrivateValue(manager, SoundSystem.class, ObfuscatedNames.SoundManager_sndSystem); + } catch(Exception e) { + return null; + } } public static void playSound(String sound) { - Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(sound), 1.0F)); + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(sound), 1.0F)); } @SubscribeEvent diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index a1d12c5eb..f7b0592dd 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -1309,7 +1309,7 @@ public class Mekanism new MultipartMekanism(); //Packet registrations - packetPipeline.initalise(); + packetPipeline.initialize(); //Load proxy proxy.registerRenderInformation(); @@ -1334,7 +1334,7 @@ public class Mekanism OreDictManager.init(); - packetPipeline.postInitialise(); + packetPipeline.postInitialize(); logger.info("Hooking complete."); } diff --git a/src/main/java/mekanism/common/ObfuscatedNames.java b/src/main/java/mekanism/common/ObfuscatedNames.java index 48b19a014..6728d2c0e 100644 --- a/src/main/java/mekanism/common/ObfuscatedNames.java +++ b/src/main/java/mekanism/common/ObfuscatedNames.java @@ -7,11 +7,11 @@ public final class ObfuscatedNames public static String[] AbstractClientPlayer_downloadImageCape = new String[] {"downloadImageCape", "field_110315_c", "c"}; public static String[] AbstractClientPlayer_locationCape = new String[] {"locationCape", "field_110313_e", "e"}; public static String[] AbstractClientPlayer_getDownloadImage = new String[] {"getDownloadImage", "func_110301_a", "a"}; - public static String[] GuiContainer_drawCreativeTabHoveringText = new String[] {"drawCreativeTabHoveringText", "func_74190_a", "a"}; - public static String[] GuiContainer_xSize = new String[] {"xSize", "field_74194_b", "c"}; - public static String[] GuiContainer_ySize = new String[] {"ySize", "field_74195_c", "d"}; - public static String[] GuiScreen_fontRenderer = new String[] {"fontRenderer", "field_73886_k", "o"}; - public static String[] GuiContainer_guiLeft = new String[] {"guiLeft", "field_74198_m"}; - public static String[] GuiContainer_guiTop = new String[] {"guiTop", "field_74197_n"}; + public static String[] GuiContainer_xSize = new String[] {"xSize", "field_146999_f", "c"}; + public static String[] GuiContainer_ySize = new String[] {"ySize", "field_147000_g", "d"}; + public static String[] GuiContainer_guiLeft = new String[] {"guiLeft", "field_147003_i"}; + public static String[] GuiContainer_guiTop = new String[] {"guiTop", "field_147009_r"}; public static String[] NetHandlerPlayServer_floatingTickCount = new String[] {"floatingTickCount", "field_147365_f"}; + public static String[] SoundHandler_sndManager = new String[] {"sndManager", "field_147694_f"}; + public static String[] SoundManager_sndSystem = new String[] {"sndSystem", "field_148620_e"}; } \ No newline at end of file diff --git a/src/main/java/mekanism/common/entity/EntityRobit.java b/src/main/java/mekanism/common/entity/EntityRobit.java index 6fe422cee..2321fdace 100644 --- a/src/main/java/mekanism/common/entity/EntityRobit.java +++ b/src/main/java/mekanism/common/entity/EntityRobit.java @@ -267,7 +267,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine onItemPickup(item, item.getEntityItem().stackSize); item.setDead(); - SoundHandler.playSound("random.pop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + playSound("random.pop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); break; } @@ -286,7 +286,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine item.setDead(); } - SoundHandler.playSound("random.pop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + playSound("random.pop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); break; } diff --git a/src/main/java/mekanism/common/network/PacketPipeline.java b/src/main/java/mekanism/common/network/PacketPipeline.java index 85df2ccb5..64d929d40 100644 --- a/src/main/java/mekanism/common/network/PacketPipeline.java +++ b/src/main/java/mekanism/common/network/PacketPipeline.java @@ -137,7 +137,7 @@ public class PacketPipeline extends MessageToMessageCodec