Sounds work! Also got tick handlers set up, still have to do a few things
This commit is contained in:
parent
815944c49a
commit
f0d3848f8a
8 changed files with 61 additions and 46 deletions
|
@ -46,6 +46,7 @@ import mekanism.client.gui.GuiTeleporter;
|
|||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.RenderGlowPanel;
|
||||
import mekanism.client.render.RenderPartTransmitter;
|
||||
import mekanism.client.render.RenderTickHandler;
|
||||
import mekanism.client.render.block.BasicRenderingHandler;
|
||||
import mekanism.client.render.block.MachineRenderingHandler;
|
||||
import mekanism.client.render.entity.RenderBalloon;
|
||||
|
@ -131,7 +132,6 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
|
@ -478,10 +478,12 @@ public class ClientProxy extends CommonProxy
|
|||
@Override
|
||||
public void loadUtilities()
|
||||
{
|
||||
super.loadUtilities();
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new ClientConnectionHandler());
|
||||
FMLCommonHandler.instance().bus().register(new ClientPlayerTracker());
|
||||
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
|
||||
FMLCommonHandler.instance().bus().register(new RenderTickHandler());
|
||||
|
||||
new MekanismKeyHandler();
|
||||
|
||||
HolidayManager.init();
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ClientTickHandler
|
|||
|
||||
public void tickStart()
|
||||
{
|
||||
if(!preloadedSounds && MekanismClient.enableSounds && MekanismClient.audioHandler != null)
|
||||
if(!preloadedSounds && MekanismClient.enableSounds && MekanismClient.audioHandler != null && MekanismClient.audioHandler.isSystemLoaded())
|
||||
{
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -51,22 +51,6 @@ public abstract class MekKeyHandler
|
|||
return keyBindings;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(ClientTickEvent event)
|
||||
{
|
||||
if(event.side == Side.CLIENT)
|
||||
{
|
||||
if(event.phase == Phase.START)
|
||||
{
|
||||
keyTick(event.type, false);
|
||||
}
|
||||
else if(event.phase == Phase.END)
|
||||
{
|
||||
keyTick(event.type, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void keyTick(Type type, boolean tickEnd)
|
||||
{
|
||||
for(int i = 0; i < keyBindings.length; i++)
|
||||
|
|
|
@ -4,6 +4,10 @@ import net.minecraft.client.settings.KeyBinding;
|
|||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Type;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -18,6 +22,24 @@ public class MekanismKeyHandler extends MekKeyHandler
|
|||
public MekanismKeyHandler()
|
||||
{
|
||||
super(new KeyBinding[] {modeSwitchKey, voiceKey}, new boolean[] {false, false});
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(ClientTickEvent event)
|
||||
{
|
||||
if(event.side == Side.CLIENT)
|
||||
{
|
||||
if(event.phase == Phase.START)
|
||||
{
|
||||
keyTick(event.type, false);
|
||||
}
|
||||
else if(event.phase == Phase.END)
|
||||
{
|
||||
keyTick(event.type, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class Sound
|
|||
identifier = id;
|
||||
objRef = obj;
|
||||
|
||||
URL url = getClass().getClassLoader().getResource("assets/mekanism/sound/" + sound);
|
||||
URL url = getClass().getClassLoader().getResource("assets/mekanism/sounds/" + sound);
|
||||
|
||||
if(url == null)
|
||||
{
|
||||
|
@ -150,8 +150,7 @@ public abstract class Sound
|
|||
try {
|
||||
float multiplier = getMultiplier();
|
||||
float volume = 0;
|
||||
float masterVolume = MekanismClient.audioHandler.masterVolume;
|
||||
|
||||
float masterVolume = MekanismClient.audioHandler.getMasterVolume();
|
||||
double distance = mc.thePlayer.getDistance(getLocation().xPos, getLocation().yPos, getLocation().zPos);
|
||||
volume = (float)Math.min(Math.max(masterVolume-((distance*.08F)*masterVolume), 0)*multiplier, 1);
|
||||
volume *= Math.max(0, Math.min(1, MekanismClient.baseSoundVolume));
|
||||
|
|
|
@ -46,9 +46,6 @@ public class SoundHandler
|
|||
/** All the sound references in the Minecraft game. */
|
||||
public Map<Object, Sound> sounds = Collections.synchronizedMap(new HashMap<Object, Sound>());
|
||||
|
||||
/** The current base volume Minecraft is using. */
|
||||
public float masterVolume = 0;
|
||||
|
||||
public static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
/**
|
||||
|
@ -84,20 +81,6 @@ public class SoundHandler
|
|||
|
||||
Mekanism.logger.info("Preloaded " + listings.size() + " object sounds.");
|
||||
|
||||
/*listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sounds/etc");
|
||||
|
||||
for(String s : listings)
|
||||
{
|
||||
if(s.contains("/mekanism/sounds/etc/"))
|
||||
{
|
||||
s = s.split("/mekanism/sounds/etc/")[1];
|
||||
}
|
||||
|
||||
mc.sndManager.addSound("mekanism:etc/" + s);
|
||||
}
|
||||
|
||||
Mekanism.logger.info("Initialized " + listings.size() + " sound effects.");*/
|
||||
|
||||
if(MekanismClient.holidays)
|
||||
{
|
||||
listings = listFiles(corePath.replace("%20", " ").replace(".jar!", ".jar").replace("file:", ""), "assets/mekanism/sounds/holiday");
|
||||
|
@ -223,8 +206,6 @@ public class SoundHandler
|
|||
sound.updateVolume();
|
||||
}
|
||||
}
|
||||
|
||||
masterVolume = FMLClientHandler.instance().getClient().gameSettings.getSoundLevel(SoundCategory.MASTER);
|
||||
}
|
||||
else {
|
||||
for(Sound sound : sounds.values())
|
||||
|
@ -319,19 +300,41 @@ public class SoundHandler
|
|||
}
|
||||
|
||||
String s = getSoundSystem().quickPlay(false, url, soundPath, false, object.xCoord, object.yCoord, object.zCoord, 0, 16F);
|
||||
getSoundSystem().setVolume(s, masterVolume);
|
||||
getSoundSystem().setVolume(s, getMasterVolume());
|
||||
}
|
||||
|
||||
public float getMasterVolume()
|
||||
{
|
||||
return FMLClientHandler.instance().getClient().gameSettings.getSoundLevel(SoundCategory.MASTER);
|
||||
}
|
||||
|
||||
public static SoundSystem getSoundSystem()
|
||||
{
|
||||
try {
|
||||
SoundManager manager = (SoundManager)MekanismUtils.getPrivateValue(mc.getSoundHandler(), SoundManager.class, ObfuscatedNames.SoundHandler_sndManager);
|
||||
return (SoundSystem)MekanismUtils.getPrivateValue(manager, SoundSystem.class, ObfuscatedNames.SoundManager_sndSystem);
|
||||
return (SoundSystem)MekanismUtils.getPrivateValue(getSoundManager(), SoundManager.class, ObfuscatedNames.SoundManager_sndSystem);
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static SoundManager getSoundManager()
|
||||
{
|
||||
try {
|
||||
return (SoundManager)MekanismUtils.getPrivateValue(mc.getSoundHandler(), net.minecraft.client.audio.SoundHandler.class, ObfuscatedNames.SoundHandler_sndManager);
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSystemLoaded()
|
||||
{
|
||||
try {
|
||||
return (Boolean)MekanismUtils.getPrivateValue(getSoundManager(), net.minecraft.client.audio.SoundManager.class, new String[] {"loaded"});
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void playSound(String sound)
|
||||
{
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(sound), 1.0F));
|
||||
|
|
|
@ -78,6 +78,7 @@ import net.minecraft.inventory.Container;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
||||
|
||||
|
@ -238,7 +239,10 @@ public class CommonProxy
|
|||
/**
|
||||
* Set up and load the utilities this mod uses.
|
||||
*/
|
||||
public void loadUtilities() {}
|
||||
public void loadUtilities()
|
||||
{
|
||||
FMLCommonHandler.instance().bus().register(new CommonWorldTickHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up and load the sound handler.
|
||||
|
|
|
@ -439,6 +439,7 @@ tooltip.PrecisionSawmill=A machine used to process logs and other !nwood-based i
|
|||
tooltip.ChemicalDissolutionChamber=An ultimate machine used to !nchemically dissolve all impurities of an !nore, leaving an unprocessed slurry !nbehind.
|
||||
tooltip.ChemicalWasher=An ultimate machine that cleans unprocessed !nslurry and prepares it for crystallization.
|
||||
tooltip.ChemicalCrystallizer=An ultimate machine used to crystallize !npurified ore slurry into ore crystals.
|
||||
tooltip.SeismicVibrator=A machine that uses seismic vibrations to !nprovide information on differing layers !of the world.
|
||||
|
||||
tooltip.OsmiumOre=A strong mineral that can be found !nat nearly any height in the world. !nIt is known to have many uses in !nthe construction of machinery.
|
||||
tooltip.CopperOre=A common, conductive material that !ncan be used in the production of !nwires. Its ability to withstand !nhigh heats also makes it essential !nto advanced machinery.
|
||||
|
|
Loading…
Reference in a new issue