geforkt von Mirrors/Velocity
Some minor touch-ups
Dieser Commit ist enthalten in:
Ursprung
d37b6a361c
Commit
fca73bae67
@ -18,6 +18,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import io.netty.handler.codec.DecoderException;
|
||||||
|
import io.netty.handler.codec.EncoderException;
|
||||||
import net.kyori.nbt.CompoundTag;
|
import net.kyori.nbt.CompoundTag;
|
||||||
|
|
||||||
public enum ProtocolUtils {
|
public enum ProtocolUtils {
|
||||||
@ -196,22 +198,21 @@ public enum ProtocolUtils {
|
|||||||
int indexBefore = buf.readerIndex();
|
int indexBefore = buf.readerIndex();
|
||||||
byte startType = buf.readByte();
|
byte startType = buf.readByte();
|
||||||
if (startType == 0) {
|
if (startType == 0) {
|
||||||
return null;
|
throw new DecoderException("Invalid NBT start-type (end/empty)");
|
||||||
} else {
|
}
|
||||||
buf.readerIndex(indexBefore);
|
buf.readerIndex(indexBefore);
|
||||||
try {
|
try {
|
||||||
DataInput input = new ByteBufInputStream(buf);
|
DataInput input = new ByteBufInputStream(buf);
|
||||||
byte type = input.readByte();
|
byte type = input.readByte();
|
||||||
if (type != 10) {
|
if (type != 10) {
|
||||||
return null;
|
throw new DecoderException("NBTTag is not a CompoundTag");
|
||||||
}
|
|
||||||
input.readUTF();
|
|
||||||
CompoundTag ret = new CompoundTag();
|
|
||||||
ret.read(input, 0);
|
|
||||||
return ret;
|
|
||||||
} catch (IOException e) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
input.readUTF(); // Head-padding
|
||||||
|
CompoundTag compoundTag = new CompoundTag();
|
||||||
|
compoundTag.read(input, 0);
|
||||||
|
return compoundTag;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new DecoderException("Unable to decode NBT CompoundTag at " + indexBefore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,15 +224,15 @@ public enum ProtocolUtils {
|
|||||||
public static void writeCompoundTag(ByteBuf buf, CompoundTag compoundTag) {
|
public static void writeCompoundTag(ByteBuf buf, CompoundTag compoundTag) {
|
||||||
if (compoundTag == null) {
|
if (compoundTag == null) {
|
||||||
buf.writeByte(0);
|
buf.writeByte(0);
|
||||||
} else {
|
return;
|
||||||
try {
|
}
|
||||||
DataOutput output = new ByteBufOutputStream(buf);
|
try {
|
||||||
output.writeByte(10);
|
DataOutput output = new ByteBufOutputStream(buf);
|
||||||
output.writeUTF("");
|
output.writeByte(10); // Type 10 - CompoundTag
|
||||||
compoundTag.write(output);
|
output.writeUTF(""); // Head-padding
|
||||||
} catch (IOException e) {
|
compoundTag.write(output);
|
||||||
e.printStackTrace();
|
} catch (IOException e) {
|
||||||
}
|
throw new EncoderException("Unable to encode NBT CompoundTag");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class Chat implements MinecraftPacket {
|
|||||||
|
|
||||||
private @Nullable String message;
|
private @Nullable String message;
|
||||||
private byte type;
|
private byte type;
|
||||||
private UUID sender;
|
private @Nullable UUID sender;
|
||||||
|
|
||||||
public Chat() {
|
public Chat() {
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ public class Chat implements MinecraftPacket {
|
|||||||
message = ProtocolUtils.readString(buf);
|
message = ProtocolUtils.readString(buf);
|
||||||
if (direction == ProtocolUtils.Direction.CLIENTBOUND) {
|
if (direction == ProtocolUtils.Direction.CLIENTBOUND) {
|
||||||
type = buf.readByte();
|
type = buf.readByte();
|
||||||
if(version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
||||||
sender = ProtocolUtils.readUuid(buf);
|
sender = ProtocolUtils.readUuid(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ public class Chat implements MinecraftPacket {
|
|||||||
if (direction == ProtocolUtils.Direction.CLIENTBOUND) {
|
if (direction == ProtocolUtils.Direction.CLIENTBOUND) {
|
||||||
buf.writeByte(type);
|
buf.writeByte(type);
|
||||||
if(version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
if(version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
||||||
ProtocolUtils.writeUuid(buf, sender == null ? new UUID(0,0) : sender);
|
ProtocolUtils.writeUuid(buf, sender == null ? EMPTY_SENDER : sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,14 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
private short difficulty;
|
private short difficulty;
|
||||||
private short maxPlayers;
|
private short maxPlayers;
|
||||||
private @Nullable String levelType;
|
private @Nullable String levelType;
|
||||||
private int viewDistance; //1.14+
|
private int viewDistance; // 1.14+
|
||||||
private boolean reducedDebugInfo;
|
private boolean reducedDebugInfo;
|
||||||
private boolean showRespawnScreen;
|
private boolean showRespawnScreen;
|
||||||
private boolean shouldKeepPlayerData;
|
private boolean shouldKeepPlayerData; // 1.16+
|
||||||
private boolean isDebug;
|
private boolean isDebug; // 1.16+
|
||||||
private boolean isFlat;
|
private boolean isFlat; // 1.16+
|
||||||
private String dimensionRegistryName;
|
private String dimensionRegistryName; // 1.16+
|
||||||
private CompoundTag dimensionRegistry;
|
private CompoundTag dimensionRegistry; // 1.16+
|
||||||
|
|
||||||
public int getEntityId() {
|
public int getEntityId() {
|
||||||
return entityId;
|
return entityId;
|
||||||
@ -149,6 +149,10 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
+ ", levelType='" + levelType + '\''
|
+ ", levelType='" + levelType + '\''
|
||||||
+ ", viewDistance=" + viewDistance
|
+ ", viewDistance=" + viewDistance
|
||||||
+ ", reducedDebugInfo=" + reducedDebugInfo
|
+ ", reducedDebugInfo=" + reducedDebugInfo
|
||||||
|
+ ", shouldKeepPlayerData=" + shouldKeepPlayerData
|
||||||
|
+ ", isDebug=" + isDebug
|
||||||
|
+ ", isFlat='" + isFlat
|
||||||
|
+ ", dimensionRegistryName='" + dimensionRegistryName + '\''
|
||||||
+ '}';
|
+ '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,12 +163,10 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
||||||
this.dimensionRegistry = ProtocolUtils.readCompoundTag(buf);
|
this.dimensionRegistry = ProtocolUtils.readCompoundTag(buf);
|
||||||
this.dimensionRegistryName = ProtocolUtils.readString(buf);
|
this.dimensionRegistryName = ProtocolUtils.readString(buf);
|
||||||
|
} else if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) {
|
||||||
|
this.dimension = buf.readInt();
|
||||||
} else {
|
} else {
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) {
|
this.dimension = buf.readByte();
|
||||||
this.dimension = buf.readInt();
|
|
||||||
} else {
|
|
||||||
this.dimension = buf.readByte();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) {
|
||||||
this.difficulty = buf.readUnsignedByte();
|
this.difficulty = buf.readUnsignedByte();
|
||||||
@ -198,12 +200,10 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
||||||
ProtocolUtils.writeCompoundTag(buf, dimensionRegistry);
|
ProtocolUtils.writeCompoundTag(buf, dimensionRegistry);
|
||||||
ProtocolUtils.writeString(buf, dimensionRegistryName);
|
ProtocolUtils.writeString(buf, dimensionRegistryName);
|
||||||
|
} else if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) {
|
||||||
|
buf.writeInt(dimension);
|
||||||
} else {
|
} else {
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_9_1) >= 0) {
|
buf.writeByte(dimension);
|
||||||
buf.writeInt(dimension);
|
|
||||||
} else {
|
|
||||||
buf.writeByte(dimension);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13_2) <= 0) {
|
||||||
buf.writeByte(difficulty);
|
buf.writeByte(difficulty);
|
||||||
|
@ -13,10 +13,10 @@ public class Respawn implements MinecraftPacket {
|
|||||||
private short difficulty;
|
private short difficulty;
|
||||||
private short gamemode;
|
private short gamemode;
|
||||||
private String levelType = "";
|
private String levelType = "";
|
||||||
private boolean shouldKeepPlayerData;
|
private boolean shouldKeepPlayerData; // 1.16+
|
||||||
private boolean isDebug;
|
private boolean isDebug; // 1.16+
|
||||||
private boolean isFlat;
|
private boolean isFlat; // 1.16+
|
||||||
private String dimensionRegistryName;
|
private String dimensionRegistryName; // 1.16+
|
||||||
|
|
||||||
public Respawn() {
|
public Respawn() {
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,6 @@ public class ArgumentPropertyRegistry {
|
|||||||
dummy("minecraft:int_range", DUMMY);
|
dummy("minecraft:int_range", DUMMY);
|
||||||
dummy("minecraft:float_range", DUMMY);
|
dummy("minecraft:float_range", DUMMY);
|
||||||
dummy("minecraft:time", DUMMY); // added in 1.14
|
dummy("minecraft:time", DUMMY); // added in 1.14
|
||||||
dummy("minecraft:uuid", DUMMY);
|
dummy("minecraft:uuid", DUMMY); // added in 1.16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren