Attempt a few jetpack fixes
This commit is contained in:
parent
8b25c1acb3
commit
0d830d6136
5 changed files with 170 additions and 157 deletions
|
@ -131,156 +131,9 @@ public class ClientPlayerTickHandler implements ITickHandler
|
|||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(Mekanism.jetpackOn.contains(entityPlayer) != isJetpackOn(entityPlayer))
|
||||
{
|
||||
if(isJetpackOn(entityPlayer))
|
||||
{
|
||||
Mekanism.jetpackOn.add(entityPlayer);
|
||||
}
|
||||
else {
|
||||
Mekanism.jetpackOn.remove(entityPlayer);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(PacketType.UPDATE, entityPlayer, isJetpackOn(entityPlayer)));
|
||||
}
|
||||
|
||||
if(Mekanism.gasmaskOn.contains(entityPlayer) != isGasMaskOn(entityPlayer))
|
||||
{
|
||||
if(isGasMaskOn(entityPlayer) && mc.currentScreen == null)
|
||||
{
|
||||
Mekanism.gasmaskOn.add(entityPlayer);
|
||||
}
|
||||
else {
|
||||
Mekanism.gasmaskOn.remove(entityPlayer);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketScubaTankData().setParams(PacketType.UPDATE, entityPlayer, isGasMaskOn(entityPlayer)));
|
||||
}
|
||||
|
||||
for(EntityPlayer entry : Mekanism.jetpackOn)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(entry) == null)
|
||||
{
|
||||
new JetpackSound(MekanismClient.audioHandler.getIdentifier(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
for(EntityPlayer entry : Mekanism.gasmaskOn)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(entry) == null)
|
||||
{
|
||||
new GasMaskSound(MekanismClient.audioHandler.getIdentifier(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
if(entityPlayer.getCurrentItemOrArmor(3) != null && entityPlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
||||
{
|
||||
MekanismClient.updateKey(Keyboard.KEY_SPACE);
|
||||
MekanismClient.updateKey(Keyboard.KEY_LSHIFT);
|
||||
}
|
||||
|
||||
if(isJetpackOn(entityPlayer))
|
||||
{
|
||||
ItemJetpack jetpack = (ItemJetpack)entityPlayer.getCurrentItemOrArmor(3).getItem();
|
||||
|
||||
if(jetpack.getMode(entityPlayer.getCurrentItemOrArmor(3)) == JetpackMode.NORMAL)
|
||||
{
|
||||
entityPlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D);
|
||||
entityPlayer.fallDistance = 0.0F;
|
||||
}
|
||||
else if(jetpack.getMode(entityPlayer.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(entityPlayer.motionY > 0)
|
||||
{
|
||||
entityPlayer.motionY = Math.max(entityPlayer.motionY - 0.15D, 0);
|
||||
}
|
||||
else if(entityPlayer.motionY < 0)
|
||||
{
|
||||
entityPlayer.motionY = Math.min(entityPlayer.motionY + 0.15D, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE) && mc.currentScreen == null)
|
||||
{
|
||||
entityPlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.2D);
|
||||
}
|
||||
else if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && mc.currentScreen == null)
|
||||
{
|
||||
entityPlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D);
|
||||
}
|
||||
}
|
||||
|
||||
entityPlayer.fallDistance = 0.0F;
|
||||
}
|
||||
|
||||
jetpack.useGas(entityPlayer.getCurrentItemOrArmor(3));
|
||||
}
|
||||
|
||||
if(isGasMaskOn(entityPlayer))
|
||||
{
|
||||
ItemScubaTank tank = (ItemScubaTank)entityPlayer.getCurrentItemOrArmor(3).getItem();
|
||||
|
||||
tank.useGas(entityPlayer.getCurrentItemOrArmor(3));
|
||||
entityPlayer.setAir(300);
|
||||
entityPlayer.clearActivePotions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isJetpackOn(EntityPlayer player)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
|
|
|
@ -8,13 +8,27 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import mekanism.api.IClientTicker;
|
||||
import mekanism.client.sound.GasMaskSound;
|
||||
import mekanism.client.sound.JetpackSound;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
||||
import mekanism.common.network.PacketJetpackData;
|
||||
import mekanism.common.network.PacketScubaTankData;
|
||||
import mekanism.common.network.PacketJetpackData.PacketType;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
|
@ -34,7 +48,7 @@ public class ClientTickHandler implements ITickHandler
|
|||
|
||||
public boolean preloadedSounds = false;
|
||||
|
||||
public Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
public static Minecraft mc = FMLClientHandler.instance().getClient();
|
||||
|
||||
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";
|
||||
|
@ -160,9 +174,156 @@ public class ClientTickHandler implements ITickHandler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Mekanism.jetpackOn.contains(mc.thePlayer) != isJetpackOn(mc.thePlayer))
|
||||
{
|
||||
if(isJetpackOn(mc.thePlayer))
|
||||
{
|
||||
Mekanism.jetpackOn.add(mc.thePlayer);
|
||||
}
|
||||
else {
|
||||
Mekanism.jetpackOn.remove(mc.thePlayer);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(PacketType.UPDATE, mc.thePlayer, isJetpackOn(mc.thePlayer)));
|
||||
}
|
||||
|
||||
if(Mekanism.gasmaskOn.contains(mc.thePlayer) != isGasMaskOn(mc.thePlayer))
|
||||
{
|
||||
if(isGasMaskOn(mc.thePlayer) && mc.currentScreen == null)
|
||||
{
|
||||
Mekanism.gasmaskOn.add(mc.thePlayer);
|
||||
}
|
||||
else {
|
||||
Mekanism.gasmaskOn.remove(mc.thePlayer);
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketScubaTankData().setParams(PacketType.UPDATE, mc.thePlayer, isGasMaskOn(mc.thePlayer)));
|
||||
}
|
||||
|
||||
for(EntityPlayer entry : Mekanism.jetpackOn)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(entry) == null)
|
||||
{
|
||||
new JetpackSound(MekanismClient.audioHandler.getIdentifier(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
for(EntityPlayer entry : Mekanism.gasmaskOn)
|
||||
{
|
||||
if(MekanismClient.audioHandler.getFrom(entry) == null)
|
||||
{
|
||||
new GasMaskSound(MekanismClient.audioHandler.getIdentifier(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isJetpackOn(EntityPlayer player)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ import mekanism.common.Mekanism;
|
|||
import mekanism.common.item.ItemJetpack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiChat;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.particle.EntityFlameFX;
|
||||
|
@ -18,7 +19,6 @@ import net.minecraft.util.MathHelper;
|
|||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -74,7 +74,7 @@ public class RenderTickHandler implements ITickHandler
|
|||
}
|
||||
}
|
||||
|
||||
if(player != null)
|
||||
if(player != null && !(mc.currentScreen instanceof GuiChat))
|
||||
{
|
||||
if(player.getCurrentItemOrArmor(3) != null && player.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package mekanism.client.sound;
|
||||
|
||||
import mekanism.client.ClientPlayerTickHandler;
|
||||
import mekanism.client.ClientTickHandler;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -24,9 +24,9 @@ public class GasMaskSound extends PlayerSound
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
if(ClientPlayerTickHandler.isGasMaskOn(player) != isPlaying)
|
||||
if(ClientTickHandler.isGasMaskOn(player) != isPlaying)
|
||||
{
|
||||
if(ClientPlayerTickHandler.isGasMaskOn(player))
|
||||
if(ClientTickHandler.isGasMaskOn(player))
|
||||
{
|
||||
play();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package mekanism.client.sound;
|
||||
|
||||
import mekanism.client.ClientPlayerTickHandler;
|
||||
import mekanism.client.ClientTickHandler;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class JetpackSound extends PlayerSound
|
||||
{
|
||||
|
@ -25,9 +24,9 @@ public class JetpackSound extends PlayerSound
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
if(ClientPlayerTickHandler.isJetpackOn(player) != isPlaying)
|
||||
if(ClientTickHandler.isJetpackOn(player) != isPlaying)
|
||||
{
|
||||
if(ClientPlayerTickHandler.isJetpackOn(player))
|
||||
if(ClientTickHandler.isJetpackOn(player))
|
||||
{
|
||||
play();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue