2012-11-05 20:29:04 +01:00
|
|
|
package mekanism.client;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
|
|
|
import java.util.EnumSet;
|
2013-07-20 18:10:14 +02:00
|
|
|
import java.util.HashMap;
|
2013-11-29 03:43:53 +01:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
2013-06-21 17:47:01 +02:00
|
|
|
import java.util.List;
|
2013-07-20 18:10:14 +02:00
|
|
|
import java.util.Map;
|
2013-11-29 03:43:53 +01:00
|
|
|
import java.util.Set;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
2013-12-09 17:56:48 +01:00
|
|
|
import mekanism.api.EnumColor;
|
2013-11-29 03:43:53 +01:00
|
|
|
import mekanism.api.IClientTicker;
|
2013-12-09 02:35:45 +01:00
|
|
|
import mekanism.client.sound.GasMaskSound;
|
|
|
|
import mekanism.client.sound.JetpackSound;
|
2012-11-05 20:29:04 +01:00
|
|
|
import mekanism.common.Mekanism;
|
2013-10-14 20:59:48 +02:00
|
|
|
import mekanism.common.ObfuscatedNames;
|
2013-12-09 02:35:45 +01:00
|
|
|
import mekanism.common.PacketHandler;
|
|
|
|
import mekanism.common.PacketHandler.Transmission;
|
2013-12-09 17:56:48 +01:00
|
|
|
import mekanism.common.item.ItemConfigurator;
|
|
|
|
import mekanism.common.item.ItemElectricBow;
|
2013-12-09 02:35:45 +01:00
|
|
|
import mekanism.common.item.ItemGasMask;
|
|
|
|
import mekanism.common.item.ItemJetpack;
|
|
|
|
import mekanism.common.item.ItemJetpack.JetpackMode;
|
2013-12-09 13:19:16 +01:00
|
|
|
import mekanism.common.item.ItemScubaTank;
|
2013-12-15 22:07:30 +01:00
|
|
|
import mekanism.common.item.ItemWalkieTalkie;
|
2013-12-09 17:56:48 +01:00
|
|
|
import mekanism.common.network.PacketConfiguratorState;
|
|
|
|
import mekanism.common.network.PacketElectricBowState;
|
2013-12-09 02:35:45 +01:00
|
|
|
import mekanism.common.network.PacketJetpackData;
|
2013-12-09 23:08:47 +01:00
|
|
|
import mekanism.common.network.PacketJetpackData.JetpackPacket;
|
2013-12-09 13:19:16 +01:00
|
|
|
import mekanism.common.network.PacketScubaTankData;
|
2013-12-15 22:07:30 +01:00
|
|
|
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
|
|
|
|
import mekanism.common.network.PacketWalkieTalkieState;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
2013-12-09 17:56:48 +01:00
|
|
|
import mekanism.common.util.StackUtils;
|
2013-06-21 17:47:01 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2013-07-20 18:10:14 +02:00
|
|
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
2013-06-21 17:47:01 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-09 02:35:45 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2013-12-09 17:56:48 +01:00
|
|
|
import net.minecraft.util.ChatMessageComponent;
|
2013-06-21 17:47:01 +02:00
|
|
|
import net.minecraft.util.StringUtils;
|
2013-12-09 13:19:16 +01:00
|
|
|
|
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
|
2013-02-14 19:26:13 +01:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
2012-08-15 22:41:41 +02:00
|
|
|
import cpw.mods.fml.common.ITickHandler;
|
|
|
|
import cpw.mods.fml.common.TickType;
|
2013-04-13 16:33:37 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2012-08-15 22:41:41 +02:00
|
|
|
|
2012-09-08 18:48:24 +02:00
|
|
|
/**
|
2012-11-05 20:29:04 +01:00
|
|
|
* Client-side tick handler for Mekanism. Used mainly for the update check upon startup.
|
2012-09-08 18:48:24 +02:00
|
|
|
* @author AidanBrady
|
|
|
|
*
|
|
|
|
*/
|
2013-04-13 16:33:37 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2012-08-15 22:41:41 +02:00
|
|
|
public class ClientTickHandler implements ITickHandler
|
|
|
|
{
|
2012-12-21 14:30:40 +01:00
|
|
|
public boolean hasNotified = false;
|
2012-11-27 01:18:50 +01:00
|
|
|
|
2013-10-31 19:26:04 +01:00
|
|
|
public boolean preloadedSounds = false;
|
|
|
|
|
2013-12-09 17:56:48 +01:00
|
|
|
public boolean lastTickUpdate;
|
|
|
|
|
2013-12-09 02:35:45 +01:00
|
|
|
public static Minecraft mc = FMLClientHandler.instance().getClient();
|
2013-06-21 17:47:01 +02:00
|
|
|
|
2013-07-20 18:10:14 +02:00
|
|
|
public static final String MIKE_CAPE = "https://dl.dropboxusercontent.com/s/ji06yflixnszcby/cape.png";
|
|
|
|
public static final String DONATE_CAPE = "https://dl.dropboxusercontent.com/u/90411166/donate.png";
|
|
|
|
public static final String AIDAN_CAPE = "https://dl.dropboxusercontent.com/u/90411166/aidan.png";
|
|
|
|
|
2013-10-14 21:54:10 +02:00
|
|
|
private Map<String, CapeBufferDownload> mikeDownload = new HashMap<String, CapeBufferDownload>();
|
|
|
|
private Map<String, CapeBufferDownload> donateDownload = new HashMap<String, CapeBufferDownload>();
|
|
|
|
private Map<String, CapeBufferDownload> aidanDownload = new HashMap<String, CapeBufferDownload>();
|
2013-06-21 17:47:01 +02:00
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
public static Set<IClientTicker> tickingSet = new HashSet<IClientTicker>();
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
|
|
|
{
|
2013-11-25 22:34:59 +01:00
|
|
|
if(!preloadedSounds && mc.sndManager.sndSystem != null && MekanismClient.enableSounds)
|
2013-10-31 19:26:04 +01:00
|
|
|
{
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
preloadedSounds = true;
|
|
|
|
MekanismClient.audioHandler.preloadSounds();
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}
|
|
|
|
|
2013-11-03 02:07:55 +01:00
|
|
|
MekanismClient.ticksPassed++;
|
|
|
|
|
2013-06-21 17:47:01 +02:00
|
|
|
if(!hasNotified && mc.theWorld != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null)
|
2012-08-15 22:41:41 +02:00
|
|
|
{
|
2013-06-21 17:47:01 +02:00
|
|
|
MekanismUtils.checkForUpdates(mc.thePlayer);
|
2012-12-21 14:30:40 +01:00
|
|
|
hasNotified = true;
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
2013-06-21 17:47:01 +02:00
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
if(!Mekanism.proxy.isPaused())
|
|
|
|
{
|
|
|
|
for(Iterator<IClientTicker> iter = tickingSet.iterator(); iter.hasNext();)
|
|
|
|
{
|
|
|
|
IClientTicker ticker = iter.next();
|
|
|
|
|
2013-12-16 13:23:33 +01:00
|
|
|
if(ticker.needsTicks())
|
2013-11-29 03:43:53 +01:00
|
|
|
{
|
2013-12-16 13:23:33 +01:00
|
|
|
ticker.clientTick();
|
|
|
|
}
|
|
|
|
else {
|
2013-11-29 03:43:53 +01:00
|
|
|
iter.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-21 17:47:01 +02:00
|
|
|
if(mc.theWorld != null)
|
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
for(EntityPlayer entityPlayer : (List<EntityPlayer>)mc.theWorld.playerEntities)
|
2013-06-21 17:47:01 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
if(entityPlayer instanceof AbstractClientPlayer)
|
2013-06-24 18:24:04 +02:00
|
|
|
{
|
2013-07-20 18:10:14 +02:00
|
|
|
AbstractClientPlayer player = (AbstractClientPlayer)entityPlayer;
|
|
|
|
|
|
|
|
if(player != null)
|
|
|
|
{
|
2013-06-24 18:24:04 +02:00
|
|
|
if(StringUtils.stripControlCodes(player.username).equals("mikeacttck"))
|
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
CapeBufferDownload download = mikeDownload.get(player.username);
|
|
|
|
|
|
|
|
if(download == null)
|
2013-07-20 18:10:14 +02:00
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
download = new CapeBufferDownload(player.username, MIKE_CAPE);
|
|
|
|
mikeDownload.put(player.username, download);
|
|
|
|
|
|
|
|
download.start();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(!download.downloaded)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
2013-07-20 18:10:14 +02:00
|
|
|
}
|
2013-06-24 18:24:04 +02:00
|
|
|
}
|
|
|
|
else if(StringUtils.stripControlCodes(player.username).equals("aidancbrady"))
|
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
CapeBufferDownload download = aidanDownload.get(player.username);
|
|
|
|
|
|
|
|
if(download == null)
|
2013-07-20 18:10:14 +02:00
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
download = new CapeBufferDownload(player.username, AIDAN_CAPE);
|
|
|
|
aidanDownload.put(player.username, download);
|
|
|
|
|
|
|
|
download.start();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(!download.downloaded)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
2013-07-20 18:10:14 +02:00
|
|
|
}
|
2013-06-24 18:24:04 +02:00
|
|
|
}
|
2013-12-03 00:54:21 +01:00
|
|
|
else if(Mekanism.donators.contains(StringUtils.stripControlCodes(player.username)))
|
2013-06-24 18:24:04 +02:00
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
CapeBufferDownload download = donateDownload.get(player.username);
|
|
|
|
|
|
|
|
if(download == null)
|
2013-07-20 18:10:14 +02:00
|
|
|
{
|
2013-10-14 21:54:10 +02:00
|
|
|
download = new CapeBufferDownload(player.username, DONATE_CAPE);
|
|
|
|
donateDownload.put(player.username, download);
|
|
|
|
|
|
|
|
download.start();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(!download.downloaded)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
|
|
|
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
2013-07-20 18:10:14 +02:00
|
|
|
}
|
2013-06-24 18:24:04 +02:00
|
|
|
}
|
2013-07-20 18:10:14 +02:00
|
|
|
}
|
2013-06-24 18:24:04 +02:00
|
|
|
}
|
2013-06-21 17:47:01 +02:00
|
|
|
}
|
2013-12-09 02:35:45 +01:00
|
|
|
|
2013-12-09 17:56:48 +01:00
|
|
|
ItemStack stack = mc.thePlayer.getCurrentEquippedItem();
|
|
|
|
|
|
|
|
if(mc.currentScreen == null)
|
|
|
|
{
|
|
|
|
if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemConfigurator)
|
|
|
|
{
|
|
|
|
ItemConfigurator item = (ItemConfigurator)mc.thePlayer.getCurrentEquippedItem().getItem();
|
|
|
|
|
|
|
|
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
|
|
|
{
|
|
|
|
if(!lastTickUpdate)
|
|
|
|
{
|
|
|
|
item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0));
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfiguratorState().setParams(item.getState(stack)));
|
|
|
|
mc.thePlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + item.getColor(item.getState(stack)) + item.getStateDisplay(item.getState(stack))));
|
|
|
|
lastTickUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastTickUpdate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemElectricBow)
|
|
|
|
{
|
|
|
|
ItemElectricBow item = (ItemElectricBow)mc.thePlayer.getCurrentEquippedItem().getItem();
|
|
|
|
|
|
|
|
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
|
|
|
{
|
|
|
|
if(!lastTickUpdate)
|
|
|
|
{
|
|
|
|
item.setFireState(stack, !item.getFireState(stack));
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketElectricBowState().setParams(item.getFireState(stack)));
|
|
|
|
mc.thePlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Fire Mode: " + (item.getFireState(stack) ? (EnumColor.DARK_GREEN + "ON") : (EnumColor.DARK_RED + "OFF"))));
|
|
|
|
lastTickUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastTickUpdate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(mc.thePlayer.isSneaking() && StackUtils.getItem(mc.thePlayer.getCurrentEquippedItem()) instanceof ItemWalkieTalkie)
|
|
|
|
{
|
|
|
|
ItemWalkieTalkie item = (ItemWalkieTalkie)mc.thePlayer.getCurrentEquippedItem().getItem();
|
|
|
|
|
|
|
|
if(MekanismKeyHandler.modeSwitchKey.pressed && item.getOn(stack))
|
|
|
|
{
|
|
|
|
if(!lastTickUpdate)
|
|
|
|
{
|
|
|
|
int newChan = item.getChannel(stack) < 9 ? item.getChannel(stack)+1 : 1;
|
|
|
|
item.setChannel(stack, newChan);
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketWalkieTalkieState().setParams(newChan));
|
|
|
|
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
|
|
|
lastTickUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastTickUpdate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(mc.thePlayer.getCurrentItemOrArmor(3) != null && mc.thePlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
|
|
|
{
|
|
|
|
ItemStack jetpack = mc.thePlayer.getCurrentItemOrArmor(3);
|
|
|
|
|
|
|
|
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
|
|
|
{
|
|
|
|
if(!lastTickUpdate)
|
|
|
|
{
|
|
|
|
((ItemJetpack)jetpack.getItem()).incrementMode(jetpack);
|
2013-12-09 23:08:47 +01:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(JetpackPacket.MODE));
|
2013-12-09 17:56:48 +01:00
|
|
|
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Hydraulic", 1.0F, 1.0F);
|
|
|
|
lastTickUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastTickUpdate = false;
|
|
|
|
}
|
|
|
|
}
|
2013-12-15 22:07:30 +01:00
|
|
|
else if(mc.thePlayer.getCurrentItemOrArmor(3) != null && mc.thePlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemScubaTank)
|
|
|
|
{
|
|
|
|
ItemStack scubaTank = mc.thePlayer.getCurrentItemOrArmor(3);
|
|
|
|
|
|
|
|
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
|
|
|
{
|
|
|
|
if(!lastTickUpdate)
|
|
|
|
{
|
|
|
|
((ItemScubaTank)scubaTank.getItem()).toggleFlowing(scubaTank);
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketScubaTankData().setParams(ScubaTankPacket.MODE));
|
|
|
|
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Hydraulic", 1.0F, 1.0F);
|
|
|
|
lastTickUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastTickUpdate = false;
|
|
|
|
}
|
|
|
|
}
|
2013-12-09 17:56:48 +01:00
|
|
|
else {
|
|
|
|
lastTickUpdate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-09 23:34:53 +01:00
|
|
|
if(Mekanism.jetpackOn.contains(mc.thePlayer.username) != isJetpackOn(mc.thePlayer))
|
2013-12-09 02:35:45 +01:00
|
|
|
{
|
|
|
|
if(isJetpackOn(mc.thePlayer))
|
|
|
|
{
|
2013-12-09 23:34:53 +01:00
|
|
|
Mekanism.jetpackOn.add(mc.thePlayer.username);
|
2013-12-09 02:35:45 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-12-09 23:34:53 +01:00
|
|
|
Mekanism.jetpackOn.remove(mc.thePlayer.username);
|
2013-12-09 02:35:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-09 23:34:53 +01:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(JetpackPacket.UPDATE, mc.thePlayer.username, isJetpackOn(mc.thePlayer)));
|
2013-12-09 02:35:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-09 23:34:53 +01:00
|
|
|
if(Mekanism.gasmaskOn.contains(mc.thePlayer.username) != isGasMaskOn(mc.thePlayer))
|
2013-12-09 02:35:45 +01:00
|
|
|
{
|
|
|
|
if(isGasMaskOn(mc.thePlayer) && mc.currentScreen == null)
|
|
|
|
{
|
2013-12-15 22:07:30 +01:00
|
|
|
System.out.println("on");
|
2013-12-09 23:34:53 +01:00
|
|
|
Mekanism.gasmaskOn.add(mc.thePlayer.username);
|
2013-12-09 02:35:45 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-12-09 23:34:53 +01:00
|
|
|
Mekanism.gasmaskOn.remove(mc.thePlayer.username);
|
2013-12-09 02:35:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-15 22:07:30 +01:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketScubaTankData().setParams(ScubaTankPacket.UPDATE, mc.thePlayer.username, isGasMaskOn(mc.thePlayer)));
|
2013-12-09 02:35:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-09 13:19:16 +01:00
|
|
|
if(MekanismClient.audioHandler != null)
|
2013-12-09 02:35:45 +01:00
|
|
|
{
|
2013-12-09 23:34:53 +01:00
|
|
|
for(String username : Mekanism.jetpackOn)
|
2013-12-09 02:35:45 +01:00
|
|
|
{
|
2013-12-09 23:34:53 +01:00
|
|
|
if(mc.theWorld.getPlayerEntityByName(username) != null)
|
2013-12-09 13:19:16 +01:00
|
|
|
{
|
2013-12-09 23:34:53 +01:00
|
|
|
if(MekanismClient.audioHandler.getFrom(mc.theWorld.getPlayerEntityByName(username)) == null)
|
|
|
|
{
|
|
|
|
new JetpackSound(MekanismClient.audioHandler.getIdentifier(), mc.theWorld.getPlayerEntityByName(username));
|
|
|
|
}
|
2013-12-09 13:19:16 +01:00
|
|
|
}
|
2013-12-09 02:35:45 +01:00
|
|
|
}
|
2013-12-09 13:19:16 +01:00
|
|
|
|
2013-12-09 23:34:53 +01:00
|
|
|
for(String username : Mekanism.gasmaskOn)
|
2013-12-09 02:35:45 +01:00
|
|
|
{
|
2013-12-09 23:34:53 +01:00
|
|
|
if(mc.theWorld.getPlayerEntityByName(username) != null)
|
2013-12-09 13:19:16 +01:00
|
|
|
{
|
2013-12-09 23:34:53 +01:00
|
|
|
if(MekanismClient.audioHandler.getFrom(mc.theWorld.getPlayerEntityByName(username)) == null)
|
|
|
|
{
|
|
|
|
new GasMaskSound(MekanismClient.audioHandler.getIdentifier(), mc.theWorld.getPlayerEntityByName(username));
|
|
|
|
}
|
2013-12-09 13:19:16 +01:00
|
|
|
}
|
2013-12-09 02:35:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mc.thePlayer.getCurrentItemOrArmor(3) != null && mc.thePlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
|
|
|
{
|
|
|
|
MekanismClient.updateKey(Keyboard.KEY_SPACE);
|
|
|
|
MekanismClient.updateKey(Keyboard.KEY_LSHIFT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isJetpackOn(mc.thePlayer))
|
|
|
|
{
|
|
|
|
ItemJetpack jetpack = (ItemJetpack)mc.thePlayer.getCurrentItemOrArmor(3).getItem();
|
|
|
|
|
|
|
|
if(jetpack.getMode(mc.thePlayer.getCurrentItemOrArmor(3)) == JetpackMode.NORMAL)
|
|
|
|
{
|
|
|
|
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D);
|
|
|
|
mc.thePlayer.fallDistance = 0.0F;
|
|
|
|
}
|
|
|
|
else if(jetpack.getMode(mc.thePlayer.getCurrentItemOrArmor(3)) == JetpackMode.HOVER)
|
|
|
|
{
|
|
|
|
if((!Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) || (Keyboard.isKeyDown(Keyboard.KEY_SPACE) && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) || mc.currentScreen != null)
|
|
|
|
{
|
|
|
|
if(mc.thePlayer.motionY > 0)
|
|
|
|
{
|
|
|
|
mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, 0);
|
|
|
|
}
|
|
|
|
else if(mc.thePlayer.motionY < 0)
|
|
|
|
{
|
|
|
|
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE) && mc.currentScreen == null)
|
|
|
|
{
|
|
|
|
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.2D);
|
|
|
|
}
|
|
|
|
else if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && mc.currentScreen == null)
|
|
|
|
{
|
|
|
|
mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mc.thePlayer.fallDistance = 0.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
jetpack.useGas(mc.thePlayer.getCurrentItemOrArmor(3));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isGasMaskOn(mc.thePlayer))
|
|
|
|
{
|
|
|
|
ItemScubaTank tank = (ItemScubaTank)mc.thePlayer.getCurrentItemOrArmor(3).getItem();
|
|
|
|
|
|
|
|
tank.useGas(mc.thePlayer.getCurrentItemOrArmor(3));
|
|
|
|
mc.thePlayer.setAir(300);
|
|
|
|
mc.thePlayer.clearActivePotions();
|
|
|
|
}
|
2013-06-21 17:47:01 +02:00
|
|
|
}
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2013-12-16 05:01:36 +01:00
|
|
|
public static void killDeadNetworks()
|
|
|
|
{
|
|
|
|
for(Iterator<IClientTicker> iter = tickingSet.iterator(); iter.hasNext();)
|
|
|
|
{
|
|
|
|
if(!iter.next().needsTicks())
|
|
|
|
{
|
|
|
|
iter.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-09 02:35:45 +01:00
|
|
|
public static boolean isJetpackOn(EntityPlayer player)
|
|
|
|
{
|
2013-12-09 23:00:08 +01:00
|
|
|
if(player != mc.thePlayer)
|
|
|
|
{
|
2013-12-09 23:34:53 +01:00
|
|
|
return Mekanism.jetpackOn.contains(player.username);
|
2013-12-09 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2013-12-09 02:35:45 +01:00
|
|
|
ItemStack stack = player.inventory.armorInventory[2];
|
|
|
|
|
|
|
|
if(stack != null)
|
|
|
|
{
|
|
|
|
if(stack.getItem() instanceof ItemJetpack)
|
|
|
|
{
|
|
|
|
ItemJetpack jetpack = (ItemJetpack)stack.getItem();
|
|
|
|
|
|
|
|
if(jetpack.getGas(stack) != null)
|
|
|
|
{
|
|
|
|
if((Keyboard.isKeyDown(Keyboard.KEY_SPACE) && jetpack.getMode(stack) == JetpackMode.NORMAL) && mc.currentScreen == null)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(jetpack.getMode(stack) == JetpackMode.HOVER)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isGasMaskOn(EntityPlayer player)
|
|
|
|
{
|
2013-12-09 23:00:08 +01:00
|
|
|
if(player != mc.thePlayer)
|
|
|
|
{
|
2013-12-09 23:34:53 +01:00
|
|
|
return Mekanism.gasmaskOn.contains(player.username);
|
2013-12-09 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2013-12-09 02:35:45 +01:00
|
|
|
ItemStack tank = player.inventory.armorInventory[2];
|
|
|
|
ItemStack mask = player.inventory.armorInventory[3];
|
|
|
|
|
|
|
|
if(tank != null && mask != null)
|
|
|
|
{
|
|
|
|
if(tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask)
|
|
|
|
{
|
|
|
|
ItemScubaTank scubaTank = (ItemScubaTank)tank.getItem();
|
|
|
|
|
|
|
|
if(scubaTank.getGas(tank) != null)
|
|
|
|
{
|
|
|
|
if(scubaTank.getFlowing(tank))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
|
|
|
{
|
2013-10-15 05:36:07 +02:00
|
|
|
if(MekanismClient.audioHandler != null)
|
2012-12-30 22:34:45 +01:00
|
|
|
{
|
2013-10-15 05:36:07 +02:00
|
|
|
synchronized(MekanismClient.audioHandler.sounds)
|
2013-02-14 19:26:13 +01:00
|
|
|
{
|
2013-10-15 05:36:07 +02:00
|
|
|
MekanismClient.audioHandler.onTick();
|
2013-02-14 19:26:13 +01:00
|
|
|
}
|
2012-12-30 22:34:45 +01:00
|
|
|
}
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
2013-02-14 19:26:13 +01:00
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public EnumSet<TickType> ticks()
|
|
|
|
{
|
2012-08-24 02:04:52 +02:00
|
|
|
return EnumSet.of(TickType.CLIENT);
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2012-08-15 22:41:41 +02:00
|
|
|
public String getLabel()
|
|
|
|
{
|
2013-01-21 02:15:59 +01:00
|
|
|
return "MekanismClient";
|
2012-08-15 22:41:41 +02:00
|
|
|
}
|
|
|
|
}
|