mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-18 19:39:10 +00:00
41 lines
1.1 KiB
Java
41 lines
1.1 KiB
Java
package mcp.mobius.opis.network.packets.server;
|
|
|
|
import java.io.DataInputStream;
|
|
import java.lang.reflect.Method;
|
|
import java.util.ArrayList;
|
|
|
|
import net.minecraft.network.packet.Packet250CustomPayload;
|
|
import mcp.mobius.opis.data.holders.ISerializable;
|
|
import mcp.mobius.opis.network.enums.Message;
|
|
|
|
public class NetDataRaw {
|
|
|
|
public byte header;
|
|
public Message msg;
|
|
public String clazzStr;
|
|
public Class clazz;
|
|
public Packet250CustomPayload packet;
|
|
public ArrayList<ISerializable> array = null;
|
|
public ISerializable value = null;
|
|
|
|
protected Class getClass(String datatypeStr){
|
|
try{
|
|
return Class.forName(datatypeStr);
|
|
} catch (Exception e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
protected ISerializable dataRead(String datatypeStr, DataInputStream istream){
|
|
try{
|
|
Class datatype = Class.forName(datatypeStr);
|
|
Method readFromStream = datatype.getMethod("readFromStream", DataInputStream.class);
|
|
|
|
return (ISerializable)readFromStream.invoke(null, istream);
|
|
|
|
} catch (Exception e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|