2013-03-31 00:13:59 +01:00
|
|
|
package mekanism.client;
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
2013-11-03 22:54:33 +01:00
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
2013-03-31 00:13:59 +01:00
|
|
|
|
2013-12-01 06:03:40 +01:00
|
|
|
import mekanism.api.EnumColor;
|
2013-12-01 05:19:24 +01:00
|
|
|
import mekanism.api.Object3D;
|
2013-03-31 00:13:59 +01:00
|
|
|
import mekanism.common.PacketHandler;
|
2013-06-07 17:16:47 +02:00
|
|
|
import mekanism.common.PacketHandler.Transmission;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.item.ItemConfigurator;
|
|
|
|
import mekanism.common.item.ItemElectricBow;
|
2013-10-13 18:31:26 +02:00
|
|
|
import mekanism.common.item.ItemWalkieTalkie;
|
2013-06-13 23:37:30 +02:00
|
|
|
import mekanism.common.network.PacketConfiguratorState;
|
|
|
|
import mekanism.common.network.PacketElectricBowState;
|
2013-10-13 18:31:26 +02:00
|
|
|
import mekanism.common.network.PacketWalkieTalkieState;
|
2013-11-03 22:54:33 +01:00
|
|
|
import mekanism.common.tileentity.TileEntityUniversalCable;
|
2013-11-05 03:11:09 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2013-03-31 00:13:59 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2013-11-03 22:54:33 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2013-07-20 18:10:14 +02:00
|
|
|
import net.minecraft.util.ChatMessageComponent;
|
2013-03-31 00:13:59 +01: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;
|
2013-03-31 00:13:59 +01:00
|
|
|
|
2013-04-13 16:33:37 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-03-31 00:13:59 +01:00
|
|
|
public class ClientPlayerTickHandler implements ITickHandler
|
2013-11-03 22:54:33 +01:00
|
|
|
{
|
2013-10-14 19:27:38 +02:00
|
|
|
public boolean lastTickUpdate = false;
|
2013-03-31 00:13:59 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void tickStart(EnumSet<TickType> type, Object... tickData) {}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
|
|
|
{
|
|
|
|
if(tickData[0] instanceof EntityPlayer)
|
|
|
|
{
|
|
|
|
EntityPlayer entityPlayer = (EntityPlayer)tickData[0];
|
|
|
|
|
|
|
|
if(entityPlayer.getCurrentEquippedItem() != null)
|
|
|
|
{
|
|
|
|
ItemStack stack = entityPlayer.getCurrentEquippedItem();
|
|
|
|
|
|
|
|
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemConfigurator)
|
|
|
|
{
|
|
|
|
ItemConfigurator item = (ItemConfigurator)entityPlayer.getCurrentEquippedItem().getItem();
|
|
|
|
|
2013-10-20 06:04:11 +02:00
|
|
|
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchKey.pressed)
|
2013-03-31 00:13:59 +01:00
|
|
|
{
|
2013-10-14 19:27:38 +02:00
|
|
|
if(!lastTickUpdate)
|
2013-03-31 00:13:59 +01:00
|
|
|
{
|
2013-12-01 20:03:00 +01:00
|
|
|
item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0));
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfiguratorState().setParams(item.getState(stack)));
|
2013-12-01 20:03:00 +01:00
|
|
|
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + item.getColor(item.getState(stack)) + item.getStateDisplay(item.getState(stack))));
|
2013-10-14 19:27:38 +02:00
|
|
|
lastTickUpdate = true;
|
2013-03-31 00:13:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-10-14 19:27:38 +02:00
|
|
|
lastTickUpdate = false;
|
2013-03-31 00:13:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemElectricBow)
|
|
|
|
{
|
|
|
|
ItemElectricBow item = (ItemElectricBow)entityPlayer.getCurrentEquippedItem().getItem();
|
|
|
|
|
2013-10-20 06:04:11 +02:00
|
|
|
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchKey.pressed)
|
2013-03-31 00:13:59 +01:00
|
|
|
{
|
2013-10-14 19:27:38 +02:00
|
|
|
if(!lastTickUpdate)
|
2013-03-31 00:13:59 +01:00
|
|
|
{
|
|
|
|
item.setFireState(stack, !item.getFireState(stack));
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketElectricBowState().setParams(item.getFireState(stack)));
|
2013-09-28 03:59:47 +02:00
|
|
|
entityPlayer.sendChatToPlayer(ChatMessageComponent.createFromText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Fire Mode: " + (item.getFireState(stack) ? (EnumColor.DARK_GREEN + "ON") : (EnumColor.DARK_RED + "OFF"))));
|
2013-10-14 19:27:38 +02:00
|
|
|
lastTickUpdate = true;
|
2013-03-31 00:13:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-10-14 19:27:38 +02:00
|
|
|
lastTickUpdate = false;
|
2013-03-31 00:13:59 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-13 18:31:26 +02:00
|
|
|
else if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemWalkieTalkie)
|
|
|
|
{
|
|
|
|
ItemWalkieTalkie item = (ItemWalkieTalkie)entityPlayer.getCurrentEquippedItem().getItem();
|
|
|
|
|
2013-10-20 06:04:11 +02:00
|
|
|
if(entityPlayer.isSneaking() && MekanismKeyHandler.modeSwitchKey.pressed && item.getOn(stack))
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
2013-10-14 19:27:38 +02:00
|
|
|
if(!lastTickUpdate)
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
|
|
|
int newChan = item.getChannel(stack) < 9 ? item.getChannel(stack)+1 : 1;
|
|
|
|
item.setChannel(stack, newChan);
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketWalkieTalkieState().setParams(newChan));
|
2013-11-11 00:54:30 +01:00
|
|
|
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
2013-10-14 19:27:38 +02:00
|
|
|
lastTickUpdate = true;
|
2013-10-13 18:31:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2013-10-14 19:27:38 +02:00
|
|
|
lastTickUpdate = false;
|
2013-10-13 18:31:26 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-14 19:27:38 +02:00
|
|
|
else {
|
|
|
|
lastTickUpdate = false;
|
|
|
|
}
|
2013-03-31 00:13:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumSet<TickType> ticks()
|
|
|
|
{
|
|
|
|
return EnumSet.of(TickType.PLAYER);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getLabel()
|
|
|
|
{
|
|
|
|
return "MekanismClientPlayer";
|
|
|
|
}
|
|
|
|
}
|