equivalent-exchange-3/ee3_common/ee3/common/network/PacketKeyPressed.java

62 lines
1.6 KiB
Java
Raw Normal View History

package ee3.common.network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.LanguageRegistry;
import ee3.common.EquivalentExchange3;
import ee3.common.item.IKeyBound;
import ee3.common.item.ITransmutationStone;
import ee3.common.lib.GuiIds;
import ee3.common.lib.ItemIds;
import ee3.common.lib.Reference;
import net.minecraft.src.EntityPlayer;
2012-10-22 04:39:43 +02:00
import net.minecraft.src.INetworkManager;
import net.minecraft.src.Packet250CustomPayload;
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)
*
*/
public class PacketKeyPressed extends PacketEE {
public String key;
public PacketKeyPressed() {
super(PacketTypeHandler.KEY, false);
}
public PacketKeyPressed(String key) {
super(PacketTypeHandler.KEY, false);
this.key = key;
}
public void writeData(DataOutputStream data) throws IOException {
data.writeUTF(key);
}
public void readData(DataInputStream data) throws IOException {
this.key = data.readUTF();
}
public void setKey(String key) {
this.key = key;
}
2012-10-22 04:39:43 +02:00
public void execute(INetworkManager manager, Player player) {
EntityPlayer thePlayer = (EntityPlayer) player;
if ((thePlayer.getCurrentEquippedItem() != null) && (thePlayer.getCurrentEquippedItem().getItem() instanceof IKeyBound)) {
((IKeyBound) thePlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(thePlayer, thePlayer.getCurrentEquippedItem(), this.key);
}
}
}