2012-12-17 21:21:53 +01:00
|
|
|
package com.pahimar.ee3.network.packet;
|
2012-09-21 22:13:21 +02:00
|
|
|
|
|
|
|
import java.io.DataInputStream;
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2012-12-13 16:01:41 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.network.INetworkManager;
|
|
|
|
|
2012-12-19 19:09:56 +01:00
|
|
|
import com.pahimar.ee3.item.IKeyBound;
|
|
|
|
import com.pahimar.ee3.network.PacketTypeHandler;
|
|
|
|
|
2012-09-21 22:13:21 +02:00
|
|
|
import cpw.mods.fml.common.network.Player;
|
|
|
|
|
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-12-19 19:09:56 +01:00
|
|
|
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 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);
|
|
|
|
}
|
|
|
|
}
|
2012-09-21 22:13:21 +02:00
|
|
|
}
|