diff --git a/common/mekanism/api/ChanceOutput.java b/common/mekanism/api/ChanceOutput.java index 0a91f3711..21fceded7 100644 --- a/common/mekanism/api/ChanceOutput.java +++ b/common/mekanism/api/ChanceOutput.java @@ -29,7 +29,7 @@ public class ChanceOutput public boolean checkSecondary() { - return rand.nextDouble() >= secondaryChance; + return rand.nextDouble() <= secondaryChance; } public boolean hasPrimary() diff --git a/common/mekanism/client/sound/PlayerSound.java b/common/mekanism/client/sound/PlayerSound.java index f3a93fca6..248437512 100644 --- a/common/mekanism/client/sound/PlayerSound.java +++ b/common/mekanism/client/sound/PlayerSound.java @@ -9,8 +9,6 @@ public abstract class PlayerSound extends Sound /** The TileEntity this sound is associated with. */ public EntityPlayer player; - public int ticksSincePlay = 0; - public PlayerSound(String id, String sound, EntityPlayer entity) { super(id, sound, entity, new Pos3D(entity)); @@ -21,7 +19,7 @@ public abstract class PlayerSound extends Sound @Override public float getMultiplier() { - return Math.min(1, ((float)ticksSincePlay/20F))*0.3F; + return super.getMultiplier()*0.3F; } @Override @@ -48,12 +46,4 @@ public abstract class PlayerSound extends Sound { return new Pos3D(player); } - - @Override - public void play() - { - super.play(); - - ticksSincePlay = 0; - } } diff --git a/common/mekanism/client/sound/Sound.java b/common/mekanism/client/sound/Sound.java index e9eb2afd1..072df4edb 100644 --- a/common/mekanism/client/sound/Sound.java +++ b/common/mekanism/client/sound/Sound.java @@ -18,6 +18,8 @@ public abstract class Sound /** Whether or not this sound is playing */ public boolean isPlaying = false; + public int ticksSincePlay = 0; + private Object objRef; protected Minecraft mc = Minecraft.getMinecraft(); @@ -71,6 +73,8 @@ public abstract class Sound return; } + ticksSincePlay = 0; + if(SoundHandler.getSoundSystem() != null) { updateVolume(); @@ -129,7 +133,10 @@ public abstract class Sound public abstract Pos3D getLocation(); - public abstract float getMultiplier(); + public float getMultiplier() + { + return Math.min(1, ((float)ticksSincePlay/30F)); + } /** * Updates the volume based on how far away the player is from the machine. diff --git a/common/mekanism/client/sound/TileSound.java b/common/mekanism/client/sound/TileSound.java index 56249bef6..e2d7dd076 100644 --- a/common/mekanism/client/sound/TileSound.java +++ b/common/mekanism/client/sound/TileSound.java @@ -38,7 +38,7 @@ public class TileSound extends Sound @Override public float getMultiplier() { - return ((IHasSound)tileEntity).getVolumeMultiplier(); + return super.getMultiplier()*((IHasSound)tileEntity).getVolumeMultiplier(); } @Override @@ -76,6 +76,11 @@ public class TileSound extends Sound } } + if(isPlaying) + { + ticksSincePlay++; + } + return true; } } diff --git a/common/mekanism/common/tile/TileEntityChanceMachine.java b/common/mekanism/common/tile/TileEntityChanceMachine.java index 7972225ba..07b23ce6c 100644 --- a/common/mekanism/common/tile/TileEntityChanceMachine.java +++ b/common/mekanism/common/tile/TileEntityChanceMachine.java @@ -151,30 +151,36 @@ public class TileEntityChanceMachine extends TileEntityBasicMachine if(output.hasPrimary()) { - if(inventory[2] != null && !inventory[2].isItemEqual(output.primaryOutput)) - { - return false; - } - else { - if(inventory[2].stackSize + output.primaryOutput.stackSize > inventory[2].getMaxStackSize()) - { - return false; - } - } + if(inventory[2] != null) + { + if(!inventory[2].isItemEqual(output.primaryOutput)) + { + return false; + } + else { + if(inventory[2].stackSize + output.primaryOutput.stackSize > inventory[2].getMaxStackSize()) + { + return false; + } + } + } } if(output.hasSecondary()) { - if(inventory[4] != null && !inventory[4].isItemEqual(output.secondaryOutput)) - { - return false; - } - else { - if(inventory[4].stackSize + output.secondaryOutput.stackSize > inventory[4].getMaxStackSize()) - { - return false; - } - } + if(inventory[4] != null) + { + if(!inventory[4].isItemEqual(output.secondaryOutput)) + { + return false; + } + else { + if(inventory[4].stackSize + output.secondaryOutput.stackSize > inventory[4].getMaxStackSize()) + { + return false; + } + } + } } return true; diff --git a/common/mekanism/common/tile/TileEntityChemicalInfuser.java b/common/mekanism/common/tile/TileEntityChemicalInfuser.java index 45a6c364f..9a4693960 100644 --- a/common/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/common/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -11,7 +11,11 @@ import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; -import mekanism.common.*; +import mekanism.client.sound.IHasSound; +import mekanism.common.IActiveState; +import mekanism.common.IRedstoneControl; +import mekanism.common.Mekanism; +import mekanism.common.PacketHandler; import mekanism.common.PacketHandler.Transmission; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.network.PacketTileEntity; @@ -27,7 +31,7 @@ import net.minecraftforge.common.ForgeDirection; import com.google.common.io.ByteArrayDataInput; -public class TileEntityChemicalInfuser extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl +public class TileEntityChemicalInfuser extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound { public GasTank leftTank = new GasTank(MAX_GAS); public GasTank rightTank = new GasTank(MAX_GAS); @@ -61,6 +65,8 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement { if(worldObj.isRemote) { + Mekanism.proxy.registerSound(this); + if(updateDelay > 0) { updateDelay--; @@ -456,4 +462,16 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement return InventoryUtils.EMPTY; } + + @Override + public String getSoundPath() + { + return "ChemicalInfuser.ogg"; + } + + @Override + public float getVolumeMultiplier() + { + return 1; + } } diff --git a/common/mekanism/common/tile/TileEntityChemicalOxidizer.java b/common/mekanism/common/tile/TileEntityChemicalOxidizer.java index ae6bbac35..7c78cbdf0 100644 --- a/common/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/common/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -10,6 +10,7 @@ import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; +import mekanism.client.sound.IHasSound; import mekanism.common.IActiveState; import mekanism.common.IRedstoneControl; import mekanism.common.Mekanism; @@ -28,7 +29,7 @@ import net.minecraftforge.common.ForgeDirection; import com.google.common.io.ByteArrayDataInput; -public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl +public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound { public GasTank gasTank = new GasTank(MAX_GAS); @@ -63,6 +64,8 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen { if(worldObj.isRemote) { + Mekanism.proxy.registerSound(this); + if(updateDelay > 0) { updateDelay--; @@ -337,4 +340,16 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen controlType = type; MekanismUtils.saveChunk(this); } + + @Override + public String getSoundPath() + { + return "ChemicalInfuser.ogg"; + } + + @Override + public float getVolumeMultiplier() + { + return 1; + } } diff --git a/resources/assets/mekanism/sound/ChemicalInfuser.ogg b/resources/assets/mekanism/sound/ChemicalInfuser.ogg new file mode 100644 index 000000000..eade1b389 Binary files /dev/null and b/resources/assets/mekanism/sound/ChemicalInfuser.ogg differ diff --git a/resources/assets/mekanism/sound/ChemicalOxidizer.ogg b/resources/assets/mekanism/sound/ChemicalOxidizer.ogg new file mode 100644 index 000000000..488908876 Binary files /dev/null and b/resources/assets/mekanism/sound/ChemicalOxidizer.ogg differ diff --git a/resources/assets/mekanism/sound/PrecisionSawmill.ogg b/resources/assets/mekanism/sound/PrecisionSawmill.ogg new file mode 100644 index 000000000..bfc9e7468 Binary files /dev/null and b/resources/assets/mekanism/sound/PrecisionSawmill.ogg differ diff --git a/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOn.png b/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOn.png index 994930caf..a3b6dff12 100644 Binary files a/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOn.png and b/resources/assets/mekanism/textures/blocks/PrecisionSawmillFrontOn.png differ