A bit of work on flamethrower sound effect handling
This commit is contained in:
parent
cdeb25803c
commit
ee789547c6
3 changed files with 57 additions and 26 deletions
|
@ -9,6 +9,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import mekanism.api.EnumColor;
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.api.IClientTicker;
|
import mekanism.api.IClientTicker;
|
||||||
|
import mekanism.client.sound.FlamethrowerSound;
|
||||||
import mekanism.client.sound.GasMaskSound;
|
import mekanism.client.sound.GasMaskSound;
|
||||||
import mekanism.client.sound.JetpackSound;
|
import mekanism.client.sound.JetpackSound;
|
||||||
import mekanism.client.sound.SoundHandler;
|
import mekanism.client.sound.SoundHandler;
|
||||||
|
@ -19,6 +20,7 @@ import mekanism.common.block.BlockMachine.MachineType;
|
||||||
import mekanism.common.item.ItemBlockMachine;
|
import mekanism.common.item.ItemBlockMachine;
|
||||||
import mekanism.common.item.ItemConfigurator;
|
import mekanism.common.item.ItemConfigurator;
|
||||||
import mekanism.common.item.ItemElectricBow;
|
import mekanism.common.item.ItemElectricBow;
|
||||||
|
import mekanism.common.item.ItemFlamethrower;
|
||||||
import mekanism.common.item.ItemFreeRunners;
|
import mekanism.common.item.ItemFreeRunners;
|
||||||
import mekanism.common.item.ItemGasMask;
|
import mekanism.common.item.ItemGasMask;
|
||||||
import mekanism.common.item.ItemJetpack;
|
import mekanism.common.item.ItemJetpack;
|
||||||
|
@ -404,6 +406,14 @@ public class ClientTickHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(EntityPlayer player : (List<EntityPlayer>)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)
|
if(mc.thePlayer.getEquipmentInSlot(3) != null && mc.thePlayer.getEquipmentInSlot(3).getItem() instanceof ItemJetpack)
|
||||||
|
@ -533,6 +543,21 @@ public class ClientTickHandler
|
||||||
|
|
||||||
return false;
|
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()
|
public void tickEnd()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,11 +8,13 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
public class FlamethrowerSound extends PlayerSound
|
public class FlamethrowerSound extends PlayerSound
|
||||||
{
|
{
|
||||||
public byte type = 0;
|
public boolean inUse = false;
|
||||||
|
|
||||||
public FlamethrowerSound(String id, EntityPlayer entity)
|
public FlamethrowerSound(String id, EntityPlayer entity)
|
||||||
{
|
{
|
||||||
super(id, "Jetpack.ogg", entity);
|
super(id, "Flamethrower.ogg", entity);
|
||||||
|
|
||||||
|
inUse = getInUse(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,21 +24,13 @@ public class FlamethrowerSound extends PlayerSound
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if(!hasFlamethrower(player))
|
else if(!ClientTickHandler.hasFlamethrower(player))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else if(inUse != getInUse(player))
|
||||||
if(ClientTickHandler.isJetpackOn(player) != isPlaying)
|
{
|
||||||
{
|
return false;
|
||||||
if(ClientTickHandler.isJetpackOn(player))
|
|
||||||
{
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stopLoop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPlaying)
|
if(isPlaying)
|
||||||
|
@ -46,19 +40,11 @@ public class FlamethrowerSound extends PlayerSound
|
||||||
|
|
||||||
return true;
|
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();
|
||||||
{
|
|
||||||
ItemFlamethrower flamethrower = (ItemFlamethrower)player.getCurrentEquippedItem().getItem();
|
|
||||||
|
|
||||||
if(flamethrower.getGas(player.getCurrentEquippedItem()) != null)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return flamethrower.getInUse(player.getCurrentEquippedItem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,6 +148,26 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem
|
||||||
itemstack.stackTagCompound.setTag("stored", gasStack.write(new NBTTagCompound()));
|
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()
|
public ItemStack getEmptyItem()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue