diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index cb9ee9f72..4059db0da 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -9,6 +9,7 @@ import java.util.Set; import mekanism.api.EnumColor; import mekanism.api.IClientTicker; +import mekanism.client.sound.FlamethrowerSound; import mekanism.client.sound.GasMaskSound; import mekanism.client.sound.JetpackSound; import mekanism.client.sound.SoundHandler; @@ -19,6 +20,7 @@ import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.item.ItemBlockMachine; import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemElectricBow; +import mekanism.common.item.ItemFlamethrower; import mekanism.common.item.ItemFreeRunners; import mekanism.common.item.ItemGasMask; import mekanism.common.item.ItemJetpack; @@ -404,6 +406,14 @@ public class ClientTickHandler } } } + + for(EntityPlayer player : (List)mc.theWorld.playerEntities) + { + if(hasFlamethrower(player)) + { + new FlamethrowerSound(MekanismClient.audioHandler.getIdentifier(), player); + } + } } if(mc.thePlayer.getEquipmentInSlot(3) != null && mc.thePlayer.getEquipmentInSlot(3).getItem() instanceof ItemJetpack) @@ -533,6 +543,21 @@ public class ClientTickHandler return false; } + + public static boolean hasFlamethrower(EntityPlayer player) + { + if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemJetpack) + { + ItemFlamethrower flamethrower = (ItemFlamethrower)player.getCurrentEquippedItem().getItem(); + + if(flamethrower.getGas(player.getCurrentEquippedItem()) != null) + { + return true; + } + } + + return false; + } public void tickEnd() { diff --git a/src/main/java/mekanism/client/sound/FlamethrowerSound.java b/src/main/java/mekanism/client/sound/FlamethrowerSound.java index 388543374..da287074f 100644 --- a/src/main/java/mekanism/client/sound/FlamethrowerSound.java +++ b/src/main/java/mekanism/client/sound/FlamethrowerSound.java @@ -8,11 +8,13 @@ import net.minecraft.world.World; public class FlamethrowerSound extends PlayerSound { - public byte type = 0; + public boolean inUse = false; public FlamethrowerSound(String id, EntityPlayer entity) { - super(id, "Jetpack.ogg", entity); + super(id, "Flamethrower.ogg", entity); + + inUse = getInUse(entity); } @Override @@ -22,21 +24,13 @@ public class FlamethrowerSound extends PlayerSound { return false; } - else if(!hasFlamethrower(player)) + else if(!ClientTickHandler.hasFlamethrower(player)) { return false; } - else { - if(ClientTickHandler.isJetpackOn(player) != isPlaying) - { - if(ClientTickHandler.isJetpackOn(player)) - { - play(); - } - else { - stopLoop(); - } - } + else if(inUse != getInUse(player)) + { + return false; } if(isPlaying) @@ -46,19 +40,11 @@ public class FlamethrowerSound extends PlayerSound return true; } - - private boolean hasFlamethrower(EntityPlayer player) + + private boolean getInUse(EntityPlayer player) { - if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemJetpack) - { - ItemFlamethrower flamethrower = (ItemFlamethrower)player.getCurrentEquippedItem().getItem(); - - if(flamethrower.getGas(player.getCurrentEquippedItem()) != null) - { - return true; - } - } + ItemFlamethrower flamethrower = (ItemFlamethrower)player.getCurrentEquippedItem().getItem(); - return false; + return flamethrower.getInUse(player.getCurrentEquippedItem()); } } diff --git a/src/main/java/mekanism/common/item/ItemFlamethrower.java b/src/main/java/mekanism/common/item/ItemFlamethrower.java index c21259f35..de72e6635 100644 --- a/src/main/java/mekanism/common/item/ItemFlamethrower.java +++ b/src/main/java/mekanism/common/item/ItemFlamethrower.java @@ -148,6 +148,26 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem itemstack.stackTagCompound.setTag("stored", gasStack.write(new NBTTagCompound())); } } + + public boolean getInUse(ItemStack itemstack) + { + if(itemstack.stackTagCompound == null) + { + return false; + } + + return itemstack.stackTagCompound.getBoolean("inUse"); + } + + public void setInUse(ItemStack itemstack, boolean state) + { + if(itemstack.stackTagCompound == null) + { + itemstack.setTagCompound(new NBTTagCompound()); + } + + itemstack.stackTagCompound.setBoolean("inUse", state); + } public ItemStack getEmptyItem() {