mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-19 11:59:05 +00:00
Framework for Client command handling.
This commit is contained in:
1 parent
ed4ce6f930
commit
ab175caa8f
7 files changed
+116
-2
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package mcp.mobius.opis.network.server;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import mcp.mobius.opis.network.ClientCommand;
|
||||
import mcp.mobius.opis.network.Packets;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
|
||||
public class Packet_ClientCommand {
|
||||
|
||||
public byte header;
|
||||
public byte cmd;
|
||||
|
||||
public Packet_ClientCommand(Packet250CustomPayload packet) {
|
||||
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
|
||||
try{
|
||||
this.header = inputStream.readByte();
|
||||
this.cmd = inputStream.readByte();
|
||||
} catch (IOException e){}
|
||||
|
||||
}
|
||||
|
||||
public static Packet250CustomPayload create(byte cmd){
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
|
||||
try{
|
||||
outputStream.writeByte(Packets.CLIENT_CMD);
|
||||
outputStream.writeByte(cmd);
|
||||
}catch(IOException e){}
|
||||
|
||||
packet.channel = "Opis";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user