2012-09-21 22:13:21 +02:00
|
|
|
package ee3.common.network;
|
|
|
|
|
|
|
|
import java.io.DataInputStream;
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.network.Player;
|
2012-10-24 04:01:41 +02:00
|
|
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
2012-09-24 21:58:15 +02:00
|
|
|
import ee3.common.EquivalentExchange3;
|
|
|
|
import ee3.common.lib.GuiIds;
|
|
|
|
import ee3.common.lib.ItemIds;
|
|
|
|
import ee3.common.lib.Reference;
|
2012-09-21 22:13:21 +02:00
|
|
|
|
2012-09-24 21:58:15 +02:00
|
|
|
import net.minecraft.src.EntityPlayer;
|
2012-10-22 04:39:43 +02:00
|
|
|
import net.minecraft.src.INetworkManager;
|
2012-09-24 21:58:15 +02:00
|
|
|
import net.minecraft.src.Packet250CustomPayload;
|
2012-09-21 22:13:21 +02:00
|
|
|
|
2012-10-27 23:41:02 +02:00
|
|
|
/**
|
|
|
|
* PacketKeyPressed
|
|
|
|
*
|
|
|
|
* Packet specifically for notifying the server of client key pressed events
|
|
|
|
*
|
|
|
|
* @author pahimar
|
|
|
|
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
|
|
|
*
|
|
|
|
*/
|
2012-09-21 22:13:21 +02:00
|
|
|
public class PacketKeyPressed extends PacketEE {
|
|
|
|
|
2012-09-24 21:58:15 +02:00
|
|
|
public String key;
|
2012-09-21 22:13:21 +02:00
|
|
|
|
|
|
|
public PacketKeyPressed() {
|
|
|
|
super(PacketTypeHandler.KEY, false);
|
|
|
|
}
|
2012-09-24 21:58:15 +02:00
|
|
|
|
|
|
|
public PacketKeyPressed(String key) {
|
|
|
|
super(PacketTypeHandler.KEY, false);
|
|
|
|
this.key = key;
|
|
|
|
}
|
2012-09-21 22:13:21 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeData(DataOutputStream data) throws IOException {
|
2012-09-24 21:58:15 +02:00
|
|
|
data.writeUTF(key);
|
2012-09-21 22:13:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void readData(DataInputStream data) throws IOException {
|
2012-09-24 21:58:15 +02:00
|
|
|
this.key = data.readUTF();
|
2012-09-21 22:13:21 +02:00
|
|
|
}
|
|
|
|
|
2012-09-24 21:58:15 +02:00
|
|
|
public void setKey(String key) {
|
2012-09-21 22:13:21 +02:00
|
|
|
this.key = key;
|
|
|
|
}
|
|
|
|
|
2012-10-22 04:39:43 +02:00
|
|
|
public void execute(INetworkManager manager, Player player) {
|
2012-09-24 21:58:15 +02:00
|
|
|
EntityPlayer thePlayer = (EntityPlayer) player;
|
|
|
|
|
2012-10-24 04:01:41 +02:00
|
|
|
if ((this.key.equals(LanguageRegistry.instance().getStringLocalization(Reference.KEYBINDING_EXTRA))) && (thePlayer.getCurrentEquippedItem().getItem().shiftedIndex == ItemIds.MINIUM_STONE)) {
|
2012-09-24 21:58:15 +02:00
|
|
|
thePlayer.openGui(EquivalentExchange3.instance, GuiIds.PORTABLE_CRAFTING, thePlayer.worldObj, (int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ);
|
|
|
|
}
|
2012-09-21 22:13:21 +02:00
|
|
|
}
|
|
|
|
}
|