A few fixes
This commit is contained in:
parent
4035ba9b36
commit
5661b20b27
6 changed files with 96 additions and 152 deletions
|
@ -1,148 +0,0 @@
|
||||||
package mekanism.client;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
import mekanism.api.EnumColor;
|
|
||||||
import mekanism.client.sound.GasMaskSound;
|
|
||||||
import mekanism.client.sound.JetpackSound;
|
|
||||||
import mekanism.common.Mekanism;
|
|
||||||
import mekanism.common.PacketHandler;
|
|
||||||
import mekanism.common.PacketHandler.Transmission;
|
|
||||||
import mekanism.common.item.ItemConfigurator;
|
|
||||||
import mekanism.common.item.ItemElectricBow;
|
|
||||||
import mekanism.common.item.ItemGasMask;
|
|
||||||
import mekanism.common.item.ItemJetpack;
|
|
||||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
|
||||||
import mekanism.common.item.ItemScubaTank;
|
|
||||||
import mekanism.common.item.ItemWalkieTalkie;
|
|
||||||
import mekanism.common.network.PacketConfiguratorState;
|
|
||||||
import mekanism.common.network.PacketElectricBowState;
|
|
||||||
import mekanism.common.network.PacketJetpackData;
|
|
||||||
import mekanism.common.network.PacketJetpackData.PacketType;
|
|
||||||
import mekanism.common.network.PacketScubaTankData;
|
|
||||||
import mekanism.common.network.PacketWalkieTalkieState;
|
|
||||||
import mekanism.common.util.StackUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.ChatMessageComponent;
|
|
||||||
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.ITickHandler;
|
|
||||||
import cpw.mods.fml.common.TickType;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ClientPlayerTickHandler implements ITickHandler
|
|
||||||
{
|
|
||||||
public boolean lastTickUpdate = false;
|
|
||||||
public static Minecraft mc = Minecraft.getMinecraft();
|
|
||||||
|
|
||||||
@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];
|
|
||||||
|
|
||||||
ItemStack stack = entityPlayer.getCurrentEquippedItem();
|
|
||||||
|
|
||||||
if(mc.currentScreen == null)
|
|
||||||
{
|
|
||||||
if(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemConfigurator)
|
|
||||||
{
|
|
||||||
ItemConfigurator item = (ItemConfigurator)entityPlayer.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)));
|
|
||||||
entityPlayer.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(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemElectricBow)
|
|
||||||
{
|
|
||||||
ItemElectricBow item = (ItemElectricBow)entityPlayer.getCurrentEquippedItem().getItem();
|
|
||||||
|
|
||||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
|
||||||
{
|
|
||||||
if(!lastTickUpdate)
|
|
||||||
{
|
|
||||||
item.setFireState(stack, !item.getFireState(stack));
|
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketElectricBowState().setParams(item.getFireState(stack)));
|
|
||||||
entityPlayer.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(entityPlayer.isSneaking() && StackUtils.getItem(entityPlayer.getCurrentEquippedItem()) instanceof ItemWalkieTalkie)
|
|
||||||
{
|
|
||||||
ItemWalkieTalkie item = (ItemWalkieTalkie)entityPlayer.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(entityPlayer.getCurrentItemOrArmor(3) != null && entityPlayer.getCurrentItemOrArmor(3).getItem() instanceof ItemJetpack)
|
|
||||||
{
|
|
||||||
ItemStack jetpack = entityPlayer.getCurrentItemOrArmor(3);
|
|
||||||
|
|
||||||
if(MekanismKeyHandler.modeSwitchKey.pressed)
|
|
||||||
{
|
|
||||||
if(!lastTickUpdate)
|
|
||||||
{
|
|
||||||
((ItemJetpack)jetpack.getItem()).incrementMode(jetpack);
|
|
||||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(PacketType.MODE));
|
|
||||||
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Hydraulic", 1.0F, 1.0F);
|
|
||||||
lastTickUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lastTickUpdate = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lastTickUpdate = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumSet<TickType> ticks()
|
|
||||||
{
|
|
||||||
return EnumSet.of(TickType.PLAYER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLabel()
|
|
||||||
{
|
|
||||||
return "MekanismClientPlayer";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -383,7 +383,6 @@ public class ClientProxy extends CommonProxy
|
||||||
super.loadUtilities();
|
super.loadUtilities();
|
||||||
|
|
||||||
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
|
TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);
|
||||||
TickRegistry.registerTickHandler(new ClientPlayerTickHandler(), Side.CLIENT);
|
|
||||||
TickRegistry.registerTickHandler(new RenderTickHandler(), Side.CLIENT);
|
TickRegistry.registerTickHandler(new RenderTickHandler(), Side.CLIENT);
|
||||||
|
|
||||||
NetworkRegistry.instance().registerConnectionHandler(new ClientConnectionHandler());
|
NetworkRegistry.instance().registerConnectionHandler(new ClientConnectionHandler());
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import mekanism.api.EnumColor;
|
||||||
import mekanism.api.IClientTicker;
|
import mekanism.api.IClientTicker;
|
||||||
import mekanism.client.sound.GasMaskSound;
|
import mekanism.client.sound.GasMaskSound;
|
||||||
import mekanism.client.sound.JetpackSound;
|
import mekanism.client.sound.JetpackSound;
|
||||||
|
@ -15,18 +16,26 @@ import mekanism.common.Mekanism;
|
||||||
import mekanism.common.ObfuscatedNames;
|
import mekanism.common.ObfuscatedNames;
|
||||||
import mekanism.common.PacketHandler;
|
import mekanism.common.PacketHandler;
|
||||||
import mekanism.common.PacketHandler.Transmission;
|
import mekanism.common.PacketHandler.Transmission;
|
||||||
|
import mekanism.common.item.ItemConfigurator;
|
||||||
|
import mekanism.common.item.ItemElectricBow;
|
||||||
import mekanism.common.item.ItemGasMask;
|
import mekanism.common.item.ItemGasMask;
|
||||||
import mekanism.common.item.ItemJetpack;
|
import mekanism.common.item.ItemJetpack;
|
||||||
|
import mekanism.common.item.ItemWalkieTalkie;
|
||||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
import mekanism.common.item.ItemJetpack.JetpackMode;
|
||||||
import mekanism.common.item.ItemScubaTank;
|
import mekanism.common.item.ItemScubaTank;
|
||||||
|
import mekanism.common.network.PacketConfiguratorState;
|
||||||
|
import mekanism.common.network.PacketElectricBowState;
|
||||||
import mekanism.common.network.PacketJetpackData;
|
import mekanism.common.network.PacketJetpackData;
|
||||||
|
import mekanism.common.network.PacketWalkieTalkieState;
|
||||||
import mekanism.common.network.PacketJetpackData.PacketType;
|
import mekanism.common.network.PacketJetpackData.PacketType;
|
||||||
import mekanism.common.network.PacketScubaTankData;
|
import mekanism.common.network.PacketScubaTankData;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
import mekanism.common.util.StackUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ChatMessageComponent;
|
||||||
import net.minecraft.util.StringUtils;
|
import net.minecraft.util.StringUtils;
|
||||||
|
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
@ -49,6 +58,8 @@ public class ClientTickHandler implements ITickHandler
|
||||||
|
|
||||||
public boolean preloadedSounds = false;
|
public boolean preloadedSounds = false;
|
||||||
|
|
||||||
|
public boolean lastTickUpdate;
|
||||||
|
|
||||||
public static 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 MIKE_CAPE = "https://dl.dropboxusercontent.com/s/ji06yflixnszcby/cape.png";
|
||||||
|
@ -176,6 +187,88 @@ public class ClientTickHandler implements ITickHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketJetpackData().setParams(PacketType.MODE));
|
||||||
|
Minecraft.getMinecraft().sndManager.playSoundFX("mekanism:etc.Hydraulic", 1.0F, 1.0F);
|
||||||
|
lastTickUpdate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastTickUpdate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastTickUpdate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(Mekanism.jetpackOn.contains(mc.thePlayer) != isJetpackOn(mc.thePlayer))
|
if(Mekanism.jetpackOn.contains(mc.thePlayer) != isJetpackOn(mc.thePlayer))
|
||||||
{
|
{
|
||||||
if(isJetpackOn(mc.thePlayer))
|
if(isJetpackOn(mc.thePlayer))
|
||||||
|
|
|
@ -589,6 +589,7 @@ public class Mekanism
|
||||||
Jetpack = (ItemJetpack)new ItemJetpack(configuration.getItem("Jetpack", 11223).getInt()).setUnlocalizedName("Jetpack");
|
Jetpack = (ItemJetpack)new ItemJetpack(configuration.getItem("Jetpack", 11223).getInt()).setUnlocalizedName("Jetpack");
|
||||||
WalkieTalkie = new ItemWalkieTalkie(configuration.getItem("WalkieTalkie", 11224).getInt()).setUnlocalizedName("WalkieTalkie");
|
WalkieTalkie = new ItemWalkieTalkie(configuration.getItem("WalkieTalkie", 11224).getInt()).setUnlocalizedName("WalkieTalkie");
|
||||||
configuration.save();
|
configuration.save();
|
||||||
|
//TODO 1.7, fix item shifts
|
||||||
|
|
||||||
//Registrations
|
//Registrations
|
||||||
GameRegistry.registerItem(ElectricBow, "ElectricBow");
|
GameRegistry.registerItem(ElectricBow, "ElectricBow");
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class VoiceConnection
|
||||||
EntityPlayerMP playerMP = (EntityPlayerMP)obj;
|
EntityPlayerMP playerMP = (EntityPlayerMP)obj;
|
||||||
String playerIP = playerMP.getPlayerIP();
|
String playerIP = playerMP.getPlayerIP();
|
||||||
|
|
||||||
if(playerIP.equals("127.0.0.1") && !Mekanism.voiceManager.foundLocal)
|
if(!server.isDedicatedServer() && playerIP.equals("127.0.0.1") && !Mekanism.voiceManager.foundLocal)
|
||||||
{
|
{
|
||||||
Mekanism.voiceManager.foundLocal = true;
|
Mekanism.voiceManager.foundLocal = true;
|
||||||
username = playerMP.username;
|
username = playerMP.username;
|
||||||
|
|
|
@ -25,11 +25,10 @@ public class VoiceServerManager
|
||||||
System.out.println("[Mekanism] VoiceServer: Starting up server...");
|
System.out.println("[Mekanism] VoiceServer: Starting up server...");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
running = true;
|
||||||
serverSocket = new ServerSocket(Mekanism.VOICE_PORT);
|
serverSocket = new ServerSocket(Mekanism.VOICE_PORT);
|
||||||
(listenThread = new ListenThread()).start();
|
(listenThread = new ListenThread()).start();
|
||||||
} catch(Exception e) {}
|
} catch(Exception e) {}
|
||||||
|
|
||||||
running = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop()
|
public void stop()
|
||||||
|
|
Loading…
Reference in a new issue