Cool stuff!
This commit is contained in:
parent
a204df448f
commit
fb350e43f0
8 changed files with 221 additions and 13 deletions
|
@ -47,11 +47,11 @@ public class ClientPlayerTickHandler implements ITickHandler
|
|||
|
||||
ItemStack stack = entityPlayer.getCurrentEquippedItem();
|
||||
|
||||
if(StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemConfigurator)
|
||||
if(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemConfigurator)
|
||||
{
|
||||
ItemConfigurator item = (ItemConfigurator)entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
|
@ -65,11 +65,11 @@ public class ClientPlayerTickHandler implements ITickHandler
|
|||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else if(StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemElectricBow)
|
||||
else if(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemElectricBow)
|
||||
{
|
||||
ItemElectricBow item = (ItemElectricBow)entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
|
@ -83,11 +83,11 @@ public class ClientPlayerTickHandler implements ITickHandler
|
|||
lastTickUpdate = false;
|
||||
}
|
||||
}
|
||||
else if(StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemWalkieTalkie)
|
||||
else if(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemWalkieTalkie)
|
||||
{
|
||||
ItemWalkieTalkie item = (ItemWalkieTalkie)entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchKey.pressed && item.getOn(stack))
|
||||
if(MekanismKeyHandler.modeSwitchKey.pressed && item.getOn(stack))
|
||||
{
|
||||
if(!lastTickUpdate)
|
||||
{
|
||||
|
@ -142,8 +142,14 @@ public class ClientPlayerTickHandler implements ITickHandler
|
|||
Mekanism.proxy.registerSound(entry);
|
||||
}
|
||||
|
||||
if(isJetpackOn(entityPlayer))
|
||||
if(entityPlayer.getCurrentItemOrArmor(3) != null && entityPlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
||||
{
|
||||
MekanismClient.updateKey(entityPlayer, Keyboard.KEY_SPACE);
|
||||
MekanismClient.updateKey(entityPlayer, Keyboard.KEY_LSHIFT);
|
||||
}
|
||||
|
||||
if(isJetpackOn(entityPlayer))
|
||||
{
|
||||
ItemJetpack jetpack = (ItemJetpack)entityPlayer.getCurrentItemOrArmor(3).getItem();
|
||||
|
||||
if(jetpack.getMode(entityPlayer.getCurrentItemOrArmor(3)) == JetpackMode.NORMAL)
|
||||
|
@ -153,9 +159,32 @@ public class ClientPlayerTickHandler implements ITickHandler
|
|||
}
|
||||
else if(jetpack.getMode(entityPlayer.getCurrentItemOrArmor(3)) == JetpackMode.HOVER)
|
||||
{
|
||||
entityPlayer.motionY = 0;
|
||||
if((!Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) || (Keyboard.isKeyDown(Keyboard.KEY_SPACE) && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)))
|
||||
{
|
||||
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))
|
||||
{
|
||||
entityPlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.2D);
|
||||
}
|
||||
else if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
entityPlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D);
|
||||
}
|
||||
}
|
||||
|
||||
entityPlayer.fallDistance = 0.0F;
|
||||
}
|
||||
|
||||
jetpack.useGas(entityPlayer.getCurrentItemOrArmor(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,13 @@ package mekanism.client;
|
|||
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.network.PacketKey;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -16,4 +23,13 @@ public class MekanismClient extends Mekanism
|
|||
public static boolean fancyUniversalCableRender = true;
|
||||
|
||||
public static long ticksPassed = 0;
|
||||
|
||||
public static void updateKey(EntityPlayer player, int key)
|
||||
{
|
||||
if(Keyboard.isKeyDown(key) != keyMap.has(player, key))
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketKey().setParams(key, Keyboard.isKeyDown(key)));
|
||||
keyMap.update(player, key, Keyboard.isKeyDown(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,9 +96,32 @@ public class CommonPlayerTickHandler implements ITickHandler
|
|||
}
|
||||
else if(jetpack.getMode(player.getCurrentItemOrArmor(3)) == JetpackMode.HOVER)
|
||||
{
|
||||
player.motionY = 0;
|
||||
if((!Mekanism.keyMap.has(player, KeySync.SPACE) && !Mekanism.keyMap.has(player, KeySync.LSHIFT)) || (Mekanism.keyMap.has(player, KeySync.SPACE) && Mekanism.keyMap.has(player, KeySync.LSHIFT)))
|
||||
{
|
||||
if(player.motionY > 0)
|
||||
{
|
||||
player.motionY = Math.max(player.motionY - 0.15D, 0);
|
||||
}
|
||||
else if(player.motionY < 0)
|
||||
{
|
||||
player.motionY = Math.min(player.motionY + 0.15D, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(Mekanism.keyMap.has(player, KeySync.SPACE))
|
||||
{
|
||||
player.motionY = Math.min(player.motionY + 0.15D, 0.2D);
|
||||
}
|
||||
else if(Mekanism.keyMap.has(player, KeySync.LSHIFT))
|
||||
{
|
||||
player.motionY = Math.max(player.motionY - 0.15D, -0.2D);
|
||||
}
|
||||
}
|
||||
|
||||
player.fallDistance = 0.0F;
|
||||
}
|
||||
|
||||
jetpack.useGas(player.getCurrentItemOrArmor(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,9 +134,15 @@ public class CommonPlayerTickHandler implements ITickHandler
|
|||
{
|
||||
if(stack.getItem() instanceof ItemJetpack)
|
||||
{
|
||||
if(((ItemJetpack)stack.getItem()).getGas(stack) != null)
|
||||
ItemJetpack jetpack = (ItemJetpack)stack.getItem();
|
||||
|
||||
if(jetpack.getGas(stack) != null)
|
||||
{
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE))
|
||||
if((Mekanism.keyMap.has(player, KeySync.SPACE) && jetpack.getMode(stack) == JetpackMode.NORMAL))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(jetpack.getMode(stack) == JetpackMode.HOVER)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
73
common/mekanism/common/KeySync.java
Normal file
73
common/mekanism/common/KeySync.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package mekanism.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class KeySync
|
||||
{
|
||||
public static int SPACE = 57;
|
||||
public static int LSHIFT = 42;
|
||||
|
||||
public Map<EntityPlayer, KeySet> keys = new HashMap<EntityPlayer, KeySet>();
|
||||
|
||||
public static class KeySet
|
||||
{
|
||||
public Set<Integer> keysActive = new HashSet<Integer>();
|
||||
|
||||
public KeySet(int key)
|
||||
{
|
||||
keysActive.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
public KeySet getPlayerKeys(EntityPlayer player)
|
||||
{
|
||||
return keys.get(player);
|
||||
}
|
||||
|
||||
public void add(EntityPlayer player, int key)
|
||||
{
|
||||
if(!keys.containsKey(player))
|
||||
{
|
||||
keys.put(player, new KeySet(key));
|
||||
return;
|
||||
}
|
||||
|
||||
keys.get(player).keysActive.add(key);
|
||||
}
|
||||
|
||||
public void remove(EntityPlayer player, int key)
|
||||
{
|
||||
if(!keys.containsKey(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
keys.get(player).keysActive.remove(key);
|
||||
}
|
||||
|
||||
public boolean has(EntityPlayer player, int key)
|
||||
{
|
||||
if(!keys.containsKey(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return keys.get(player).keysActive.contains(key);
|
||||
}
|
||||
|
||||
public void update(EntityPlayer player, int key, boolean add)
|
||||
{
|
||||
if(add)
|
||||
{
|
||||
add(player, key);
|
||||
}
|
||||
else {
|
||||
remove(player, key);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -70,6 +70,7 @@ import mekanism.common.network.PacketEditFilter;
|
|||
import mekanism.common.network.PacketElectricBowState;
|
||||
import mekanism.common.network.PacketElectricChest;
|
||||
import mekanism.common.network.PacketJetpackData;
|
||||
import mekanism.common.network.PacketKey;
|
||||
import mekanism.common.network.PacketLogisticalSorterGui;
|
||||
import mekanism.common.network.PacketNewFilter;
|
||||
import mekanism.common.network.PacketPortableTeleport;
|
||||
|
@ -178,6 +179,8 @@ public class Mekanism
|
|||
/** A list of the usernames of players who have donated to Mekanism. */
|
||||
public static List<String> donators = new ArrayList<String>();
|
||||
|
||||
public static KeySync keyMap = new KeySync();
|
||||
|
||||
public static Set<EntityPlayer> jetpackOn = new HashSet<EntityPlayer>();
|
||||
|
||||
public static Set<Object3D> ic2Registered = new HashSet<Object3D>();
|
||||
|
@ -701,7 +704,7 @@ public class Mekanism
|
|||
* and adding machine recipes with other items' corresponding resources.
|
||||
*/
|
||||
public void addIntegratedItems()
|
||||
{
|
||||
{
|
||||
try {
|
||||
CraftingManagers.pulverizerManager.addRecipe(400, new ItemStack(OreBlock, 1, 0), new ItemStack(Dust, 2, 2), false);
|
||||
|
||||
|
@ -1197,6 +1200,7 @@ public class Mekanism
|
|||
PacketHandler.registerPacket(PacketSimpleGui.class);
|
||||
PacketHandler.registerPacket(PacketDigitalMinerGui.class);
|
||||
PacketHandler.registerPacket(PacketJetpackData.class);
|
||||
PacketHandler.registerPacket(PacketKey.class);
|
||||
|
||||
//Donators
|
||||
donators.add("mrgreaper");
|
||||
|
|
|
@ -75,6 +75,11 @@ public class ItemJetpack extends ItemArmor implements IGasItem
|
|||
setMode(stack, getMode(stack).increment());
|
||||
}
|
||||
|
||||
public void useGas(ItemStack stack)
|
||||
{
|
||||
setGas(new GasStack(getGas(stack).getGas(), getGas(stack).amount-1), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxGas(Object... data)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ public class PacketJetpackData implements IMekanismPacket
|
|||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "RedstoneControl";
|
||||
return "JetpackData";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
52
common/mekanism/common/network/PacketKey.java
Normal file
52
common/mekanism/common/network/PacketKey.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package mekanism.common.network;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class PacketKey implements IMekanismPacket
|
||||
{
|
||||
public int key;
|
||||
public boolean add;
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Key";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMekanismPacket setParams(Object... data)
|
||||
{
|
||||
key = (Integer)data[0];
|
||||
add = (Boolean)data[1];
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
|
||||
{
|
||||
key = dataStream.readInt();
|
||||
add = dataStream.readBoolean();
|
||||
|
||||
if(add)
|
||||
{
|
||||
Mekanism.keyMap.add(player, key);
|
||||
}
|
||||
else {
|
||||
Mekanism.keyMap.remove(player, key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream dataStream) throws Exception
|
||||
{
|
||||
dataStream.writeInt(key);
|
||||
dataStream.writeBoolean(add);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue