2013-12-04 22:53:58 +01:00
|
|
|
package mekanism.client.sound;
|
|
|
|
|
2013-12-09 02:35:45 +01:00
|
|
|
import mekanism.client.ClientTickHandler;
|
2013-12-04 22:53:58 +01:00
|
|
|
import mekanism.common.item.ItemJetpack;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2013-12-06 21:26:44 +01:00
|
|
|
public class JetpackSound extends PlayerSound
|
2013-12-04 22:53:58 +01:00
|
|
|
{
|
2013-12-06 21:26:44 +01:00
|
|
|
public JetpackSound(String id, EntityPlayer entity)
|
2013-12-04 23:22:00 +01:00
|
|
|
{
|
2013-12-06 21:26:44 +01:00
|
|
|
super(id, "Jetpack.ogg", entity);
|
2013-12-04 23:22:00 +01:00
|
|
|
}
|
2013-12-04 22:53:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean update(World world)
|
|
|
|
{
|
2013-12-08 05:51:07 +01:00
|
|
|
if(!super.update(world))
|
2013-12-04 22:53:58 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if(!hasJetpack(player))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
2013-12-09 02:35:45 +01:00
|
|
|
if(ClientTickHandler.isJetpackOn(player) != isPlaying)
|
2013-12-04 22:53:58 +01:00
|
|
|
{
|
2013-12-09 02:35:45 +01:00
|
|
|
if(ClientTickHandler.isJetpackOn(player))
|
2013-12-04 22:53:58 +01:00
|
|
|
{
|
|
|
|
play();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stopLoop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-04 23:22:00 +01:00
|
|
|
if(isPlaying)
|
|
|
|
{
|
|
|
|
ticksSincePlay++;
|
|
|
|
}
|
|
|
|
|
2013-12-04 22:53:58 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean hasJetpack(EntityPlayer player)
|
|
|
|
{
|
|
|
|
return player.inventory.armorInventory[2] != null && player.inventory.armorInventory[2].getItem() instanceof ItemJetpack;
|
|
|
|
}
|
|
|
|
}
|