clean up
This commit is contained in:
parent
21cec747be
commit
f849ee4526
58 changed files with 826 additions and 1003 deletions
|
@ -27,7 +27,6 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.IDN;
|
import java.net.IDN;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -43,6 +42,7 @@ import java.util.concurrent.FutureTask;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Queues;
|
import com.google.common.collect.Queues;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
|
@ -58,15 +58,17 @@ import proxy.network.MessageSerializer2;
|
||||||
import proxy.network.NetHandlerHandshake;
|
import proxy.network.NetHandlerHandshake;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.NetworkManager;
|
import proxy.network.NetworkManager;
|
||||||
import proxy.network.ServerStatusResponse;
|
|
||||||
import proxy.network.ThreadQuickExitException;
|
import proxy.network.ThreadQuickExitException;
|
||||||
import proxy.packet.play.server.S40PacketDisconnect;
|
import proxy.packet.play.server.S40PacketDisconnect;
|
||||||
import proxy.util.ChatColor;
|
import proxy.util.ChatColor;
|
||||||
import proxy.util.ChatComponentText;
|
import proxy.util.ChatComponentText;
|
||||||
import proxy.util.GameProfile;
|
import proxy.util.Profile;
|
||||||
|
import proxy.util.ServerInfo;
|
||||||
import proxy.util.User;
|
import proxy.util.User;
|
||||||
|
import proxy.util.VersionId;
|
||||||
import proxy.util.LazyLoadBase;
|
import proxy.util.LazyLoadBase;
|
||||||
import proxy.util.Log;
|
import proxy.util.Log;
|
||||||
|
import proxy.util.PlayerInfo;
|
||||||
|
|
||||||
public class Proxy {
|
public class Proxy {
|
||||||
public static final LazyLoadBase<NioEventLoopGroup> NIO_EVENT_LOOP = new LazyLoadBase<NioEventLoopGroup>() {
|
public static final LazyLoadBase<NioEventLoopGroup> NIO_EVENT_LOOP = new LazyLoadBase<NioEventLoopGroup>() {
|
||||||
|
@ -83,8 +85,8 @@ public class Proxy {
|
||||||
private volatile boolean isAlive;
|
private volatile boolean isAlive;
|
||||||
private volatile boolean running = true;
|
private volatile boolean running = true;
|
||||||
|
|
||||||
private final List<ChannelFuture> endpoints = Collections.<ChannelFuture>synchronizedList(new ArrayList());
|
private final List<ChannelFuture> endpoints = Collections.<ChannelFuture>synchronizedList(Lists.newArrayList());
|
||||||
private final List<NetworkManager> networkManagers = Collections.<NetworkManager>synchronizedList(new ArrayList());
|
private final List<NetworkManager> networkManagers = Collections.<NetworkManager>synchronizedList(Lists.newArrayList());
|
||||||
private final Queue<FutureTask<?>> futureTaskQueue = Queues.<FutureTask<?>>newArrayDeque();
|
private final Queue<FutureTask<?>> futureTaskQueue = Queues.<FutureTask<?>>newArrayDeque();
|
||||||
private final Map<String, User> users = Maps.newHashMap();
|
private final Map<String, User> users = Maps.newHashMap();
|
||||||
private final Map<String, NetHandlerPlayServer> players = Maps.newHashMap();
|
private final Map<String, NetHandlerPlayServer> players = Maps.newHashMap();
|
||||||
|
@ -100,10 +102,10 @@ public class Proxy {
|
||||||
private int proxyPort = 25566;
|
private int proxyPort = 25566;
|
||||||
private int minPassLength = 8;
|
private int minPassLength = 8;
|
||||||
private int maxAttempts = 5;
|
private int maxAttempts = 5;
|
||||||
private ServerStatusResponse status = getStatus(new File("icon.png"), ChatColor.AQUA + "Server\n" + ChatColor.GREEN + "Test!!", 90, 10, "Test1",
|
private ServerInfo status = getStatus(new File("icon.png"), ChatColor.AQUA + "Server\n" + ChatColor.GREEN + "Test!!", 90, 10, "Test1",
|
||||||
"Test2 ...", "Test #3 !!");
|
"Test2 ...", "Test #3 !!");
|
||||||
|
|
||||||
private static void addFaviconToStatusResponse(ServerStatusResponse info, File file) {
|
private static void addFaviconToStatusResponse(ServerInfo info, File file) {
|
||||||
if(file.isFile()) {
|
if(file.isFile()) {
|
||||||
ByteBuf buf = Unpooled.buffer();
|
ByteBuf buf = Unpooled.buffer();
|
||||||
try {
|
try {
|
||||||
|
@ -112,7 +114,7 @@ public class Proxy {
|
||||||
throw new IllegalArgumentException("Icon must be 64x64 pixels");
|
throw new IllegalArgumentException("Icon must be 64x64 pixels");
|
||||||
ImageIO.write(img, "PNG", new ByteBufOutputStream(buf));
|
ImageIO.write(img, "PNG", new ByteBufOutputStream(buf));
|
||||||
ByteBuf base64 = Base64.encode(buf);
|
ByteBuf base64 = Base64.encode(buf);
|
||||||
info.setFavicon("data:image/png;base64," + base64.toString(Charsets.UTF_8));
|
info.setIcon("data:image/png;base64," + base64.toString(Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
Log.error(e, "Couldn't load server icon");
|
Log.error(e, "Couldn't load server icon");
|
||||||
|
@ -123,17 +125,17 @@ public class Proxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ServerStatusResponse getStatus(File icon, String motd, int max, int current, String... lines) {
|
public static ServerInfo getStatus(File icon, String motd, int max, int current, String... lines) {
|
||||||
ServerStatusResponse info = new ServerStatusResponse();
|
ServerInfo info = new ServerInfo();
|
||||||
info.setServerDescription(new ChatComponentText(motd));
|
info.setMotd(new ChatComponentText(motd));
|
||||||
info.setProtocolVersionInfo(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.8.9", 47));
|
info.setVersion(new VersionId("1.8.9", 47));
|
||||||
addFaviconToStatusResponse(info, icon);
|
addFaviconToStatusResponse(info, icon);
|
||||||
info.setPlayerCountData(new ServerStatusResponse.PlayerCountData(max, current));
|
info.setInfo(new PlayerInfo(max, current));
|
||||||
GameProfile[] profiles = new GameProfile[Math.min(lines.length, 12)];
|
Profile[] profiles = new Profile[Math.min(lines.length, 12)];
|
||||||
for(int z = 0; z < profiles.length; z++) {
|
for(int z = 0; z < profiles.length; z++) {
|
||||||
profiles[z] = new GameProfile(Proxy.getOfflineUUID(lines[z]), lines[z]);
|
profiles[z] = new Profile(Proxy.getOfflineUUID(lines[z]), lines[z]);
|
||||||
}
|
}
|
||||||
info.getPlayerCountData().setPlayers(profiles);
|
info.getInfo().setList(profiles);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +284,7 @@ public class Proxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private <V> ListenableFuture<V> callFromMainThread(Callable<V> callable) {
|
private <V> ListenableFuture<V> callFromMainThread(Callable<V> callable) {
|
||||||
if(!this.isCallingFromMinecraftThread()) {
|
if(!this.isMainThread()) {
|
||||||
ListenableFutureTask<V> task = ListenableFutureTask.<V>create(callable);
|
ListenableFutureTask<V> task = ListenableFutureTask.<V>create(callable);
|
||||||
|
|
||||||
synchronized(this.futureTaskQueue) {
|
synchronized(this.futureTaskQueue) {
|
||||||
|
@ -304,7 +306,7 @@ public class Proxy {
|
||||||
this.<Object>callFromMainThread(Executors.callable(task));
|
this.<Object>callFromMainThread(Executors.callable(task));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCallingFromMinecraftThread() {
|
public boolean isMainThread() {
|
||||||
return Thread.currentThread() == this.serverThread;
|
return Thread.currentThread() == this.serverThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +314,7 @@ public class Proxy {
|
||||||
return this.compression;
|
return this.compression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStatusResponse getStatus() {
|
public ServerInfo getStatus() {
|
||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,16 @@ package proxy.nbt;
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class NBTTagCompound extends NBTBase
|
public class NBTTagCompound extends NBTBase
|
||||||
{
|
{
|
||||||
private Map<String, NBTBase> tagMap = new HashMap();
|
private Map<String, NBTBase> tagMap = Maps.newHashMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the actual data contents of the tag, implemented in NBT extension classes
|
* Write the actual data contents of the tag, implemented in NBT extension classes
|
||||||
|
|
|
@ -3,14 +3,15 @@ package proxy.nbt;
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import proxy.util.Log;
|
import proxy.util.Log;
|
||||||
|
|
||||||
public class NBTTagList extends NBTBase
|
public class NBTTagList extends NBTBase
|
||||||
{
|
{
|
||||||
private List<NBTBase> tagList = new ArrayList();
|
private List<NBTBase> tagList = Lists.newArrayList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type byte for the tags in the list - they must all be of the same type.
|
* The type byte for the tags in the list - they must all be of the same type.
|
||||||
|
@ -60,7 +61,7 @@ public class NBTTagList extends NBTBase
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sizeTracker.read(32L * (long)i);
|
sizeTracker.read(32L * (long)i);
|
||||||
this.tagList = new ArrayList(i);
|
this.tagList = Lists.newArrayListWithCapacity(i);
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j)
|
for (int j = 0; j < i; ++j)
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,7 +113,7 @@ import proxy.util.ChatColor;
|
||||||
import proxy.util.ChatComponent;
|
import proxy.util.ChatComponent;
|
||||||
import proxy.util.ChatComponentText;
|
import proxy.util.ChatComponentText;
|
||||||
import proxy.util.User;
|
import proxy.util.User;
|
||||||
import proxy.util.ItemStack;
|
import proxy.util.Stack;
|
||||||
import proxy.util.Log;
|
import proxy.util.Log;
|
||||||
|
|
||||||
public class NetHandlerPlayServer implements INetHandler {
|
public class NetHandlerPlayServer implements INetHandler {
|
||||||
|
@ -502,7 +502,7 @@ public class NetHandlerPlayServer implements INetHandler {
|
||||||
public void processCreativeInventoryAction(C10PacketCreativeInventoryAction packetIn) {
|
public void processCreativeInventoryAction(C10PacketCreativeInventoryAction packetIn) {
|
||||||
if(!this.connected)
|
if(!this.connected)
|
||||||
return;
|
return;
|
||||||
ItemStack stack = packetIn.getStack();
|
Stack stack = packetIn.getStack();
|
||||||
// TODO: validate item
|
// TODO: validate item
|
||||||
this.sendToServer(packetIn);
|
this.sendToServer(packetIn);
|
||||||
}
|
}
|
||||||
|
@ -522,7 +522,7 @@ public class NetHandlerPlayServer implements INetHandler {
|
||||||
if("MC|BEdit".equals(packetIn.getChannelName())) {
|
if("MC|BEdit".equals(packetIn.getChannelName())) {
|
||||||
PacketBuffer packetbuffer = packetIn.getBufferData();
|
PacketBuffer packetbuffer = packetIn.getBufferData();
|
||||||
try {
|
try {
|
||||||
ItemStack itemstack1 = packetbuffer.readItemStackFromBuffer();
|
Stack itemstack1 = packetbuffer.readStack();
|
||||||
|
|
||||||
if(itemstack1 != null) {
|
if(itemstack1 != null) {
|
||||||
NBTTagList pages = itemstack1.getTag().getTagList("pages", 8);
|
NBTTagList pages = itemstack1.getTag().getTagList("pages", 8);
|
||||||
|
@ -541,7 +541,7 @@ public class NetHandlerPlayServer implements INetHandler {
|
||||||
else if("MC|BSign".equals(packetIn.getChannelName())) {
|
else if("MC|BSign".equals(packetIn.getChannelName())) {
|
||||||
PacketBuffer packetbuffer = packetIn.getBufferData();
|
PacketBuffer packetbuffer = packetIn.getBufferData();
|
||||||
try {
|
try {
|
||||||
ItemStack itemstack = packetbuffer.readItemStackFromBuffer();
|
Stack itemstack = packetbuffer.readStack();
|
||||||
|
|
||||||
if(itemstack != null) {
|
if(itemstack != null) {
|
||||||
String title = itemstack.getTag().getString("title");
|
String title = itemstack.getTag().getString("title");
|
||||||
|
|
|
@ -22,9 +22,9 @@ import java.util.UUID;
|
||||||
|
|
||||||
import proxy.nbt.NBTSizeTracker;
|
import proxy.nbt.NBTSizeTracker;
|
||||||
import proxy.nbt.NBTTagCompound;
|
import proxy.nbt.NBTTagCompound;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
import proxy.util.ChatComponent;
|
import proxy.util.ChatComponent;
|
||||||
import proxy.util.ItemStack;
|
import proxy.util.Stack;
|
||||||
|
|
||||||
public class PacketBuffer extends ByteBuf
|
public class PacketBuffer extends ByteBuf
|
||||||
{
|
{
|
||||||
|
@ -67,14 +67,14 @@ public class PacketBuffer extends ByteBuf
|
||||||
return abyte;
|
return abyte;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPos readBlockPos()
|
public Vec3 readVector()
|
||||||
{
|
{
|
||||||
return BlockPos.fromLong(this.readLong());
|
return new Vec3(this.readLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeBlockPos(BlockPos pos)
|
public void writeVector(Vec3 pos)
|
||||||
{
|
{
|
||||||
this.writeLong(pos.toLong());
|
this.writeLong(pos.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatComponent readChatComponent() throws IOException
|
public ChatComponent readChatComponent() throws IOException
|
||||||
|
@ -244,10 +244,7 @@ public class PacketBuffer extends ByteBuf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void writeStack(Stack stack)
|
||||||
* Writes the ItemStack's ID (short), then size (byte), then damage. (short)
|
|
||||||
*/
|
|
||||||
public void writeItemStackToBuffer(ItemStack stack)
|
|
||||||
{
|
{
|
||||||
if (stack == null)
|
if (stack == null)
|
||||||
{
|
{
|
||||||
|
@ -262,19 +259,16 @@ public class PacketBuffer extends ByteBuf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Stack readStack() throws IOException
|
||||||
* Reads an ItemStack from this buffer
|
|
||||||
*/
|
|
||||||
public ItemStack readItemStackFromBuffer() throws IOException
|
|
||||||
{
|
{
|
||||||
ItemStack stack = null;
|
Stack stack = null;
|
||||||
short id = this.readShort();
|
short id = this.readShort();
|
||||||
|
|
||||||
if (id >= 0)
|
if (id >= 0)
|
||||||
{
|
{
|
||||||
byte size = this.readByte();
|
byte size = this.readByte();
|
||||||
short meta = this.readShort();
|
short meta = this.readShort();
|
||||||
stack = new ItemStack(id, size, meta, this.readNBTTagCompoundFromBuffer());
|
stack = new Stack(id, size, meta, this.readNBTTagCompoundFromBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import proxy.Proxy;
|
||||||
|
|
||||||
public class PacketThreadUtil {
|
public class PacketThreadUtil {
|
||||||
public static <T extends INetHandler> void checkThreadAndEnqueue(final Packet<T> packet, final T handler, Proxy proxy) throws ThreadQuickExitException {
|
public static <T extends INetHandler> void checkThreadAndEnqueue(final Packet<T> packet, final T handler, Proxy proxy) throws ThreadQuickExitException {
|
||||||
if(!proxy.isCallingFromMinecraftThread()) {
|
if(!proxy.isMainThread()) {
|
||||||
proxy.schedule(new Runnable() {
|
proxy.schedule(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
packet.processPacket(handler);
|
packet.processPacket(handler);
|
||||||
|
|
|
@ -1,249 +0,0 @@
|
||||||
package proxy.network;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonDeserializationContext;
|
|
||||||
import com.google.gson.JsonDeserializer;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonSerializationContext;
|
|
||||||
import com.google.gson.JsonSerializer;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import proxy.util.ChatComponent;
|
|
||||||
import proxy.util.GameProfile;
|
|
||||||
import proxy.util.JsonUtils;
|
|
||||||
|
|
||||||
public class ServerStatusResponse
|
|
||||||
{
|
|
||||||
private ChatComponent serverMotd;
|
|
||||||
private ServerStatusResponse.PlayerCountData playerCount;
|
|
||||||
private ServerStatusResponse.MinecraftProtocolVersionIdentifier protocolVersion;
|
|
||||||
private String favicon;
|
|
||||||
|
|
||||||
public ChatComponent getServerDescription()
|
|
||||||
{
|
|
||||||
return this.serverMotd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServerDescription(ChatComponent motd)
|
|
||||||
{
|
|
||||||
this.serverMotd = motd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerStatusResponse.PlayerCountData getPlayerCountData()
|
|
||||||
{
|
|
||||||
return this.playerCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerCountData(ServerStatusResponse.PlayerCountData countData)
|
|
||||||
{
|
|
||||||
this.playerCount = countData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerStatusResponse.MinecraftProtocolVersionIdentifier getProtocolVersionInfo()
|
|
||||||
{
|
|
||||||
return this.protocolVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProtocolVersionInfo(ServerStatusResponse.MinecraftProtocolVersionIdentifier protocolVersionData)
|
|
||||||
{
|
|
||||||
this.protocolVersion = protocolVersionData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFavicon(String faviconBlob)
|
|
||||||
{
|
|
||||||
this.favicon = faviconBlob;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFavicon()
|
|
||||||
{
|
|
||||||
return this.favicon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MinecraftProtocolVersionIdentifier
|
|
||||||
{
|
|
||||||
private final String name;
|
|
||||||
private final int protocol;
|
|
||||||
|
|
||||||
public MinecraftProtocolVersionIdentifier(String nameIn, int protocolIn)
|
|
||||||
{
|
|
||||||
this.name = nameIn;
|
|
||||||
this.protocol = protocolIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getProtocol()
|
|
||||||
{
|
|
||||||
return this.protocol;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Serializer implements JsonDeserializer<ServerStatusResponse.MinecraftProtocolVersionIdentifier>, JsonSerializer<ServerStatusResponse.MinecraftProtocolVersionIdentifier>
|
|
||||||
{
|
|
||||||
public ServerStatusResponse.MinecraftProtocolVersionIdentifier deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
|
||||||
{
|
|
||||||
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "version");
|
|
||||||
return new ServerStatusResponse.MinecraftProtocolVersionIdentifier(JsonUtils.getString(jsonobject, "name"), JsonUtils.getInt(jsonobject, "protocol"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement serialize(ServerStatusResponse.MinecraftProtocolVersionIdentifier p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
|
|
||||||
{
|
|
||||||
JsonObject jsonobject = new JsonObject();
|
|
||||||
jsonobject.addProperty("name", p_serialize_1_.getName());
|
|
||||||
jsonobject.addProperty("protocol", (Number)Integer.valueOf(p_serialize_1_.getProtocol()));
|
|
||||||
return jsonobject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PlayerCountData
|
|
||||||
{
|
|
||||||
private final int maxPlayers;
|
|
||||||
private final int onlinePlayerCount;
|
|
||||||
private GameProfile[] players;
|
|
||||||
|
|
||||||
public PlayerCountData(int maxOnlinePlayers, int onlinePlayers)
|
|
||||||
{
|
|
||||||
this.maxPlayers = maxOnlinePlayers;
|
|
||||||
this.onlinePlayerCount = onlinePlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxPlayers()
|
|
||||||
{
|
|
||||||
return this.maxPlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOnlinePlayerCount()
|
|
||||||
{
|
|
||||||
return this.onlinePlayerCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameProfile[] getPlayers()
|
|
||||||
{
|
|
||||||
return this.players;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayers(GameProfile[] playersIn)
|
|
||||||
{
|
|
||||||
this.players = playersIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Serializer implements JsonDeserializer<ServerStatusResponse.PlayerCountData>, JsonSerializer<ServerStatusResponse.PlayerCountData>
|
|
||||||
{
|
|
||||||
public ServerStatusResponse.PlayerCountData deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
|
||||||
{
|
|
||||||
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "players");
|
|
||||||
ServerStatusResponse.PlayerCountData serverstatusresponse$playercountdata = new ServerStatusResponse.PlayerCountData(JsonUtils.getInt(jsonobject, "max"), JsonUtils.getInt(jsonobject, "online"));
|
|
||||||
|
|
||||||
if (JsonUtils.isJsonArray(jsonobject, "sample"))
|
|
||||||
{
|
|
||||||
JsonArray jsonarray = JsonUtils.getJsonArray(jsonobject, "sample");
|
|
||||||
|
|
||||||
if (jsonarray.size() > 0)
|
|
||||||
{
|
|
||||||
GameProfile[] agameprofile = new GameProfile[jsonarray.size()];
|
|
||||||
|
|
||||||
for (int i = 0; i < agameprofile.length; ++i)
|
|
||||||
{
|
|
||||||
JsonObject jsonobject1 = JsonUtils.getJsonObject(jsonarray.get(i), "player[" + i + "]");
|
|
||||||
String s = JsonUtils.getString(jsonobject1, "id");
|
|
||||||
agameprofile[i] = new GameProfile(UUID.fromString(s), JsonUtils.getString(jsonobject1, "name"));
|
|
||||||
}
|
|
||||||
|
|
||||||
serverstatusresponse$playercountdata.setPlayers(agameprofile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return serverstatusresponse$playercountdata;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement serialize(ServerStatusResponse.PlayerCountData p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
|
|
||||||
{
|
|
||||||
JsonObject jsonobject = new JsonObject();
|
|
||||||
jsonobject.addProperty("max", (Number)Integer.valueOf(p_serialize_1_.getMaxPlayers()));
|
|
||||||
jsonobject.addProperty("online", (Number)Integer.valueOf(p_serialize_1_.getOnlinePlayerCount()));
|
|
||||||
|
|
||||||
if (p_serialize_1_.getPlayers() != null && p_serialize_1_.getPlayers().length > 0)
|
|
||||||
{
|
|
||||||
JsonArray jsonarray = new JsonArray();
|
|
||||||
|
|
||||||
for (int i = 0; i < p_serialize_1_.getPlayers().length; ++i)
|
|
||||||
{
|
|
||||||
JsonObject jsonobject1 = new JsonObject();
|
|
||||||
UUID uuid = p_serialize_1_.getPlayers()[i].getId();
|
|
||||||
jsonobject1.addProperty("id", uuid == null ? "" : uuid.toString());
|
|
||||||
jsonobject1.addProperty("name", p_serialize_1_.getPlayers()[i].getName());
|
|
||||||
jsonarray.add(jsonobject1);
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonobject.add("sample", jsonarray);
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonobject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Serializer implements JsonDeserializer<ServerStatusResponse>, JsonSerializer<ServerStatusResponse>
|
|
||||||
{
|
|
||||||
public ServerStatusResponse deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
|
|
||||||
{
|
|
||||||
JsonObject jsonobject = JsonUtils.getJsonObject(p_deserialize_1_, "status");
|
|
||||||
ServerStatusResponse serverstatusresponse = new ServerStatusResponse();
|
|
||||||
|
|
||||||
if (jsonobject.has("description"))
|
|
||||||
{
|
|
||||||
serverstatusresponse.setServerDescription((ChatComponent)p_deserialize_3_.deserialize(jsonobject.get("description"), ChatComponent.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonobject.has("players"))
|
|
||||||
{
|
|
||||||
serverstatusresponse.setPlayerCountData((ServerStatusResponse.PlayerCountData)p_deserialize_3_.deserialize(jsonobject.get("players"), ServerStatusResponse.PlayerCountData.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonobject.has("version"))
|
|
||||||
{
|
|
||||||
serverstatusresponse.setProtocolVersionInfo((ServerStatusResponse.MinecraftProtocolVersionIdentifier)p_deserialize_3_.deserialize(jsonobject.get("version"), ServerStatusResponse.MinecraftProtocolVersionIdentifier.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonobject.has("favicon"))
|
|
||||||
{
|
|
||||||
serverstatusresponse.setFavicon(JsonUtils.getString(jsonobject, "favicon"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return serverstatusresponse;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement serialize(ServerStatusResponse p_serialize_1_, Type p_serialize_2_, JsonSerializationContext p_serialize_3_)
|
|
||||||
{
|
|
||||||
JsonObject jsonobject = new JsonObject();
|
|
||||||
|
|
||||||
if (p_serialize_1_.getServerDescription() != null)
|
|
||||||
{
|
|
||||||
jsonobject.add("description", p_serialize_3_.serialize(p_serialize_1_.getServerDescription()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_serialize_1_.getPlayerCountData() != null)
|
|
||||||
{
|
|
||||||
jsonobject.add("players", p_serialize_3_.serialize(p_serialize_1_.getPlayerCountData()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_serialize_1_.getProtocolVersionInfo() != null)
|
|
||||||
{
|
|
||||||
jsonobject.add("version", p_serialize_3_.serialize(p_serialize_1_.getProtocolVersionInfo()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_serialize_1_.getFavicon() != null)
|
|
||||||
{
|
|
||||||
jsonobject.addProperty("favicon", p_serialize_1_.getFavicon());
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonobject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,11 +5,11 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class C07PacketPlayerDigging implements Packet<NetHandlerPlayServer>
|
public class C07PacketPlayerDigging implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos position;
|
private Vec3 position;
|
||||||
private byte facing;
|
private byte facing;
|
||||||
private C07PacketPlayerDigging.Action status;
|
private C07PacketPlayerDigging.Action status;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class C07PacketPlayerDigging implements Packet<NetHandlerPlayServer>
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.status = (C07PacketPlayerDigging.Action)buf.readEnumValue(C07PacketPlayerDigging.Action.class);
|
this.status = (C07PacketPlayerDigging.Action)buf.readEnumValue(C07PacketPlayerDigging.Action.class);
|
||||||
this.position = buf.readBlockPos();
|
this.position = buf.readVector();
|
||||||
this.facing = (byte)buf.readUnsignedByte();
|
this.facing = (byte)buf.readUnsignedByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class C07PacketPlayerDigging implements Packet<NetHandlerPlayServer>
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeEnumValue(this.status);
|
buf.writeEnumValue(this.status);
|
||||||
buf.writeBlockPos(this.position);
|
buf.writeVector(this.position);
|
||||||
buf.writeByte(this.facing);
|
buf.writeByte(this.facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,14 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
import proxy.util.ItemStack;
|
import proxy.util.Stack;
|
||||||
|
|
||||||
public class C08PacketPlayerBlockPlacement implements Packet<NetHandlerPlayServer>
|
public class C08PacketPlayerBlockPlacement implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos position;
|
private Vec3 position;
|
||||||
private int placedBlockDirection;
|
private int placedBlockDirection;
|
||||||
private ItemStack stack;
|
private Stack stack;
|
||||||
private float facingX;
|
private float facingX;
|
||||||
private float facingY;
|
private float facingY;
|
||||||
private float facingZ;
|
private float facingZ;
|
||||||
|
@ -22,9 +22,9 @@ public class C08PacketPlayerBlockPlacement implements Packet<NetHandlerPlayServe
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.position = buf.readBlockPos();
|
this.position = buf.readVector();
|
||||||
this.placedBlockDirection = buf.readUnsignedByte();
|
this.placedBlockDirection = buf.readUnsignedByte();
|
||||||
this.stack = buf.readItemStackFromBuffer();
|
this.stack = buf.readStack();
|
||||||
this.facingX = (float)buf.readUnsignedByte() / 16.0F;
|
this.facingX = (float)buf.readUnsignedByte() / 16.0F;
|
||||||
this.facingY = (float)buf.readUnsignedByte() / 16.0F;
|
this.facingY = (float)buf.readUnsignedByte() / 16.0F;
|
||||||
this.facingZ = (float)buf.readUnsignedByte() / 16.0F;
|
this.facingZ = (float)buf.readUnsignedByte() / 16.0F;
|
||||||
|
@ -35,9 +35,9 @@ public class C08PacketPlayerBlockPlacement implements Packet<NetHandlerPlayServe
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.position);
|
buf.writeVector(this.position);
|
||||||
buf.writeByte(this.placedBlockDirection);
|
buf.writeByte(this.placedBlockDirection);
|
||||||
buf.writeItemStackToBuffer(this.stack);
|
buf.writeStack(this.stack);
|
||||||
buf.writeByte((int)(this.facingX * 16.0F));
|
buf.writeByte((int)(this.facingX * 16.0F));
|
||||||
buf.writeByte((int)(this.facingY * 16.0F));
|
buf.writeByte((int)(this.facingY * 16.0F));
|
||||||
buf.writeByte((int)(this.facingZ * 16.0F));
|
buf.writeByte((int)(this.facingZ * 16.0F));
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.ItemStack;
|
import proxy.util.Stack;
|
||||||
|
|
||||||
public class C0EPacketClickWindow implements Packet<NetHandlerPlayServer>
|
public class C0EPacketClickWindow implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ public class C0EPacketClickWindow implements Packet<NetHandlerPlayServer>
|
||||||
private int slotId;
|
private int slotId;
|
||||||
private int usedButton;
|
private int usedButton;
|
||||||
private short actionNumber;
|
private short actionNumber;
|
||||||
private ItemStack clickedItem;
|
private Stack clickedItem;
|
||||||
private int mode;
|
private int mode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,7 @@ public class C0EPacketClickWindow implements Packet<NetHandlerPlayServer>
|
||||||
this.usedButton = buf.readByte();
|
this.usedButton = buf.readByte();
|
||||||
this.actionNumber = buf.readShort();
|
this.actionNumber = buf.readShort();
|
||||||
this.mode = buf.readByte();
|
this.mode = buf.readByte();
|
||||||
this.clickedItem = buf.readItemStackFromBuffer();
|
this.clickedItem = buf.readStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,6 +47,6 @@ public class C0EPacketClickWindow implements Packet<NetHandlerPlayServer>
|
||||||
buf.writeByte(this.usedButton);
|
buf.writeByte(this.usedButton);
|
||||||
buf.writeShort(this.actionNumber);
|
buf.writeShort(this.actionNumber);
|
||||||
buf.writeByte(this.mode);
|
buf.writeByte(this.mode);
|
||||||
buf.writeItemStackToBuffer(this.clickedItem);
|
buf.writeStack(this.clickedItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.ItemStack;
|
import proxy.util.Stack;
|
||||||
|
|
||||||
public class C10PacketCreativeInventoryAction implements Packet<NetHandlerPlayServer>
|
public class C10PacketCreativeInventoryAction implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int slotId;
|
private int slotId;
|
||||||
private ItemStack stack;
|
private Stack stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes this Packet on to the NetHandler for processing.
|
* Passes this Packet on to the NetHandler for processing.
|
||||||
|
@ -26,7 +26,7 @@ public class C10PacketCreativeInventoryAction implements Packet<NetHandlerPlaySe
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.slotId = buf.readShort();
|
this.slotId = buf.readShort();
|
||||||
this.stack = buf.readItemStackFromBuffer();
|
this.stack = buf.readStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,10 +35,10 @@ public class C10PacketCreativeInventoryAction implements Packet<NetHandlerPlaySe
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeShort(this.slotId);
|
buf.writeShort(this.slotId);
|
||||||
buf.writeItemStackToBuffer(this.stack);
|
buf.writeStack(this.stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getStack()
|
public Stack getStack()
|
||||||
{
|
{
|
||||||
return this.stack;
|
return this.stack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
import proxy.util.ChatComponent;
|
import proxy.util.ChatComponent;
|
||||||
|
|
||||||
public class C12PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
public class C12PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos pos;
|
private Vec3 pos;
|
||||||
private ChatComponent[] lines;
|
private ChatComponent[] lines;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ public class C12PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.pos = buf.readBlockPos();
|
this.pos = buf.readVector();
|
||||||
this.lines = new ChatComponent[4];
|
this.lines = new ChatComponent[4];
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
|
@ -34,7 +34,7 @@ public class C12PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.pos);
|
buf.writeVector(this.pos);
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class C14PacketTabComplete implements Packet<NetHandlerPlayServer>
|
public class C14PacketTabComplete implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private String message;
|
private String message;
|
||||||
private BlockPos targetBlock;
|
private Vec3 targetBlock;
|
||||||
|
|
||||||
public C14PacketTabComplete()
|
public C14PacketTabComplete()
|
||||||
{
|
{
|
||||||
|
@ -18,10 +18,10 @@ public class C14PacketTabComplete implements Packet<NetHandlerPlayServer>
|
||||||
|
|
||||||
public C14PacketTabComplete(String msg)
|
public C14PacketTabComplete(String msg)
|
||||||
{
|
{
|
||||||
this(msg, (BlockPos)null);
|
this(msg, (Vec3)null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public C14PacketTabComplete(String msg, BlockPos target)
|
public C14PacketTabComplete(String msg, Vec3 target)
|
||||||
{
|
{
|
||||||
this.message = msg;
|
this.message = msg;
|
||||||
this.targetBlock = target;
|
this.targetBlock = target;
|
||||||
|
@ -37,7 +37,7 @@ public class C14PacketTabComplete implements Packet<NetHandlerPlayServer>
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
this.targetBlock = buf.readBlockPos();
|
this.targetBlock = buf.readVector();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class C14PacketTabComplete implements Packet<NetHandlerPlayServer>
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.targetBlock);
|
buf.writeVector(this.targetBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class C14PacketTabComplete implements Packet<NetHandlerPlayServer>
|
||||||
return this.message;
|
return this.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPos getTargetBlock()
|
public Vec3 getTargetBlock()
|
||||||
{
|
{
|
||||||
return this.targetBlock;
|
return this.targetBlock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.ItemStack;
|
import proxy.util.Stack;
|
||||||
|
|
||||||
public class S04PacketEntityEquipment implements Packet<NetHandlerPlayServer>
|
public class S04PacketEntityEquipment implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int entityID;
|
private int entityID;
|
||||||
private int equipmentSlot;
|
private int equipmentSlot;
|
||||||
private ItemStack itemStack;
|
private Stack itemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the raw packet data from the data stream.
|
* Reads the raw packet data from the data stream.
|
||||||
|
@ -20,7 +20,7 @@ public class S04PacketEntityEquipment implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
this.entityID = buf.readVarIntFromBuffer();
|
this.entityID = buf.readVarIntFromBuffer();
|
||||||
this.equipmentSlot = buf.readShort();
|
this.equipmentSlot = buf.readShort();
|
||||||
this.itemStack = buf.readItemStackFromBuffer();
|
this.itemStack = buf.readStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,7 @@ public class S04PacketEntityEquipment implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
buf.writeVarIntToBuffer(this.entityID);
|
buf.writeVarIntToBuffer(this.entityID);
|
||||||
buf.writeShort(this.equipmentSlot);
|
buf.writeShort(this.equipmentSlot);
|
||||||
buf.writeItemStackToBuffer(this.itemStack);
|
buf.writeStack(this.itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,18 +5,18 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S05PacketSpawnPosition implements Packet<NetHandlerPlayServer>
|
public class S05PacketSpawnPosition implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos spawnBlockPos;
|
private Vec3 spawnBlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the raw packet data from the data stream.
|
* Reads the raw packet data from the data stream.
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.spawnBlockPos = buf.readBlockPos();
|
this.spawnBlockPos = buf.readVector();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ public class S05PacketSpawnPosition implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.spawnBlockPos);
|
buf.writeVector(this.spawnBlockPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S0APacketUseBed implements Packet<NetHandlerPlayServer>
|
public class S0APacketUseBed implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int playerID;
|
private int playerID;
|
||||||
private BlockPos bedPos;
|
private Vec3 bedPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the raw packet data from the data stream.
|
* Reads the raw packet data from the data stream.
|
||||||
|
@ -18,7 +18,7 @@ public class S0APacketUseBed implements Packet<NetHandlerPlayServer>
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.playerID = buf.readVarIntFromBuffer();
|
this.playerID = buf.readVarIntFromBuffer();
|
||||||
this.bedPos = buf.readBlockPos();
|
this.bedPos = buf.readVector();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ public class S0APacketUseBed implements Packet<NetHandlerPlayServer>
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeVarIntToBuffer(this.playerID);
|
buf.writeVarIntToBuffer(this.playerID);
|
||||||
buf.writeBlockPos(this.bedPos);
|
buf.writeVector(this.bedPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.DataWatcher;
|
import proxy.util.EntityData;
|
||||||
import proxy.util.MathHelper;
|
import proxy.util.MathHelper;
|
||||||
|
|
||||||
public class S0CPacketSpawnPlayer implements Packet<NetHandlerPlayServer>
|
public class S0CPacketSpawnPlayer implements Packet<NetHandlerPlayServer>
|
||||||
|
@ -20,7 +20,7 @@ public class S0CPacketSpawnPlayer implements Packet<NetHandlerPlayServer>
|
||||||
private byte yaw;
|
private byte yaw;
|
||||||
private byte pitch;
|
private byte pitch;
|
||||||
private int currentItem;
|
private int currentItem;
|
||||||
private List<DataWatcher.WatchableObject> field_148958_j;
|
private List<EntityData> field_148958_j;
|
||||||
|
|
||||||
public S0CPacketSpawnPlayer()
|
public S0CPacketSpawnPlayer()
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ public class S0CPacketSpawnPlayer implements Packet<NetHandlerPlayServer>
|
||||||
this.yaw = buf.readByte();
|
this.yaw = buf.readByte();
|
||||||
this.pitch = buf.readByte();
|
this.pitch = buf.readByte();
|
||||||
this.currentItem = buf.readShort();
|
this.currentItem = buf.readShort();
|
||||||
this.field_148958_j = DataWatcher.readWatchedListFromPacketBuffer(buf);
|
this.field_148958_j = EntityData.readData(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ public class S0CPacketSpawnPlayer implements Packet<NetHandlerPlayServer>
|
||||||
buf.writeByte(this.yaw);
|
buf.writeByte(this.yaw);
|
||||||
buf.writeByte(this.pitch);
|
buf.writeByte(this.pitch);
|
||||||
buf.writeShort(this.currentItem);
|
buf.writeShort(this.currentItem);
|
||||||
DataWatcher.writeWatchedListToPacketBuffer(this.field_148958_j, buf);
|
EntityData.writeData(this.field_148958_j, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.DataWatcher;
|
import proxy.util.EntityData;
|
||||||
|
|
||||||
public class S0FPacketSpawnMob implements Packet<NetHandlerPlayServer>
|
public class S0FPacketSpawnMob implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ public class S0FPacketSpawnMob implements Packet<NetHandlerPlayServer>
|
||||||
private byte yaw;
|
private byte yaw;
|
||||||
private byte pitch;
|
private byte pitch;
|
||||||
private byte headPitch;
|
private byte headPitch;
|
||||||
private List<DataWatcher.WatchableObject> watcher;
|
private List<EntityData> watcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the raw packet data from the data stream.
|
* Reads the raw packet data from the data stream.
|
||||||
|
@ -39,7 +39,7 @@ public class S0FPacketSpawnMob implements Packet<NetHandlerPlayServer>
|
||||||
this.velocityX = buf.readShort();
|
this.velocityX = buf.readShort();
|
||||||
this.velocityY = buf.readShort();
|
this.velocityY = buf.readShort();
|
||||||
this.velocityZ = buf.readShort();
|
this.velocityZ = buf.readShort();
|
||||||
this.watcher = DataWatcher.readWatchedListFromPacketBuffer(buf);
|
this.watcher = EntityData.readData(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +58,7 @@ public class S0FPacketSpawnMob implements Packet<NetHandlerPlayServer>
|
||||||
buf.writeShort(this.velocityX);
|
buf.writeShort(this.velocityX);
|
||||||
buf.writeShort(this.velocityY);
|
buf.writeShort(this.velocityY);
|
||||||
buf.writeShort(this.velocityZ);
|
buf.writeShort(this.velocityZ);
|
||||||
DataWatcher.writeWatchedListToPacketBuffer(this.watcher, buf);
|
EntityData.writeData(this.watcher, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S10PacketSpawnPainting implements Packet<NetHandlerPlayServer>
|
public class S10PacketSpawnPainting implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int entityID;
|
private int entityID;
|
||||||
private BlockPos position;
|
private Vec3 position;
|
||||||
private byte facing;
|
private byte facing;
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class S10PacketSpawnPainting implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
this.entityID = buf.readVarIntFromBuffer();
|
this.entityID = buf.readVarIntFromBuffer();
|
||||||
this.title = buf.readStringFromBuffer(13);
|
this.title = buf.readStringFromBuffer(13);
|
||||||
this.position = buf.readBlockPos();
|
this.position = buf.readVector();
|
||||||
this.facing = (byte)buf.readUnsignedByte();
|
this.facing = (byte)buf.readUnsignedByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class S10PacketSpawnPainting implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
buf.writeVarIntToBuffer(this.entityID);
|
buf.writeVarIntToBuffer(this.entityID);
|
||||||
buf.writeString(this.title);
|
buf.writeString(this.title);
|
||||||
buf.writeBlockPos(this.position);
|
buf.writeVector(this.position);
|
||||||
buf.writeByte(this.facing);
|
buf.writeByte(this.facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ import java.util.List;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.DataWatcher;
|
import proxy.util.EntityData;
|
||||||
|
|
||||||
public class S1CPacketEntityMetadata implements Packet<NetHandlerPlayServer>
|
public class S1CPacketEntityMetadata implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int entityId;
|
private int entityId;
|
||||||
private List<DataWatcher.WatchableObject> field_149378_b;
|
private List<EntityData> field_149378_b;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the raw packet data from the data stream.
|
* Reads the raw packet data from the data stream.
|
||||||
|
@ -19,7 +19,7 @@ public class S1CPacketEntityMetadata implements Packet<NetHandlerPlayServer>
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.entityId = buf.readVarIntFromBuffer();
|
this.entityId = buf.readVarIntFromBuffer();
|
||||||
this.field_149378_b = DataWatcher.readWatchedListFromPacketBuffer(buf);
|
this.field_149378_b = EntityData.readData(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,7 @@ public class S1CPacketEntityMetadata implements Packet<NetHandlerPlayServer>
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeVarIntToBuffer(this.entityId);
|
buf.writeVarIntToBuffer(this.entityId);
|
||||||
DataWatcher.writeWatchedListToPacketBuffer(this.field_149378_b, buf);
|
EntityData.writeData(this.field_149378_b, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,11 +5,11 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S23PacketBlockChange implements Packet<NetHandlerPlayServer>
|
public class S23PacketBlockChange implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos blockPosition;
|
private Vec3 blockPosition;
|
||||||
private int blockState;
|
private int blockState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,7 @@ public class S23PacketBlockChange implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.blockPosition = buf.readBlockPos();
|
this.blockPosition = buf.readVector();
|
||||||
this.blockState = buf.readVarIntFromBuffer();
|
this.blockState = buf.readVarIntFromBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public class S23PacketBlockChange implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.blockPosition);
|
buf.writeVector(this.blockPosition);
|
||||||
buf.writeVarIntToBuffer(this.blockState);
|
buf.writeVarIntToBuffer(this.blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S24PacketBlockAction implements Packet<NetHandlerPlayServer>
|
public class S24PacketBlockAction implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos blockPosition;
|
private Vec3 blockPosition;
|
||||||
private int instrument;
|
private int instrument;
|
||||||
private int pitch;
|
private int pitch;
|
||||||
private int block;
|
private int block;
|
||||||
|
@ -19,7 +19,7 @@ public class S24PacketBlockAction implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.blockPosition = buf.readBlockPos();
|
this.blockPosition = buf.readVector();
|
||||||
this.instrument = buf.readUnsignedByte();
|
this.instrument = buf.readUnsignedByte();
|
||||||
this.pitch = buf.readUnsignedByte();
|
this.pitch = buf.readUnsignedByte();
|
||||||
this.block = buf.readVarIntFromBuffer();
|
this.block = buf.readVarIntFromBuffer();
|
||||||
|
@ -30,7 +30,7 @@ public class S24PacketBlockAction implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.blockPosition);
|
buf.writeVector(this.blockPosition);
|
||||||
buf.writeByte(this.instrument);
|
buf.writeByte(this.instrument);
|
||||||
buf.writeByte(this.pitch);
|
buf.writeByte(this.pitch);
|
||||||
buf.writeVarIntToBuffer(this.block);
|
buf.writeVarIntToBuffer(this.block);
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S25PacketBlockBreakAnim implements Packet<NetHandlerPlayServer>
|
public class S25PacketBlockBreakAnim implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int breakerId;
|
private int breakerId;
|
||||||
private BlockPos position;
|
private Vec3 position;
|
||||||
private int progress;
|
private int progress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ public class S25PacketBlockBreakAnim implements Packet<NetHandlerPlayServer>
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.breakerId = buf.readVarIntFromBuffer();
|
this.breakerId = buf.readVarIntFromBuffer();
|
||||||
this.position = buf.readBlockPos();
|
this.position = buf.readVector();
|
||||||
this.progress = buf.readUnsignedByte();
|
this.progress = buf.readUnsignedByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class S25PacketBlockBreakAnim implements Packet<NetHandlerPlayServer>
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeVarIntToBuffer(this.breakerId);
|
buf.writeVarIntToBuffer(this.breakerId);
|
||||||
buf.writeBlockPos(this.position);
|
buf.writeVector(this.position);
|
||||||
buf.writeByte(this.progress);
|
buf.writeByte(this.progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.google.common.collect.Lists;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S27PacketExplosion implements Packet<NetHandlerPlayServer>
|
public class S27PacketExplosion implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ public class S27PacketExplosion implements Packet<NetHandlerPlayServer>
|
||||||
private double posY;
|
private double posY;
|
||||||
private double posZ;
|
private double posZ;
|
||||||
private float strength;
|
private float strength;
|
||||||
private List<BlockPos> affectedBlockPositions;
|
private List<Vec3> affectedBlockPositions;
|
||||||
private float field_149152_f;
|
private float field_149152_f;
|
||||||
private float field_149153_g;
|
private float field_149153_g;
|
||||||
private float field_149159_h;
|
private float field_149159_h;
|
||||||
|
@ -31,7 +31,7 @@ public class S27PacketExplosion implements Packet<NetHandlerPlayServer>
|
||||||
this.posZ = (double)buf.readFloat();
|
this.posZ = (double)buf.readFloat();
|
||||||
this.strength = buf.readFloat();
|
this.strength = buf.readFloat();
|
||||||
int i = buf.readInt();
|
int i = buf.readInt();
|
||||||
this.affectedBlockPositions = Lists.<BlockPos>newArrayListWithCapacity(i);
|
this.affectedBlockPositions = Lists.<Vec3>newArrayListWithCapacity(i);
|
||||||
int j = (int)this.posX;
|
int j = (int)this.posX;
|
||||||
int k = (int)this.posY;
|
int k = (int)this.posY;
|
||||||
int l = (int)this.posZ;
|
int l = (int)this.posZ;
|
||||||
|
@ -41,7 +41,7 @@ public class S27PacketExplosion implements Packet<NetHandlerPlayServer>
|
||||||
int j1 = buf.readByte() + j;
|
int j1 = buf.readByte() + j;
|
||||||
int k1 = buf.readByte() + k;
|
int k1 = buf.readByte() + k;
|
||||||
int l1 = buf.readByte() + l;
|
int l1 = buf.readByte() + l;
|
||||||
this.affectedBlockPositions.add(new BlockPos(j1, k1, l1));
|
this.affectedBlockPositions.add(new Vec3(j1, k1, l1));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.field_149152_f = buf.readFloat();
|
this.field_149152_f = buf.readFloat();
|
||||||
|
@ -63,7 +63,7 @@ public class S27PacketExplosion implements Packet<NetHandlerPlayServer>
|
||||||
int j = (int)this.posY;
|
int j = (int)this.posY;
|
||||||
int k = (int)this.posZ;
|
int k = (int)this.posZ;
|
||||||
|
|
||||||
for (BlockPos blockpos : this.affectedBlockPositions)
|
for (Vec3 blockpos : this.affectedBlockPositions)
|
||||||
{
|
{
|
||||||
int l = blockpos.getX() - i;
|
int l = blockpos.getX() - i;
|
||||||
int i1 = blockpos.getY() - j;
|
int i1 = blockpos.getY() - j;
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S28PacketEffect implements Packet<NetHandlerPlayServer>
|
public class S28PacketEffect implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int soundType;
|
private int soundType;
|
||||||
private BlockPos soundPos;
|
private Vec3 soundPos;
|
||||||
private int soundData;
|
private int soundData;
|
||||||
private boolean serverWide;
|
private boolean serverWide;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class S28PacketEffect implements Packet<NetHandlerPlayServer>
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.soundType = buf.readInt();
|
this.soundType = buf.readInt();
|
||||||
this.soundPos = buf.readBlockPos();
|
this.soundPos = buf.readVector();
|
||||||
this.soundData = buf.readInt();
|
this.soundData = buf.readInt();
|
||||||
this.serverWide = buf.readBoolean();
|
this.serverWide = buf.readBoolean();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class S28PacketEffect implements Packet<NetHandlerPlayServer>
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeInt(this.soundType);
|
buf.writeInt(this.soundType);
|
||||||
buf.writeBlockPos(this.soundPos);
|
buf.writeVector(this.soundPos);
|
||||||
buf.writeInt(this.soundData);
|
buf.writeInt(this.soundData);
|
||||||
buf.writeBoolean(this.serverWide);
|
buf.writeBoolean(this.serverWide);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.ItemStack;
|
import proxy.util.Stack;
|
||||||
|
|
||||||
public class S2FPacketSetSlot implements Packet<NetHandlerPlayServer>
|
public class S2FPacketSetSlot implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int windowId;
|
private int windowId;
|
||||||
private int slot;
|
private int slot;
|
||||||
private ItemStack item;
|
private Stack item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes this Packet on to the NetHandler for processing.
|
* Passes this Packet on to the NetHandler for processing.
|
||||||
|
@ -28,7 +28,7 @@ public class S2FPacketSetSlot implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
this.windowId = buf.readByte();
|
this.windowId = buf.readByte();
|
||||||
this.slot = buf.readShort();
|
this.slot = buf.readShort();
|
||||||
this.item = buf.readItemStackFromBuffer();
|
this.item = buf.readStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,6 +38,6 @@ public class S2FPacketSetSlot implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
buf.writeByte(this.windowId);
|
buf.writeByte(this.windowId);
|
||||||
buf.writeShort(this.slot);
|
buf.writeShort(this.slot);
|
||||||
buf.writeItemStackToBuffer(this.item);
|
buf.writeStack(this.item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.ItemStack;
|
import proxy.util.Stack;
|
||||||
|
|
||||||
public class S30PacketWindowItems implements Packet<NetHandlerPlayServer>
|
public class S30PacketWindowItems implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private int windowId;
|
private int windowId;
|
||||||
private ItemStack[] itemStacks;
|
private Stack[] itemStacks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the raw packet data from the data stream.
|
* Reads the raw packet data from the data stream.
|
||||||
|
@ -19,11 +19,11 @@ public class S30PacketWindowItems implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
this.windowId = buf.readUnsignedByte();
|
this.windowId = buf.readUnsignedByte();
|
||||||
int i = buf.readShort();
|
int i = buf.readShort();
|
||||||
this.itemStacks = new ItemStack[i];
|
this.itemStacks = new Stack[i];
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j)
|
for (int j = 0; j < i; ++j)
|
||||||
{
|
{
|
||||||
this.itemStacks[j] = buf.readItemStackFromBuffer();
|
this.itemStacks[j] = buf.readStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@ public class S30PacketWindowItems implements Packet<NetHandlerPlayServer>
|
||||||
buf.writeByte(this.windowId);
|
buf.writeByte(this.windowId);
|
||||||
buf.writeShort(this.itemStacks.length);
|
buf.writeShort(this.itemStacks.length);
|
||||||
|
|
||||||
for (ItemStack itemstack : this.itemStacks)
|
for (Stack itemstack : this.itemStacks)
|
||||||
{
|
{
|
||||||
buf.writeItemStackToBuffer(itemstack);
|
buf.writeStack(itemstack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
import proxy.util.ChatComponent;
|
import proxy.util.ChatComponent;
|
||||||
import proxy.util.ChatComponentText;
|
import proxy.util.ChatComponentText;
|
||||||
|
|
||||||
public class S33PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
public class S33PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos blockPos;
|
private Vec3 blockPos;
|
||||||
private ChatComponent[] lines;
|
private ChatComponent[] lines;
|
||||||
|
|
||||||
public S33PacketUpdateSign() {
|
public S33PacketUpdateSign() {
|
||||||
|
@ -19,7 +19,7 @@ public class S33PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
||||||
}
|
}
|
||||||
|
|
||||||
public S33PacketUpdateSign(int x, int y, int z, String line1, String line2, String line3, String line4) {
|
public S33PacketUpdateSign(int x, int y, int z, String line1, String line2, String line3, String line4) {
|
||||||
this.blockPos = new BlockPos(x, y, z);
|
this.blockPos = new Vec3(x, y, z);
|
||||||
this.lines = new ChatComponent[] {new ChatComponentText(line1), new ChatComponentText(line2), new ChatComponentText(line3), new ChatComponentText(line4)};
|
this.lines = new ChatComponent[] {new ChatComponentText(line1), new ChatComponentText(line2), new ChatComponentText(line3), new ChatComponentText(line4)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class S33PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.blockPos = buf.readBlockPos();
|
this.blockPos = buf.readVector();
|
||||||
this.lines = new ChatComponent[4];
|
this.lines = new ChatComponent[4];
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
|
@ -42,7 +42,7 @@ public class S33PacketUpdateSign implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.blockPos);
|
buf.writeVector(this.blockPos);
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,11 +6,11 @@ import proxy.nbt.NBTTagCompound;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S35PacketUpdateTileEntity implements Packet<NetHandlerPlayServer>
|
public class S35PacketUpdateTileEntity implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos blockPos;
|
private Vec3 blockPos;
|
||||||
private int metadata;
|
private int metadata;
|
||||||
private NBTTagCompound nbt;
|
private NBTTagCompound nbt;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class S35PacketUpdateTileEntity implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.blockPos = buf.readBlockPos();
|
this.blockPos = buf.readVector();
|
||||||
this.metadata = buf.readUnsignedByte();
|
this.metadata = buf.readUnsignedByte();
|
||||||
this.nbt = buf.readNBTTagCompoundFromBuffer();
|
this.nbt = buf.readNBTTagCompoundFromBuffer();
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class S35PacketUpdateTileEntity implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.blockPos);
|
buf.writeVector(this.blockPos);
|
||||||
buf.writeByte((byte)this.metadata);
|
buf.writeByte((byte)this.metadata);
|
||||||
buf.writeNBTTagCompoundToBuffer(this.nbt);
|
buf.writeNBTTagCompoundToBuffer(this.nbt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,18 +5,18 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerPlayServer;
|
import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.BlockPos;
|
import proxy.util.Vec3;
|
||||||
|
|
||||||
public class S36PacketSignEditorOpen implements Packet<NetHandlerPlayServer>
|
public class S36PacketSignEditorOpen implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private BlockPos signPosition;
|
private Vec3 signPosition;
|
||||||
|
|
||||||
public S36PacketSignEditorOpen() {
|
public S36PacketSignEditorOpen() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public S36PacketSignEditorOpen(int x, int y, int z) {
|
public S36PacketSignEditorOpen(int x, int y, int z) {
|
||||||
this.signPosition = new BlockPos(x, y, z);
|
this.signPosition = new Vec3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,7 @@ public class S36PacketSignEditorOpen implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.signPosition = buf.readBlockPos();
|
this.signPosition = buf.readVector();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +40,6 @@ public class S36PacketSignEditorOpen implements Packet<NetHandlerPlayServer>
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBlockPos(this.signPosition);
|
buf.writeVector(this.signPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import proxy.network.NetHandlerPlayServer;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.util.ChatComponent;
|
import proxy.util.ChatComponent;
|
||||||
import proxy.util.GameProfile;
|
import proxy.util.Profile;
|
||||||
import proxy.util.Property;
|
import proxy.util.Property;
|
||||||
|
|
||||||
public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
|
@ -22,7 +22,7 @@ public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public S38PacketPlayerListItem(S38PacketPlayerListItem.Action actionIn, GameProfile profile, int ping, int mode, ChatComponent display)
|
public S38PacketPlayerListItem(S38PacketPlayerListItem.Action actionIn, Profile profile, int ping, int mode, ChatComponent display)
|
||||||
{
|
{
|
||||||
this.action = actionIn;
|
this.action = actionIn;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j)
|
for (int j = 0; j < i; ++j)
|
||||||
{
|
{
|
||||||
GameProfile gameprofile = null;
|
Profile gameprofile = null;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
int worldsettings$gametype = 0;
|
int worldsettings$gametype = 0;
|
||||||
ChatComponent ichatcomponent = null;
|
ChatComponent ichatcomponent = null;
|
||||||
|
@ -47,7 +47,7 @@ public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
switch (this.action)
|
switch (this.action)
|
||||||
{
|
{
|
||||||
case ADD_PLAYER:
|
case ADD_PLAYER:
|
||||||
gameprofile = new GameProfile(buf.readUuid(), buf.readStringFromBuffer(16));
|
gameprofile = new Profile(buf.readUuid(), buf.readStringFromBuffer(16));
|
||||||
int l = buf.readVarIntFromBuffer();
|
int l = buf.readVarIntFromBuffer();
|
||||||
int i1 = 0;
|
int i1 = 0;
|
||||||
|
|
||||||
|
@ -77,17 +77,17 @@ public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPDATE_GAME_MODE:
|
case UPDATE_GAME_MODE:
|
||||||
gameprofile = new GameProfile(buf.readUuid(), (String)null);
|
gameprofile = new Profile(buf.readUuid(), (String)null);
|
||||||
worldsettings$gametype = buf.readVarIntFromBuffer();
|
worldsettings$gametype = buf.readVarIntFromBuffer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPDATE_LATENCY:
|
case UPDATE_LATENCY:
|
||||||
gameprofile = new GameProfile(buf.readUuid(), (String)null);
|
gameprofile = new Profile(buf.readUuid(), (String)null);
|
||||||
k = buf.readVarIntFromBuffer();
|
k = buf.readVarIntFromBuffer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPDATE_DISPLAY_NAME:
|
case UPDATE_DISPLAY_NAME:
|
||||||
gameprofile = new GameProfile(buf.readUuid(), (String)null);
|
gameprofile = new Profile(buf.readUuid(), (String)null);
|
||||||
|
|
||||||
if (buf.readBoolean())
|
if (buf.readBoolean())
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REMOVE_PLAYER:
|
case REMOVE_PLAYER:
|
||||||
gameprofile = new GameProfile(buf.readUuid(), (String)null);
|
gameprofile = new Profile(buf.readUuid(), (String)null);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.players.add(new S38PacketPlayerListItem.AddPlayerData(gameprofile, k, worldsettings$gametype, ichatcomponent));
|
this.players.add(new S38PacketPlayerListItem.AddPlayerData(gameprofile, k, worldsettings$gametype, ichatcomponent));
|
||||||
|
@ -126,7 +126,7 @@ public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
buf.writeString(property.getName());
|
buf.writeString(property.getName());
|
||||||
buf.writeString(property.getValue());
|
buf.writeString(property.getValue());
|
||||||
|
|
||||||
if (property.hasSignature())
|
if (property.getSignature() != null)
|
||||||
{
|
{
|
||||||
buf.writeBoolean(true);
|
buf.writeBoolean(true);
|
||||||
buf.writeString(property.getSignature());
|
buf.writeString(property.getSignature());
|
||||||
|
@ -219,10 +219,10 @@ public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
{
|
{
|
||||||
private final int ping;
|
private final int ping;
|
||||||
private final int gamemode;
|
private final int gamemode;
|
||||||
private final GameProfile profile;
|
private final Profile profile;
|
||||||
private final ChatComponent displayName;
|
private final ChatComponent displayName;
|
||||||
|
|
||||||
public AddPlayerData(GameProfile profile, int pingIn, int gamemodeIn, ChatComponent displayNameIn)
|
public AddPlayerData(Profile profile, int pingIn, int gamemodeIn, ChatComponent displayNameIn)
|
||||||
{
|
{
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
this.ping = pingIn;
|
this.ping = pingIn;
|
||||||
|
@ -230,7 +230,7 @@ public class S38PacketPlayerListItem implements Packet<NetHandlerPlayServer>
|
||||||
this.displayName = displayNameIn;
|
this.displayName = displayNameIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameProfile getProfile()
|
public Profile getProfile()
|
||||||
{
|
{
|
||||||
return this.profile;
|
return this.profile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,21 +8,23 @@ import java.io.IOException;
|
||||||
import proxy.network.NetHandlerStatusClient;
|
import proxy.network.NetHandlerStatusClient;
|
||||||
import proxy.network.Packet;
|
import proxy.network.Packet;
|
||||||
import proxy.network.PacketBuffer;
|
import proxy.network.PacketBuffer;
|
||||||
import proxy.network.ServerStatusResponse;
|
|
||||||
import proxy.util.ChatComponent;
|
import proxy.util.ChatComponent;
|
||||||
import proxy.util.ChatStyle;
|
import proxy.util.ChatStyle;
|
||||||
import proxy.util.EnumTypeAdapterFactory;
|
import proxy.util.JsonEnumFactory;
|
||||||
|
import proxy.util.PlayerInfo;
|
||||||
|
import proxy.util.ServerInfo;
|
||||||
|
import proxy.util.VersionId;
|
||||||
|
|
||||||
public class S00PacketServerInfo implements Packet<NetHandlerStatusClient>
|
public class S00PacketServerInfo implements Packet<NetHandlerStatusClient>
|
||||||
{
|
{
|
||||||
private static final Gson GSON = (new GsonBuilder()).registerTypeAdapter(ServerStatusResponse.MinecraftProtocolVersionIdentifier.class, new ServerStatusResponse.MinecraftProtocolVersionIdentifier.Serializer()).registerTypeAdapter(ServerStatusResponse.PlayerCountData.class, new ServerStatusResponse.PlayerCountData.Serializer()).registerTypeAdapter(ServerStatusResponse.class, new ServerStatusResponse.Serializer()).registerTypeHierarchyAdapter(ChatComponent.class, new ChatComponent.Serializer()).registerTypeHierarchyAdapter(ChatStyle.class, new ChatStyle.Serializer()).registerTypeAdapterFactory(new EnumTypeAdapterFactory()).create();
|
private static final Gson GSON = (new GsonBuilder()).registerTypeAdapter(VersionId.class, new VersionId.Serializer()).registerTypeAdapter(PlayerInfo.class, new PlayerInfo.Serializer()).registerTypeAdapter(ServerInfo.class, new ServerInfo.Serializer()).registerTypeHierarchyAdapter(ChatComponent.class, new ChatComponent.Serializer()).registerTypeHierarchyAdapter(ChatStyle.class, new ChatStyle.Serializer()).registerTypeAdapterFactory(new JsonEnumFactory()).create();
|
||||||
private ServerStatusResponse response;
|
private ServerInfo response;
|
||||||
|
|
||||||
public S00PacketServerInfo()
|
public S00PacketServerInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public S00PacketServerInfo(ServerStatusResponse responseIn)
|
public S00PacketServerInfo(ServerInfo responseIn)
|
||||||
{
|
{
|
||||||
this.response = responseIn;
|
this.response = responseIn;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +34,7 @@ public class S00PacketServerInfo implements Packet<NetHandlerStatusClient>
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.response = (ServerStatusResponse)GSON.fromJson(buf.readStringFromBuffer(32767), ServerStatusResponse.class);
|
this.response = (ServerInfo)GSON.fromJson(buf.readStringFromBuffer(32767), ServerInfo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +53,7 @@ public class S00PacketServerInfo implements Packet<NetHandlerStatusClient>
|
||||||
handler.handleServerInfo(this);
|
handler.handleServerInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStatusResponse getResponse()
|
public ServerInfo getResponse()
|
||||||
{
|
{
|
||||||
return this.response;
|
return this.response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
package proxy.util;
|
|
||||||
|
|
||||||
public class BlockPos {
|
|
||||||
private static final int NUM_X_BITS = 1 + MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000));
|
|
||||||
private static final int NUM_Z_BITS = NUM_X_BITS;
|
|
||||||
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
|
|
||||||
private static final int Y_SHIFT = 0 + NUM_Z_BITS;
|
|
||||||
private static final int X_SHIFT = Y_SHIFT + NUM_Y_BITS;
|
|
||||||
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
|
|
||||||
private static final long Y_MASK = (1L << NUM_Y_BITS) - 1L;
|
|
||||||
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
|
|
||||||
|
|
||||||
private final int x;
|
|
||||||
private final int y;
|
|
||||||
private final int z;
|
|
||||||
|
|
||||||
public BlockPos(int x, int y, int z) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return this.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getY() {
|
|
||||||
return this.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getZ() {
|
|
||||||
return this.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long toLong() {
|
|
||||||
return ((long)this.getX() & X_MASK) << X_SHIFT | ((long)this.getY() & Y_MASK) << Y_SHIFT | ((long)this.getZ() & Z_MASK) << 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BlockPos fromLong(long serialized) {
|
|
||||||
int i = (int)(serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
|
|
||||||
int j = (int)(serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
|
|
||||||
int k = (int)(serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
|
|
||||||
return new BlockPos(i, j, k);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,6 +30,10 @@ public enum ChatColor {
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
|
public static String strip(String str) {
|
||||||
|
return str == null ? null : STRIP_PATTERN.matcher(str).replaceAll("");
|
||||||
|
}
|
||||||
|
|
||||||
private ChatColor(char code) {
|
private ChatColor(char code) {
|
||||||
this.value = "\u00a7" + code;
|
this.value = "\u00a7" + code;
|
||||||
}
|
}
|
||||||
|
@ -37,8 +41,4 @@ public enum ChatColor {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String strip(String str) {
|
|
||||||
return str == null ? null : STRIP_PATTERN.matcher(str).replaceAll("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,29 +74,29 @@ public abstract class ChatComponent
|
||||||
|
|
||||||
if (jsonobject.has("with"))
|
if (jsonobject.has("with"))
|
||||||
{
|
{
|
||||||
JsonArray jsonarray = jsonobject.getAsJsonArray("with");
|
JsonArray arr = jsonobject.getAsJsonArray("with");
|
||||||
Object[] aobject = new Object[jsonarray.size()];
|
Object[] args = new Object[arr.size()];
|
||||||
|
|
||||||
for (int i = 0; i < aobject.length; ++i)
|
for (int z = 0; z < args.length; z++)
|
||||||
{
|
{
|
||||||
aobject[i] = this.deserialize(jsonarray.get(i), p_deserialize_2_, p_deserialize_3_);
|
args[z] = this.deserialize(arr.get(z), p_deserialize_2_, p_deserialize_3_);
|
||||||
|
|
||||||
if (aobject[i] instanceof ChatComponentText)
|
if (args[z] instanceof ChatComponentText)
|
||||||
{
|
{
|
||||||
ChatComponentText chatcomponenttext = (ChatComponentText)aobject[i];
|
ChatComponentText text = (ChatComponentText)args[z];
|
||||||
|
|
||||||
if ((((ChatComponent)chatcomponenttext).style == null || ((ChatComponent)chatcomponenttext).style.isEmpty()) && ((ChatComponent)chatcomponenttext).siblings.isEmpty())
|
if ((((ChatComponent)text).style == null || ((ChatComponent)text).style.isEmpty()) && ((ChatComponent)text).siblings.isEmpty())
|
||||||
{
|
{
|
||||||
aobject[i] = chatcomponenttext.getText();
|
args[z] = text.getText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ichatcomponent = new ChatComponentTranslation(s, aobject);
|
ichatcomponent = new ChatComponentTranslation(s, args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ichatcomponent = new ChatComponentTranslation(s, new Object[0]);
|
ichatcomponent = new ChatComponentTranslation(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (jsonobject.has("score"))
|
else if (jsonobject.has("score"))
|
||||||
|
@ -196,11 +196,11 @@ public abstract class ChatComponent
|
||||||
ChatComponentTranslation chatcomponenttranslation = (ChatComponentTranslation)p_serialize_1_;
|
ChatComponentTranslation chatcomponenttranslation = (ChatComponentTranslation)p_serialize_1_;
|
||||||
jsonobject.addProperty("translate", chatcomponenttranslation.getKey());
|
jsonobject.addProperty("translate", chatcomponenttranslation.getKey());
|
||||||
|
|
||||||
if (chatcomponenttranslation.getFormatArgs() != null && chatcomponenttranslation.getFormatArgs().length > 0)
|
if (chatcomponenttranslation.getArgs() != null && chatcomponenttranslation.getArgs().length > 0)
|
||||||
{
|
{
|
||||||
JsonArray jsonarray1 = new JsonArray();
|
JsonArray jsonarray1 = new JsonArray();
|
||||||
|
|
||||||
for (Object object : chatcomponenttranslation.getFormatArgs())
|
for (Object object : chatcomponenttranslation.getArgs())
|
||||||
{
|
{
|
||||||
if (object instanceof ChatComponent)
|
if (object instanceof ChatComponent)
|
||||||
{
|
{
|
||||||
|
@ -254,7 +254,7 @@ public abstract class ChatComponent
|
||||||
GsonBuilder gsonbuilder = new GsonBuilder();
|
GsonBuilder gsonbuilder = new GsonBuilder();
|
||||||
gsonbuilder.registerTypeHierarchyAdapter(ChatComponent.class, new ChatComponent.Serializer());
|
gsonbuilder.registerTypeHierarchyAdapter(ChatComponent.class, new ChatComponent.Serializer());
|
||||||
gsonbuilder.registerTypeHierarchyAdapter(ChatStyle.class, new ChatStyle.Serializer());
|
gsonbuilder.registerTypeHierarchyAdapter(ChatStyle.class, new ChatStyle.Serializer());
|
||||||
gsonbuilder.registerTypeAdapterFactory(new EnumTypeAdapterFactory());
|
gsonbuilder.registerTypeAdapterFactory(new JsonEnumFactory());
|
||||||
GSON = gsonbuilder.create();
|
GSON = gsonbuilder.create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ public class ChatComponentScore extends ChatComponent {
|
||||||
private final String objective;
|
private final String objective;
|
||||||
private String value = "";
|
private String value = "";
|
||||||
|
|
||||||
public ChatComponentScore(String nameIn, String objectiveIn) {
|
public ChatComponentScore(String name, String objective) {
|
||||||
this.name = nameIn;
|
this.name = name;
|
||||||
this.objective = objectiveIn;
|
this.objective = objective;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -18,8 +18,8 @@ public class ChatComponentScore extends ChatComponent {
|
||||||
return this.objective;
|
return this.objective;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(String valueIn) {
|
public void setValue(String value) {
|
||||||
this.value = valueIn;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
|
|
|
@ -3,8 +3,8 @@ package proxy.util;
|
||||||
public class ChatComponentSelector extends ChatComponent {
|
public class ChatComponentSelector extends ChatComponent {
|
||||||
private final String selector;
|
private final String selector;
|
||||||
|
|
||||||
public ChatComponentSelector(String selectorIn) {
|
public ChatComponentSelector(String selector) {
|
||||||
this.selector = selectorIn;
|
this.selector = selector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSelector() {
|
public String getSelector() {
|
||||||
|
|
|
@ -3,8 +3,8 @@ package proxy.util;
|
||||||
public class ChatComponentText extends ChatComponent {
|
public class ChatComponentText extends ChatComponent {
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
public ChatComponentText(String msg) {
|
public ChatComponentText(String text) {
|
||||||
this.text = msg;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
|
|
|
@ -2,24 +2,24 @@ package proxy.util;
|
||||||
|
|
||||||
public class ChatComponentTranslation extends ChatComponent {
|
public class ChatComponentTranslation extends ChatComponent {
|
||||||
private final String key;
|
private final String key;
|
||||||
private final Object[] formatArgs;
|
private final Object[] args;
|
||||||
|
|
||||||
public ChatComponentTranslation(String translationKey, Object... args) {
|
public ChatComponentTranslation(String key, Object... args) {
|
||||||
this.key = translationKey;
|
this.key = key;
|
||||||
this.formatArgs = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return this.key;
|
return this.key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getFormatArgs() {
|
public Object[] getArgs() {
|
||||||
return this.formatArgs;
|
return this.args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder(this.key);
|
StringBuilder sb = new StringBuilder(this.key);
|
||||||
for(Object arg : this.formatArgs) {
|
for(Object arg : this.args) {
|
||||||
sb.append(' ').append(arg);
|
sb.append(' ').append(arg);
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
|
@ -84,11 +84,11 @@ public class ChatStyle
|
||||||
if (jsonobject1 != null)
|
if (jsonobject1 != null)
|
||||||
{
|
{
|
||||||
JsonPrimitive jsonprimitive = jsonobject1.getAsJsonPrimitive("action");
|
JsonPrimitive jsonprimitive = jsonobject1.getAsJsonPrimitive("action");
|
||||||
ClickEvent.Action clickevent$action = jsonprimitive == null ? null : ClickEvent.Action.getValueByCanonicalName(jsonprimitive.getAsString());
|
ClickAction clickevent$action = jsonprimitive == null ? null : ClickAction.getByName(jsonprimitive.getAsString());
|
||||||
JsonPrimitive jsonprimitive1 = jsonobject1.getAsJsonPrimitive("value");
|
JsonPrimitive jsonprimitive1 = jsonobject1.getAsJsonPrimitive("value");
|
||||||
String s = jsonprimitive1 == null ? null : jsonprimitive1.getAsString();
|
String s = jsonprimitive1 == null ? null : jsonprimitive1.getAsString();
|
||||||
|
|
||||||
if (clickevent$action != null && s != null && clickevent$action.shouldAllowInChat())
|
if (clickevent$action != null && s != null && clickevent$action.isSerialized())
|
||||||
{
|
{
|
||||||
chatstyle.chatClickEvent = new ClickEvent(clickevent$action, s);
|
chatstyle.chatClickEvent = new ClickEvent(clickevent$action, s);
|
||||||
}
|
}
|
||||||
|
@ -102,10 +102,10 @@ public class ChatStyle
|
||||||
if (jsonobject2 != null)
|
if (jsonobject2 != null)
|
||||||
{
|
{
|
||||||
JsonPrimitive jsonprimitive2 = jsonobject2.getAsJsonPrimitive("action");
|
JsonPrimitive jsonprimitive2 = jsonobject2.getAsJsonPrimitive("action");
|
||||||
HoverEvent.Action hoverevent$action = jsonprimitive2 == null ? null : HoverEvent.Action.getValueByCanonicalName(jsonprimitive2.getAsString());
|
HoverAction hoverevent$action = jsonprimitive2 == null ? null : HoverAction.getByName(jsonprimitive2.getAsString());
|
||||||
ChatComponent ichatcomponent = (ChatComponent)p_deserialize_3_.deserialize(jsonobject2.get("value"), ChatComponent.class);
|
ChatComponent ichatcomponent = (ChatComponent)p_deserialize_3_.deserialize(jsonobject2.get("value"), ChatComponent.class);
|
||||||
|
|
||||||
if (hoverevent$action != null && ichatcomponent != null && hoverevent$action.shouldAllowInChat())
|
if (hoverevent$action != null && ichatcomponent != null && hoverevent$action.isSerialized())
|
||||||
{
|
{
|
||||||
chatstyle.chatHoverEvent = new HoverEvent(hoverevent$action, ichatcomponent);
|
chatstyle.chatHoverEvent = new HoverEvent(hoverevent$action, ichatcomponent);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ public class ChatStyle
|
||||||
if (p_serialize_1_.chatClickEvent != null)
|
if (p_serialize_1_.chatClickEvent != null)
|
||||||
{
|
{
|
||||||
JsonObject jsonobject1 = new JsonObject();
|
JsonObject jsonobject1 = new JsonObject();
|
||||||
jsonobject1.addProperty("action", p_serialize_1_.chatClickEvent.getAction().getCanonicalName());
|
jsonobject1.addProperty("action", p_serialize_1_.chatClickEvent.getAction().getName());
|
||||||
jsonobject1.addProperty("value", p_serialize_1_.chatClickEvent.getValue());
|
jsonobject1.addProperty("value", p_serialize_1_.chatClickEvent.getValue());
|
||||||
jsonobject.add("clickEvent", jsonobject1);
|
jsonobject.add("clickEvent", jsonobject1);
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ public class ChatStyle
|
||||||
if (p_serialize_1_.chatHoverEvent != null)
|
if (p_serialize_1_.chatHoverEvent != null)
|
||||||
{
|
{
|
||||||
JsonObject jsonobject2 = new JsonObject();
|
JsonObject jsonobject2 = new JsonObject();
|
||||||
jsonobject2.addProperty("action", p_serialize_1_.chatHoverEvent.getAction().getCanonicalName());
|
jsonobject2.addProperty("action", p_serialize_1_.chatHoverEvent.getAction().getName());
|
||||||
jsonobject2.add("value", p_serialize_3_.serialize(p_serialize_1_.chatHoverEvent.getValue()));
|
jsonobject2.add("value", p_serialize_3_.serialize(p_serialize_1_.chatHoverEvent.getValue()));
|
||||||
jsonobject.add("hoverEvent", jsonobject2);
|
jsonobject.add("hoverEvent", jsonobject2);
|
||||||
}
|
}
|
||||||
|
|
42
proxy/src/main/java/proxy/util/ClickAction.java
Normal file
42
proxy/src/main/java/proxy/util/ClickAction.java
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
public enum ClickAction {
|
||||||
|
OPEN_URL("open_url", true),
|
||||||
|
OPEN_FILE("open_file", false),
|
||||||
|
RUN_COMMAND("run_command", true),
|
||||||
|
TWITCH_USER_INFO("twitch_user_info", false),
|
||||||
|
SUGGEST_COMMAND("suggest_command", true),
|
||||||
|
CHANGE_PAGE("change_page", true);
|
||||||
|
|
||||||
|
private static final Map<String, ClickAction> LOOKUP = Maps.newHashMap();
|
||||||
|
|
||||||
|
private final boolean serialize;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for(ClickAction action : values()) {
|
||||||
|
LOOKUP.put(action.name, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ClickAction getByName(String name) {
|
||||||
|
return LOOKUP.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ClickAction(String name, boolean serialize) {
|
||||||
|
this.name = name;
|
||||||
|
this.serialize = serialize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSerialized() {
|
||||||
|
return this.serialize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,59 +1,19 @@
|
||||||
package proxy.util;
|
package proxy.util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ClickEvent {
|
public class ClickEvent {
|
||||||
private final ClickEvent.Action action;
|
private final ClickAction action;
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
public ClickEvent(ClickEvent.Action theAction, String theValue) {
|
public ClickEvent(ClickAction action, String value) {
|
||||||
this.action = theAction;
|
this.action = action;
|
||||||
this.value = theValue;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClickEvent.Action getAction() {
|
public ClickAction getAction() {
|
||||||
return this.action;
|
return this.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Action {
|
|
||||||
OPEN_URL("open_url", true),
|
|
||||||
OPEN_FILE("open_file", false),
|
|
||||||
RUN_COMMAND("run_command", true),
|
|
||||||
TWITCH_USER_INFO("twitch_user_info", false),
|
|
||||||
SUGGEST_COMMAND("suggest_command", true),
|
|
||||||
CHANGE_PAGE("change_page", true);
|
|
||||||
|
|
||||||
private static final Map<String, ClickEvent.Action> nameMapping = new HashMap();
|
|
||||||
|
|
||||||
private final boolean allowedInChat;
|
|
||||||
private final String canonicalName;
|
|
||||||
|
|
||||||
private Action(String canonicalNameIn, boolean allowedInChatIn) {
|
|
||||||
this.canonicalName = canonicalNameIn;
|
|
||||||
this.allowedInChat = allowedInChatIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldAllowInChat() {
|
|
||||||
return this.allowedInChat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCanonicalName() {
|
|
||||||
return this.canonicalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ClickEvent.Action getValueByCanonicalName(String canonicalNameIn) {
|
|
||||||
return nameMapping.get(canonicalNameIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
for(ClickEvent.Action clickevent$action : values()) {
|
|
||||||
nameMapping.put(clickevent$action.getCanonicalName(), clickevent$action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,201 +0,0 @@
|
||||||
package proxy.util;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import proxy.network.PacketBuffer;
|
|
||||||
|
|
||||||
public class DataWatcher
|
|
||||||
{
|
|
||||||
private static class Vec3f {
|
|
||||||
protected final float x;
|
|
||||||
protected final float y;
|
|
||||||
protected final float z;
|
|
||||||
|
|
||||||
public Vec3f(float x, float y, float z) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getX() {
|
|
||||||
return this.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getY() {
|
|
||||||
return this.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getZ() {
|
|
||||||
return this.z;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeWatchedListToPacketBuffer(List<DataWatcher.WatchableObject> objectsList, PacketBuffer buffer) throws IOException
|
|
||||||
{
|
|
||||||
if (objectsList != null)
|
|
||||||
{
|
|
||||||
for (DataWatcher.WatchableObject datawatcher$watchableobject : objectsList)
|
|
||||||
{
|
|
||||||
writeWatchableObjectToPacketBuffer(buffer, datawatcher$watchableobject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.writeByte(127);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void writeWatchableObjectToPacketBuffer(PacketBuffer buffer, DataWatcher.WatchableObject object) throws IOException
|
|
||||||
{
|
|
||||||
int i = (object.getObjectType() << 5 | object.getDataValueId() & 31) & 255;
|
|
||||||
buffer.writeByte(i);
|
|
||||||
|
|
||||||
switch (object.getObjectType())
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
buffer.writeByte(((Byte)object.getObject()).byteValue());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
buffer.writeShort(((Short)object.getObject()).shortValue());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
buffer.writeInt(((Integer)object.getObject()).intValue());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
buffer.writeFloat(((Float)object.getObject()).floatValue());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
buffer.writeString((String)object.getObject());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
ItemStack itemstack = (ItemStack)object.getObject();
|
|
||||||
buffer.writeItemStackToBuffer(itemstack);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
BlockPos blockpos = (BlockPos)object.getObject();
|
|
||||||
buffer.writeInt(blockpos.getX());
|
|
||||||
buffer.writeInt(blockpos.getY());
|
|
||||||
buffer.writeInt(blockpos.getZ());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
Vec3f rotations = (Vec3f)object.getObject();
|
|
||||||
buffer.writeFloat(rotations.getX());
|
|
||||||
buffer.writeFloat(rotations.getY());
|
|
||||||
buffer.writeFloat(rotations.getZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<DataWatcher.WatchableObject> readWatchedListFromPacketBuffer(PacketBuffer buffer) throws IOException
|
|
||||||
{
|
|
||||||
List<DataWatcher.WatchableObject> list = null;
|
|
||||||
|
|
||||||
for (int i = buffer.readByte(); i != 127; i = buffer.readByte())
|
|
||||||
{
|
|
||||||
if (list == null)
|
|
||||||
{
|
|
||||||
list = Lists.<DataWatcher.WatchableObject>newArrayList();
|
|
||||||
}
|
|
||||||
|
|
||||||
int j = (i & 224) >> 5;
|
|
||||||
int k = i & 31;
|
|
||||||
DataWatcher.WatchableObject datawatcher$watchableobject = null;
|
|
||||||
|
|
||||||
switch (j)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, Byte.valueOf(buffer.readByte()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, Short.valueOf(buffer.readShort()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, Integer.valueOf(buffer.readInt()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, Float.valueOf(buffer.readFloat()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, buffer.readStringFromBuffer(32767));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, buffer.readItemStackFromBuffer());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
int l = buffer.readInt();
|
|
||||||
int i1 = buffer.readInt();
|
|
||||||
int j1 = buffer.readInt();
|
|
||||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, new BlockPos(l, i1, j1));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 7:
|
|
||||||
float f = buffer.readFloat();
|
|
||||||
float f1 = buffer.readFloat();
|
|
||||||
float f2 = buffer.readFloat();
|
|
||||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, new Vec3f(f, f1, f2));
|
|
||||||
}
|
|
||||||
|
|
||||||
list.add(datawatcher$watchableobject);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class WatchableObject
|
|
||||||
{
|
|
||||||
private final int objectType;
|
|
||||||
private final int dataValueId;
|
|
||||||
private Object watchedObject;
|
|
||||||
private boolean watched;
|
|
||||||
|
|
||||||
public WatchableObject(int type, int id, Object object)
|
|
||||||
{
|
|
||||||
this.dataValueId = id;
|
|
||||||
this.watchedObject = object;
|
|
||||||
this.objectType = type;
|
|
||||||
this.watched = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDataValueId()
|
|
||||||
{
|
|
||||||
return this.dataValueId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setObject(Object object)
|
|
||||||
{
|
|
||||||
this.watchedObject = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getObject()
|
|
||||||
{
|
|
||||||
return this.watchedObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getObjectType()
|
|
||||||
{
|
|
||||||
return this.objectType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWatched()
|
|
||||||
{
|
|
||||||
return this.watched;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWatched(boolean watched)
|
|
||||||
{
|
|
||||||
this.watched = watched;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
122
proxy/src/main/java/proxy/util/EntityData.java
Normal file
122
proxy/src/main/java/proxy/util/EntityData.java
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import proxy.network.PacketBuffer;
|
||||||
|
|
||||||
|
public class EntityData {
|
||||||
|
private final int type;
|
||||||
|
private final int id;
|
||||||
|
private final Object data;
|
||||||
|
|
||||||
|
private static void writeData(PacketBuffer buf, EntityData data) throws IOException {
|
||||||
|
int value = (data.getType() << 5 | data.getId() & 31) & 255;
|
||||||
|
buf.writeByte(value);
|
||||||
|
switch(data.getType()) {
|
||||||
|
case 0:
|
||||||
|
buf.writeByte(((Byte)data.getData()).byteValue());
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
buf.writeShort(((Short)data.getData()).shortValue());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
buf.writeInt(((Integer)data.getData()).intValue());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
buf.writeFloat(((Float)data.getData()).floatValue());
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
buf.writeString((String)data.getData());
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
Stack stack = (Stack)data.getData();
|
||||||
|
buf.writeStack(stack);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
Vec3 vec = (Vec3)data.getData();
|
||||||
|
buf.writeInt(vec.getX());
|
||||||
|
buf.writeInt(vec.getY());
|
||||||
|
buf.writeInt(vec.getZ());
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
Vec3f vecf = (Vec3f)data.getData();
|
||||||
|
buf.writeFloat(vecf.getX());
|
||||||
|
buf.writeFloat(vecf.getY());
|
||||||
|
buf.writeFloat(vecf.getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void writeData(List<EntityData> list, PacketBuffer buf) throws IOException {
|
||||||
|
if(list != null) {
|
||||||
|
for(EntityData data : list) {
|
||||||
|
EntityData.writeData(buf, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf.writeByte(127);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<EntityData> readData(PacketBuffer buf) throws IOException {
|
||||||
|
List<EntityData> list = null;
|
||||||
|
for(int value = buf.readByte(); value != 127; value = buf.readByte()) {
|
||||||
|
if(list == null)
|
||||||
|
list = Lists.<EntityData>newArrayList();
|
||||||
|
int type = (value & 224) >> 5;
|
||||||
|
int id = value & 31;
|
||||||
|
EntityData data = null;
|
||||||
|
switch(type) {
|
||||||
|
case 0:
|
||||||
|
data = new EntityData(type, id, Byte.valueOf(buf.readByte()));
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
data = new EntityData(type, id, Short.valueOf(buf.readShort()));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
data = new EntityData(type, id, Integer.valueOf(buf.readInt()));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
data = new EntityData(type, id, Float.valueOf(buf.readFloat()));
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
data = new EntityData(type, id, buf.readStringFromBuffer(32767));
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
data = new EntityData(type, id, buf.readStack());
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
int x = buf.readInt();
|
||||||
|
int y = buf.readInt();
|
||||||
|
int z = buf.readInt();
|
||||||
|
data = new EntityData(type, id, new Vec3(x, y, z));
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
float xf = buf.readFloat();
|
||||||
|
float yf = buf.readFloat();
|
||||||
|
float zf = buf.readFloat();
|
||||||
|
data = new EntityData(type, id, new Vec3f(xf, yf, zf));
|
||||||
|
}
|
||||||
|
list.add(data);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityData(int type, int id, Object data) {
|
||||||
|
this.type = type;
|
||||||
|
this.id = id;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,67 +0,0 @@
|
||||||
package proxy.util;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.TypeAdapter;
|
|
||||||
import com.google.gson.TypeAdapterFactory;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.google.gson.stream.JsonToken;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class EnumTypeAdapterFactory implements TypeAdapterFactory
|
|
||||||
{
|
|
||||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> token)
|
|
||||||
{
|
|
||||||
Class<T> oclass = (Class<T>)token.getRawType();
|
|
||||||
|
|
||||||
if (!oclass.isEnum())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
final Map<String, T> map = new HashMap();
|
|
||||||
|
|
||||||
for (T t : oclass.getEnumConstants())
|
|
||||||
{
|
|
||||||
map.put(this.func_151232_a(t), t);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new TypeAdapter<T>()
|
|
||||||
{
|
|
||||||
public void write(JsonWriter p_write_1_, T p_write_2_) throws IOException
|
|
||||||
{
|
|
||||||
if (p_write_2_ == null)
|
|
||||||
{
|
|
||||||
p_write_1_.nullValue();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p_write_1_.value(EnumTypeAdapterFactory.this.func_151232_a(p_write_2_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public T read(JsonReader p_read_1_) throws IOException
|
|
||||||
{
|
|
||||||
if (p_read_1_.peek() == JsonToken.NULL)
|
|
||||||
{
|
|
||||||
p_read_1_.nextNull();
|
|
||||||
return (T)null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (T)map.get(p_read_1_.nextString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String func_151232_a(Object p_151232_1_)
|
|
||||||
{
|
|
||||||
return p_151232_1_ instanceof Enum ? ((Enum)p_151232_1_).name().toLowerCase(Locale.US) : p_151232_1_.toString().toLowerCase(Locale.US);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
package proxy.util;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class GameProfile {
|
|
||||||
private final UUID id;
|
|
||||||
private final String name;
|
|
||||||
private final PropertyMap properties = new PropertyMap();
|
|
||||||
private boolean legacy;
|
|
||||||
|
|
||||||
public GameProfile(UUID id, String name) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PropertyMap getProperties() {
|
|
||||||
return this.properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if(this == o) {
|
|
||||||
return true;
|
|
||||||
} else if(o != null && this.getClass() == o.getClass()) {
|
|
||||||
GameProfile that = (GameProfile)o;
|
|
||||||
if(this.id != null) {
|
|
||||||
if(!this.id.equals(that.id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if(that.id != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.name != null) {
|
|
||||||
if(!this.name.equals(that.name)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if(that.name != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
int result = this.id != null?this.id.hashCode():0;
|
|
||||||
result = 31 * result + (this.name != null?this.name.hashCode():0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLegacy() {
|
|
||||||
return this.legacy;
|
|
||||||
}
|
|
||||||
}
|
|
40
proxy/src/main/java/proxy/util/HoverAction.java
Normal file
40
proxy/src/main/java/proxy/util/HoverAction.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
public enum HoverAction {
|
||||||
|
SHOW_TEXT("show_text", true),
|
||||||
|
SHOW_ACHIEVEMENT("show_achievement", true),
|
||||||
|
SHOW_ITEM("show_item", true),
|
||||||
|
SHOW_ENTITY("show_entity", true);
|
||||||
|
|
||||||
|
private static final Map<String, HoverAction> LOOKUP = Maps.newHashMap();
|
||||||
|
|
||||||
|
private final boolean serialize;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
static {
|
||||||
|
for(HoverAction action : values()) {
|
||||||
|
LOOKUP.put(action.name, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HoverAction getByName(String name) {
|
||||||
|
return LOOKUP.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private HoverAction(String name, boolean serialize) {
|
||||||
|
this.name = name;
|
||||||
|
this.serialize = serialize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSerialized() {
|
||||||
|
return this.serialize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,57 +1,19 @@
|
||||||
package proxy.util;
|
package proxy.util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class HoverEvent {
|
public class HoverEvent {
|
||||||
private final HoverEvent.Action action;
|
private final HoverAction action;
|
||||||
private final ChatComponent value;
|
private final ChatComponent value;
|
||||||
|
|
||||||
public HoverEvent(HoverEvent.Action actionIn, ChatComponent valueIn) {
|
public HoverEvent(HoverAction action, ChatComponent value) {
|
||||||
this.action = actionIn;
|
this.action = action;
|
||||||
this.value = valueIn;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HoverEvent.Action getAction() {
|
public HoverAction getAction() {
|
||||||
return this.action;
|
return this.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatComponent getValue() {
|
public ChatComponent getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Action {
|
|
||||||
SHOW_TEXT("show_text", true),
|
|
||||||
SHOW_ACHIEVEMENT("show_achievement", true),
|
|
||||||
SHOW_ITEM("show_item", true),
|
|
||||||
SHOW_ENTITY("show_entity", true);
|
|
||||||
|
|
||||||
private static final Map<String, HoverEvent.Action> nameMapping = new HashMap();
|
|
||||||
|
|
||||||
private final boolean allowedInChat;
|
|
||||||
private final String canonicalName;
|
|
||||||
|
|
||||||
private Action(String canonicalNameIn, boolean allowedInChatIn) {
|
|
||||||
this.canonicalName = canonicalNameIn;
|
|
||||||
this.allowedInChat = allowedInChatIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldAllowInChat() {
|
|
||||||
return this.allowedInChat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCanonicalName() {
|
|
||||||
return this.canonicalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HoverEvent.Action getValueByCanonicalName(String canonicalNameIn) {
|
|
||||||
return nameMapping.get(canonicalNameIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
for(HoverEvent.Action hoverevent$action : values()) {
|
|
||||||
nameMapping.put(hoverevent$action.getCanonicalName(), hoverevent$action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
49
proxy/src/main/java/proxy/util/JsonEnumFactory.java
Executable file
49
proxy/src/main/java/proxy/util/JsonEnumFactory.java
Executable file
|
@ -0,0 +1,49 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.TypeAdapterFactory;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.gson.stream.JsonToken;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class JsonEnumFactory implements TypeAdapterFactory {
|
||||||
|
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||||
|
Class<T> clazz = (Class<T>)type.getRawType();
|
||||||
|
if(!clazz.isEnum())
|
||||||
|
return null;
|
||||||
|
final Map<String, T> map = Maps.newHashMap();
|
||||||
|
for(T t : clazz.getEnumConstants()) {
|
||||||
|
map.put(this.formatName(t), t);
|
||||||
|
}
|
||||||
|
return new TypeAdapter<T>() {
|
||||||
|
public void write(JsonWriter writer, T data) throws IOException {
|
||||||
|
if(data == null) {
|
||||||
|
writer.nullValue();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
writer.value(JsonEnumFactory.this.formatName(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T read(JsonReader reader) throws IOException {
|
||||||
|
if(reader.peek() == JsonToken.NULL) {
|
||||||
|
reader.nextNull();
|
||||||
|
return (T)null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (T)map.get(reader.nextString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String formatName(Object data) {
|
||||||
|
return data instanceof Enum ? ((Enum)data).name().toLowerCase(Locale.US) : data.toString().toLowerCase(Locale.US);
|
||||||
|
}
|
||||||
|
}
|
78
proxy/src/main/java/proxy/util/PlayerInfo.java
Normal file
78
proxy/src/main/java/proxy/util/PlayerInfo.java
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonSerializationContext;
|
||||||
|
import com.google.gson.JsonSerializer;
|
||||||
|
|
||||||
|
public class PlayerInfo {
|
||||||
|
private final int capacity;
|
||||||
|
private final int online;
|
||||||
|
private Profile[] list;
|
||||||
|
|
||||||
|
public PlayerInfo(int capacity, int online) {
|
||||||
|
this.capacity = capacity;
|
||||||
|
this.online = online;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCapacity() {
|
||||||
|
return this.capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOnline() {
|
||||||
|
return this.online;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Profile[] getList() {
|
||||||
|
return this.list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(Profile[] list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Serializer implements JsonDeserializer<PlayerInfo>, JsonSerializer<PlayerInfo> {
|
||||||
|
public PlayerInfo deserialize(JsonElement elem, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
JsonObject obj = JsonUtils.getJsonObject(elem, "players");
|
||||||
|
PlayerInfo info = new PlayerInfo(JsonUtils.getInt(obj, "max"), JsonUtils.getInt(obj, "online"));
|
||||||
|
if(JsonUtils.isJsonArray(obj, "sample")) {
|
||||||
|
JsonArray arr = JsonUtils.getJsonArray(obj, "sample");
|
||||||
|
if(arr.size() > 0) {
|
||||||
|
Profile[] list = new Profile[arr.size()];
|
||||||
|
for(int z = 0; z < list.length; z++) {
|
||||||
|
JsonObject profile = JsonUtils.getJsonObject(arr.get(z), "player[" + z + "]");
|
||||||
|
String id = JsonUtils.getString(profile, "id");
|
||||||
|
list[z] = new Profile(UUID.fromString(id), JsonUtils.getString(profile, "name"));
|
||||||
|
}
|
||||||
|
info.setList(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement serialize(PlayerInfo info, Type type, JsonSerializationContext context) {
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
obj.addProperty("max", info.getCapacity());
|
||||||
|
obj.addProperty("online", info.getOnline());
|
||||||
|
if(info.getList() != null && info.getList().length > 0) {
|
||||||
|
JsonArray arr = new JsonArray();
|
||||||
|
for(int z = 0; z < info.getList().length; z++) {
|
||||||
|
JsonObject profile = new JsonObject();
|
||||||
|
UUID id = info.getList()[z].getId();
|
||||||
|
profile.addProperty("id", id == null ? "" : id.toString());
|
||||||
|
profile.addProperty("name", info.getList()[z].getName());
|
||||||
|
arr.add(profile);
|
||||||
|
}
|
||||||
|
obj.add("sample", arr);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
proxy/src/main/java/proxy/util/Profile.java
Normal file
27
proxy/src/main/java/proxy/util/Profile.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Profile {
|
||||||
|
private final UUID id;
|
||||||
|
private final String name;
|
||||||
|
private final PropertyMap properties = new PropertyMap();
|
||||||
|
private boolean legacy;
|
||||||
|
|
||||||
|
public Profile(UUID id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyMap getProperties() {
|
||||||
|
return this.properties;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ public class Property {
|
||||||
private final String signature;
|
private final String signature;
|
||||||
|
|
||||||
public Property(String value, String name) {
|
public Property(String value, String name) {
|
||||||
this(value, name, (String)null);
|
this(value, name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Property(String name, String value, String signature) {
|
public Property(String name, String value, String signature) {
|
||||||
|
@ -26,8 +26,4 @@ public class Property {
|
||||||
public String getSignature() {
|
public String getSignature() {
|
||||||
return this.signature;
|
return this.signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSignature() {
|
|
||||||
return this.signature != null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,51 +22,46 @@ public class PropertyMap extends ForwardingMultimap<String, Property> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Serializer implements JsonSerializer<PropertyMap>, JsonDeserializer<PropertyMap> {
|
public static class Serializer implements JsonSerializer<PropertyMap>, JsonDeserializer<PropertyMap> {
|
||||||
public PropertyMap deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public PropertyMap deserialize(JsonElement elem, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||||
PropertyMap result = new PropertyMap();
|
PropertyMap properties = new PropertyMap();
|
||||||
if(json instanceof JsonObject) {
|
if(elem instanceof JsonObject) {
|
||||||
JsonObject object = (JsonObject)json;
|
JsonObject obj = (JsonObject)elem;
|
||||||
|
for(Entry<String, JsonElement> entry : obj.entrySet()) {
|
||||||
for(Entry<String, JsonElement> entry : object.entrySet()) {
|
|
||||||
if(entry.getValue() instanceof JsonArray) {
|
if(entry.getValue() instanceof JsonArray) {
|
||||||
for(JsonElement element : (JsonArray)entry.getValue()) {
|
for(JsonElement element : (JsonArray)entry.getValue()) {
|
||||||
result.put(entry.getKey(), new Property((String)entry.getKey(), element.getAsString()));
|
properties.put(entry.getKey(), new Property(entry.getKey(), element.getAsString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(json instanceof JsonArray) {
|
}
|
||||||
for(JsonElement element : (JsonArray)json) {
|
else if(elem instanceof JsonArray) {
|
||||||
|
for(JsonElement element : (JsonArray)elem) {
|
||||||
if(element instanceof JsonObject) {
|
if(element instanceof JsonObject) {
|
||||||
JsonObject object = (JsonObject)element;
|
JsonObject obj = (JsonObject)element;
|
||||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
String name = obj.getAsJsonPrimitive("name").getAsString();
|
||||||
String value = object.getAsJsonPrimitive("value").getAsString();
|
String value = obj.getAsJsonPrimitive("value").getAsString();
|
||||||
if(object.has("signature")) {
|
if(obj.has("signature"))
|
||||||
result.put(name, new Property(name, value, object.getAsJsonPrimitive("signature").getAsString()));
|
properties.put(name, new Property(name, value, obj.getAsJsonPrimitive("signature").getAsString()));
|
||||||
} else {
|
else
|
||||||
result.put(name, new Property(name, value));
|
properties.put(name, new Property(name, value));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonElement serialize(PropertyMap src, Type typeOfSrc, JsonSerializationContext context) {
|
public JsonElement serialize(PropertyMap properties, Type type, JsonSerializationContext context) {
|
||||||
JsonArray result = new JsonArray();
|
JsonArray arr = new JsonArray();
|
||||||
|
for(Property property : properties.values()) {
|
||||||
for(Property property : src.values()) {
|
JsonObject obj = new JsonObject();
|
||||||
JsonObject object = new JsonObject();
|
obj.addProperty("name", property.getName());
|
||||||
object.addProperty("name", property.getName());
|
obj.addProperty("value", property.getValue());
|
||||||
object.addProperty("value", property.getValue());
|
if(property.getSignature() != null)
|
||||||
if(property.hasSignature()) {
|
obj.addProperty("signature", property.getSignature());
|
||||||
object.addProperty("signature", property.getSignature());
|
arr.add(obj);
|
||||||
}
|
}
|
||||||
|
return arr;
|
||||||
result.add(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
78
proxy/src/main/java/proxy/util/ServerInfo.java
Executable file
78
proxy/src/main/java/proxy/util/ServerInfo.java
Executable file
|
@ -0,0 +1,78 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonSerializationContext;
|
||||||
|
import com.google.gson.JsonSerializer;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
public class ServerInfo {
|
||||||
|
private ChatComponent motd;
|
||||||
|
private PlayerInfo info;
|
||||||
|
private VersionId version;
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
public ChatComponent getMotd() {
|
||||||
|
return this.motd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMotd(ChatComponent motd) {
|
||||||
|
this.motd = motd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerInfo getInfo() {
|
||||||
|
return this.info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInfo(PlayerInfo info) {
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VersionId getVersion() {
|
||||||
|
return this.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(VersionId version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIcon(String icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIcon() {
|
||||||
|
return this.icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Serializer implements JsonDeserializer<ServerInfo>, JsonSerializer<ServerInfo> {
|
||||||
|
public ServerInfo deserialize(JsonElement elem, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
JsonObject obj = JsonUtils.getJsonObject(elem, "status");
|
||||||
|
ServerInfo status = new ServerInfo();
|
||||||
|
if(obj.has("description"))
|
||||||
|
status.setMotd((ChatComponent)context.deserialize(obj.get("description"), ChatComponent.class));
|
||||||
|
if(obj.has("players"))
|
||||||
|
status.setInfo((PlayerInfo)context.deserialize(obj.get("players"), PlayerInfo.class));
|
||||||
|
if(obj.has("version"))
|
||||||
|
status.setVersion((VersionId)context.deserialize(obj.get("version"), VersionId.class));
|
||||||
|
if(obj.has("favicon"))
|
||||||
|
status.setIcon(JsonUtils.getString(obj, "favicon"));
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement serialize(ServerInfo status, Type type, JsonSerializationContext context) {
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
if(status.getMotd() != null)
|
||||||
|
obj.add("description", context.serialize(status.getMotd()));
|
||||||
|
if(status.getInfo() != null)
|
||||||
|
obj.add("players", context.serialize(status.getInfo()));
|
||||||
|
if(status.getVersion() != null)
|
||||||
|
obj.add("version", context.serialize(status.getVersion()));
|
||||||
|
if(status.getIcon() != null)
|
||||||
|
obj.addProperty("favicon", status.getIcon());
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,23 +2,19 @@ package proxy.util;
|
||||||
|
|
||||||
import proxy.nbt.NBTTagCompound;
|
import proxy.nbt.NBTTagCompound;
|
||||||
|
|
||||||
public final class ItemStack {
|
public final class Stack {
|
||||||
private final short id;
|
private final short id;
|
||||||
private final byte size;
|
private final byte size;
|
||||||
private final short meta;
|
private final short meta;
|
||||||
private final NBTTagCompound tag;
|
private final NBTTagCompound tag;
|
||||||
|
|
||||||
public ItemStack(short id, byte size, short meta, NBTTagCompound tag) {
|
public Stack(short id, byte size, short meta, NBTTagCompound tag) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.meta = meta;
|
this.meta = meta;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack copy() {
|
|
||||||
return new ItemStack(this.id, this.size, this.meta, (NBTTagCompound)this.tag.copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getId() {
|
public short getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
35
proxy/src/main/java/proxy/util/Vec3.java
Executable file
35
proxy/src/main/java/proxy/util/Vec3.java
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
public class Vec3 {
|
||||||
|
private final int x;
|
||||||
|
private final int y;
|
||||||
|
private final int z;
|
||||||
|
|
||||||
|
public Vec3(int x, int y, int z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3(long data) {
|
||||||
|
this.x = (int)(data << 64 - 38 - 26 >> 64 - 26);
|
||||||
|
this.y = (int)(data << 64 - 26 - 12 >> 64 - 12);
|
||||||
|
this.z = (int)(data << 64 - 26 >> 64 - 26);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getX() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getY() {
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getZ() {
|
||||||
|
return this.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getData() {
|
||||||
|
return ((long)this.getX() & 0x3ffffff) << 38 | ((long)this.getY() & 0xfff) << 26 | ((long)this.getZ() & 0x3ffffff) << 0;
|
||||||
|
}
|
||||||
|
}
|
25
proxy/src/main/java/proxy/util/Vec3f.java
Normal file
25
proxy/src/main/java/proxy/util/Vec3f.java
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
public class Vec3f {
|
||||||
|
private final float x;
|
||||||
|
private final float y;
|
||||||
|
private final float z;
|
||||||
|
|
||||||
|
public Vec3f(float x, float y, float z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getX() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getY() {
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getZ() {
|
||||||
|
return this.z;
|
||||||
|
}
|
||||||
|
}
|
43
proxy/src/main/java/proxy/util/VersionId.java
Normal file
43
proxy/src/main/java/proxy/util/VersionId.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package proxy.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonSerializationContext;
|
||||||
|
import com.google.gson.JsonSerializer;
|
||||||
|
|
||||||
|
public class VersionId {
|
||||||
|
private final String name;
|
||||||
|
private final int protocol;
|
||||||
|
|
||||||
|
public VersionId(String name, int protocol) {
|
||||||
|
this.name = name;
|
||||||
|
this.protocol = protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProtocol() {
|
||||||
|
return this.protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Serializer implements JsonDeserializer<VersionId>, JsonSerializer<VersionId> {
|
||||||
|
public VersionId deserialize(JsonElement elem, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
JsonObject obj = JsonUtils.getJsonObject(elem, "version");
|
||||||
|
return new VersionId(JsonUtils.getString(obj, "name"), JsonUtils.getInt(obj, "protocol"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement serialize(VersionId version, Type type, JsonSerializationContext context) {
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
obj.addProperty("name", version.getName());
|
||||||
|
obj.addProperty("protocol", (Number)Integer.valueOf(version.getProtocol()));
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue