mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-16 13:11:40 +01:00
Small packet cleanup, removed LevelType, new RawJsonMessage
This commit is contained in:
parent
f4716b7e8c
commit
ea80d56bd0
@ -55,4 +55,20 @@ public abstract class JsonMessage {
|
||||
|
||||
return compiledJson;
|
||||
}
|
||||
|
||||
public static class RawJsonMessage extends JsonMessage {
|
||||
|
||||
private JsonObject jsonObject;
|
||||
|
||||
public RawJsonMessage(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JsonObject getJsonObject() {
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,14 +17,14 @@ public class ByteArrayData extends DataType<byte[]> {
|
||||
return decodeByteArray(reader);
|
||||
}
|
||||
|
||||
public static void encodeByteArray(BinaryWriter binaryWriter, byte[] value) {
|
||||
public static void encodeByteArray(@NotNull BinaryWriter binaryWriter, @NotNull byte[] value) {
|
||||
binaryWriter.writeVarInt(value.length);
|
||||
for (byte val : value) {
|
||||
binaryWriter.writeByte(val);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] decodeByteArray(BinaryReader binaryReader) {
|
||||
public static byte[] decodeByteArray(@NotNull BinaryReader binaryReader) {
|
||||
byte[] array = new byte[binaryReader.readVarInt()];
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = binaryReader.readByte();
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents the game mode of a player.
|
||||
* <p>
|
||||
@ -33,4 +35,14 @@ public enum GameMode {
|
||||
public boolean canTakeDamage() {
|
||||
return canTakeDamage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GameMode fromId(byte id) {
|
||||
for (GameMode gameMode : values()) {
|
||||
if (gameMode.id == id) {
|
||||
return gameMode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ import net.minestom.server.utils.chunk.ChunkCallback;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import net.minestom.server.world.LevelType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -93,7 +92,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
|
||||
protected boolean onGround;
|
||||
private final ConcurrentLinkedQueue<ClientPlayPacket> packets = new ConcurrentLinkedQueue<>();
|
||||
private final LevelType levelType;
|
||||
private final boolean levelFlat;
|
||||
private final PlayerSettings settings;
|
||||
private float exp;
|
||||
private int level;
|
||||
@ -170,7 +169,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
|
||||
this.gameMode = GameMode.SURVIVAL;
|
||||
this.dimensionType = DimensionType.OVERWORLD;
|
||||
this.levelType = LevelType.FLAT;
|
||||
this.levelFlat = true;
|
||||
refreshPosition(0, 0, 0);
|
||||
|
||||
// Used to cache the breaker for single custom block breaking
|
||||
@ -194,9 +193,9 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
joinGamePacket.gameMode = gameMode;
|
||||
joinGamePacket.dimensionType = dimensionType;
|
||||
joinGamePacket.maxPlayers = 0; // Unused
|
||||
joinGamePacket.levelType = levelType;
|
||||
joinGamePacket.viewDistance = MinecraftServer.getChunkViewDistance();
|
||||
joinGamePacket.reducedDebugInfo = false;
|
||||
joinGamePacket.isFlat = levelFlat;
|
||||
playerConnection.sendPacket(joinGamePacket);
|
||||
|
||||
// Server brand name
|
||||
@ -507,7 +506,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
RespawnPacket respawnPacket = new RespawnPacket();
|
||||
respawnPacket.dimensionType = getDimensionType();
|
||||
respawnPacket.gameMode = getGameMode();
|
||||
respawnPacket.levelType = getLevelType();
|
||||
respawnPacket.isFlat = levelFlat;
|
||||
getPlayerConnection().sendPacket(respawnPacket);
|
||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this);
|
||||
callEvent(PlayerRespawnEvent.class, respawnEvent);
|
||||
@ -1075,7 +1074,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
RespawnPacket respawnPacket = new RespawnPacket();
|
||||
respawnPacket.dimensionType = getDimensionType();
|
||||
respawnPacket.gameMode = getGameMode();
|
||||
respawnPacket.levelType = getLevelType();
|
||||
respawnPacket.isFlat = levelFlat;
|
||||
|
||||
playerConnection.sendPacket(removePlayerPacket);
|
||||
playerConnection.sendPacket(destroyEntitiesPacket);
|
||||
@ -1513,7 +1512,7 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
RespawnPacket respawnPacket = new RespawnPacket();
|
||||
respawnPacket.dimensionType = dimensionType;
|
||||
respawnPacket.gameMode = gameMode;
|
||||
respawnPacket.levelType = levelType;
|
||||
respawnPacket.isFlat = levelFlat;
|
||||
playerConnection.sendPacket(respawnPacket);
|
||||
}
|
||||
|
||||
@ -1539,10 +1538,6 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
kick(ColoredText.of(message));
|
||||
}
|
||||
|
||||
public LevelType getLevelType() {
|
||||
return levelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the current held slot for the player.
|
||||
*
|
||||
|
@ -29,6 +29,10 @@ import java.util.Set;
|
||||
* There should be only one instance of this class for each custom block type,
|
||||
* every individual blocks will execute the callbacks present there. Each of which contains the
|
||||
* custom block position and the instance concerned.
|
||||
* <p>
|
||||
* Each block in a chunk contains 2 id, the block state id (only visual) and a custom block id corresponding to
|
||||
* {@link CustomBlock#getCustomBlockId()}. A custom block is responsible for the blocks tick, the custom break time feature,
|
||||
* and some useful callbacks.
|
||||
*/
|
||||
public abstract class CustomBlock {
|
||||
|
||||
|
@ -2,18 +2,20 @@ package net.minestom.server.network.packet.server;
|
||||
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.binary.Writeable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a packet which can be sent to a player using {@link PlayerConnection#sendPacket(ServerPacket)}.
|
||||
*/
|
||||
public interface ServerPacket {
|
||||
public interface ServerPacket extends Writeable {
|
||||
|
||||
/**
|
||||
* Writes the packet to a {@link BinaryWriter}.
|
||||
*
|
||||
* @param writer the writer to write the packet to.
|
||||
*/
|
||||
void write(BinaryWriter writer);
|
||||
void write(@NotNull BinaryWriter writer);
|
||||
|
||||
/**
|
||||
* Gets the id of this packet.
|
||||
|
@ -2,13 +2,14 @@ package net.minestom.server.network.packet.server.handshake;
|
||||
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ResponsePacket implements ServerPacket {
|
||||
|
||||
public String jsonResponse;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(jsonResponse);
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,14 @@ import net.minestom.server.data.type.array.ByteArrayData;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class EncryptionRequestPacket implements ServerPacket {
|
||||
|
||||
private byte[] nonce = new byte[4];
|
||||
public byte[] publicKey;
|
||||
public byte[] nonce = new byte[4];
|
||||
|
||||
public EncryptionRequestPacket(PlayerConnection connection) {
|
||||
ThreadLocalRandom.current().nextBytes(nonce);
|
||||
@ -18,9 +20,9 @@ public class EncryptionRequestPacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString("");
|
||||
byte[] publicKey = MinecraftServer.getKeyPair().getPublic().getEncoded();
|
||||
final byte[] publicKey = MinecraftServer.getKeyPair().getPublic().getEncoded();
|
||||
ByteArrayData.encodeByteArray(writer, publicKey);
|
||||
ByteArrayData.encodeByteArray(writer, nonce);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import net.minestom.server.world.LevelType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
public class JoinGamePacket implements ServerPacket {
|
||||
@ -15,14 +15,15 @@ public class JoinGamePacket implements ServerPacket {
|
||||
public GameMode gameMode = GameMode.SURVIVAL;
|
||||
public DimensionType dimensionType = DimensionType.OVERWORLD;
|
||||
public long hashedSeed;
|
||||
public byte maxPlayers = 0; // Unused
|
||||
public LevelType levelType;
|
||||
public int maxPlayers = 0; // Unused
|
||||
public int viewDistance;
|
||||
public boolean reducedDebugInfo = false;
|
||||
public boolean enableRespawnScreen = true;
|
||||
public boolean isDebug = false;
|
||||
public boolean isFlat = false;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeInt(entityId);
|
||||
writer.writeBoolean(MinecraftServer.isHardcoreLook());
|
||||
writer.writeByte(gameMode.getId());
|
||||
@ -49,9 +50,9 @@ public class JoinGamePacket implements ServerPacket {
|
||||
writer.writeBoolean(reducedDebugInfo);
|
||||
writer.writeBoolean(enableRespawnScreen);
|
||||
//debug
|
||||
writer.writeBoolean(false);
|
||||
writer.writeBoolean(isDebug);
|
||||
//is flat
|
||||
writer.writeBoolean(levelType == LevelType.FLAT);
|
||||
writer.writeBoolean(isFlat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.network.packet.server.login;
|
||||
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LoginDisconnect implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class LoginDisconnect implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(kickMessage);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.network.packet.server.login;
|
||||
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -16,7 +17,7 @@ public class LoginSuccessPacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeUuid(uuid);
|
||||
writer.writeSizedString(username);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.network.packet.server.login;
|
||||
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SetCompressionPacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class SetCompressionPacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(threshold);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AcknowledgePlayerDiggingPacket implements ServerPacket {
|
||||
|
||||
@ -14,7 +15,7 @@ public class AcknowledgePlayerDiggingPacket implements ServerPacket {
|
||||
public boolean successful;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeBlockPosition(blockPosition);
|
||||
writer.writeVarInt(blockStateId);
|
||||
writer.writeVarInt(status.ordinal());
|
||||
|
@ -6,6 +6,8 @@ import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.binary.Writeable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AdvancementsPacket implements ServerPacket {
|
||||
|
||||
@ -15,7 +17,7 @@ public class AdvancementsPacket implements ServerPacket {
|
||||
public ProgressMapping[] progressMappings;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeBoolean(resetAdvancements);
|
||||
|
||||
writer.writeVarInt(advancementMappings.length);
|
||||
@ -38,25 +40,27 @@ public class AdvancementsPacket implements ServerPacket {
|
||||
/**
|
||||
* AdvancementMapping maps the namespaced ID to the Advancement.
|
||||
*/
|
||||
public static class AdvancementMapping {
|
||||
public static class AdvancementMapping implements Writeable {
|
||||
|
||||
public String key;
|
||||
public Advancement value;
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeSizedString(key);
|
||||
value.write(writer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Advancement {
|
||||
public static class Advancement implements Writeable {
|
||||
public String parentIdentifier;
|
||||
public DisplayData displayData;
|
||||
public String[] criterions;
|
||||
public Requirement[] requirements;
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
// hasParent
|
||||
writer.writeBoolean(parentIdentifier != null);
|
||||
if (parentIdentifier != null) {
|
||||
@ -79,7 +83,7 @@ public class AdvancementsPacket implements ServerPacket {
|
||||
}
|
||||
}
|
||||
|
||||
public static class DisplayData {
|
||||
public static class DisplayData implements Writeable {
|
||||
public JsonMessage title; // Only text
|
||||
public JsonMessage description; // Only text
|
||||
public ItemStack icon;
|
||||
@ -89,7 +93,8 @@ public class AdvancementsPacket implements ServerPacket {
|
||||
public float x;
|
||||
public float y;
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeSizedString(title.toString());
|
||||
writer.writeSizedString(description.toString());
|
||||
writer.writeItemStack(icon);
|
||||
@ -104,11 +109,12 @@ public class AdvancementsPacket implements ServerPacket {
|
||||
|
||||
}
|
||||
|
||||
public static class Requirement {
|
||||
public static class Requirement implements Writeable {
|
||||
|
||||
public String[] requirements;
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeVarInt(requirements.length);
|
||||
for (String requirement : requirements) {
|
||||
writer.writeSizedString(requirement);
|
||||
@ -116,20 +122,22 @@ public class AdvancementsPacket implements ServerPacket {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ProgressMapping {
|
||||
public static class ProgressMapping implements Writeable {
|
||||
public String key;
|
||||
public AdvancementProgress value;
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeSizedString(key);
|
||||
value.write(writer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdvancementProgress {
|
||||
public static class AdvancementProgress implements Writeable {
|
||||
public Criteria[] criteria;
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeVarInt(criteria.length);
|
||||
for (Criteria criterion : criteria) {
|
||||
criterion.write(writer);
|
||||
@ -137,21 +145,24 @@ public class AdvancementsPacket implements ServerPacket {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria {
|
||||
public static class Criteria implements Writeable {
|
||||
public String criterionIdentifier;
|
||||
public CriterionProgress criterionProgress;
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeSizedString(criterionIdentifier);
|
||||
criterionProgress.write(writer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class CriterionProgress {
|
||||
public static class CriterionProgress implements Writeable {
|
||||
public boolean achieved;
|
||||
public long dateOfAchieving;
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeBoolean(achieved);
|
||||
if (dateOfAchieving != 0)
|
||||
writer.writeLong(dateOfAchieving);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AttachEntityPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class AttachEntityPacket implements ServerPacket {
|
||||
public int holdingEntityId; // Or -1 to detach
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeInt(attachedEntityId);
|
||||
writer.writeInt(holdingEntityId);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlockActionPacket implements ServerPacket {
|
||||
|
||||
@ -13,7 +14,7 @@ public class BlockActionPacket implements ServerPacket {
|
||||
public int blockId;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeBlockPosition(blockPosition);
|
||||
writer.writeByte(actionId);
|
||||
writer.writeByte(actionParam);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlockBreakAnimationPacket implements ServerPacket {
|
||||
|
||||
@ -22,7 +23,7 @@ public class BlockBreakAnimationPacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeBlockPosition(blockPosition);
|
||||
writer.writeByte(destroyStage);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BlockChangePacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class BlockChangePacket implements ServerPacket {
|
||||
public int blockStateId;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeBlockPosition(blockPosition);
|
||||
writer.writeVarInt(blockStateId);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -22,7 +23,7 @@ public class BossBarPacket implements ServerPacket {
|
||||
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeUuid(uuid);
|
||||
writer.writeVarInt(action.ordinal());
|
||||
|
||||
|
@ -3,13 +3,14 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CameraPacket implements ServerPacket {
|
||||
|
||||
public int cameraId;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(cameraId);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ChangeGameStatePacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class ChangeGameStatePacket implements ServerPacket {
|
||||
public float value;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte((byte) reason.ordinal());
|
||||
writer.writeFloat(value);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -23,7 +24,7 @@ public class ChatMessagePacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(jsonMessage);
|
||||
writer.writeByte((byte) position.ordinal());
|
||||
writer.writeUuid(uuid);
|
||||
|
@ -15,6 +15,7 @@ import net.minestom.server.utils.Utils;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.util.Set;
|
||||
@ -41,7 +42,7 @@ public class ChunkDataPacket implements ServerPacket {
|
||||
private static final int MAX_BUFFER_SIZE = (Short.BYTES + Byte.BYTES + 5 * Byte.BYTES + (4096 * BITS_PER_ENTRY / Long.SIZE * Long.BYTES)) * CHUNK_SECTION_COUNT + 256 * Integer.BYTES;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeInt(chunkX);
|
||||
writer.writeInt(chunkZ);
|
||||
writer.writeBoolean(fullChunk);
|
||||
|
@ -3,13 +3,14 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CloseWindowPacket implements ServerPacket {
|
||||
|
||||
public byte windowId;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CollectItemPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class CollectItemPacket implements ServerPacket {
|
||||
public int pickupItemCount;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(collectedEntityId);
|
||||
writer.writeVarInt(collectorEntityId);
|
||||
writer.writeVarInt(pickupItemCount);
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -48,7 +49,7 @@ public class CombatEventPacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(type.ordinal());
|
||||
switch (type) {
|
||||
case ENTER_COMBAT:
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CraftRecipeResponse implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class CraftRecipeResponse implements ServerPacket {
|
||||
public String recipe;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
writer.writeSizedString(recipe);
|
||||
}
|
||||
|
@ -3,17 +3,18 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.binary.Writeable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DeclareCommandsPacket implements ServerPacket {
|
||||
|
||||
|
||||
public Node[] nodes;
|
||||
public int rootIndex;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(nodes.length);
|
||||
for (Node node : nodes) {
|
||||
node.write(writer);
|
||||
@ -26,7 +27,7 @@ public class DeclareCommandsPacket implements ServerPacket {
|
||||
return ServerPacketIdentifier.DECLARE_COMMANDS;
|
||||
}
|
||||
|
||||
public static class Node {
|
||||
public static class Node implements Writeable {
|
||||
|
||||
public byte flags;
|
||||
public int[] children;
|
||||
@ -36,7 +37,8 @@ public class DeclareCommandsPacket implements ServerPacket {
|
||||
public Consumer<BinaryWriter> properties; // Only for argument
|
||||
public String suggestionsType; // Only if flags 0x10
|
||||
|
||||
private void write(BinaryWriter writer) {
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
writer.writeByte(flags);
|
||||
|
||||
writer.writeVarIntArray(children);
|
||||
|
@ -12,7 +12,7 @@ public class DeclareRecipesPacket implements ServerPacket {
|
||||
public DeclaredRecipe[] recipes;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
Check.notNull(recipes, "Recipes cannot be null!");
|
||||
|
||||
writer.writeVarInt(recipes.length);
|
||||
|
@ -3,13 +3,14 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DestroyEntitiesPacket implements ServerPacket {
|
||||
|
||||
public int[] entityIds;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarIntArray(entityIds);
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,14 @@ import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DisconnectPacket implements ServerPacket {
|
||||
|
||||
public JsonMessage message; // Only text
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(message.toString());
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DisplayScoreboardPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class DisplayScoreboardPacket implements ServerPacket {
|
||||
public String scoreName;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(position);
|
||||
writer.writeSizedString(scoreName);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EffectPacket implements ServerPacket {
|
||||
|
||||
@ -13,7 +14,7 @@ public class EffectPacket implements ServerPacket {
|
||||
public boolean disableRelativeVolume;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeInt(effectId);
|
||||
writer.writeBlockPosition(position);
|
||||
writer.writeInt(data);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityAnimationPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class EntityAnimationPacket implements ServerPacket {
|
||||
public Animation animation;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeByte((byte) animation.ordinal());
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.potion.PotionEffect;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityEffectPacket implements ServerPacket {
|
||||
|
||||
@ -14,7 +15,7 @@ public class EntityEffectPacket implements ServerPacket {
|
||||
public byte flags;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeByte((byte) effect.getId());
|
||||
writer.writeByte(amplifier);
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityEquipmentPacket implements ServerPacket {
|
||||
|
||||
@ -13,7 +14,7 @@ public class EntityEquipmentPacket implements ServerPacket {
|
||||
public ItemStack[] itemStacks;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
|
||||
if (slots == null || itemStacks == null) {
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityHeadLookPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class EntityHeadLookPacket implements ServerPacket {
|
||||
public float yaw;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeByte((byte) (this.yaw * 256 / 360));
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -12,7 +13,7 @@ public class EntityMetaDataPacket implements ServerPacket {
|
||||
public Consumer<BinaryWriter> consumer;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.write(consumer);
|
||||
writer.writeByte((byte) 0xFF);
|
||||
|
@ -3,13 +3,14 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityPacket implements ServerPacket {
|
||||
|
||||
public int entityId;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityPositionAndRotationPacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class EntityPositionAndRotationPacket implements ServerPacket {
|
||||
public boolean onGround;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeShort(deltaX);
|
||||
writer.writeShort(deltaY);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityPositionPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class EntityPositionPacket implements ServerPacket {
|
||||
public boolean onGround;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeShort(deltaX);
|
||||
writer.writeShort(deltaY);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.attribute.Attribute;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityPropertiesPacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class EntityPropertiesPacket implements ServerPacket {
|
||||
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeInt(properties.length);
|
||||
for (Property property : properties) {
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityRotationPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class EntityRotationPacket implements ServerPacket {
|
||||
public boolean onGround;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeByte((byte) (yaw * 256 / 360));
|
||||
writer.writeByte((byte) (pitch * 256 / 360));
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.sound.SoundCategory;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntitySoundEffect implements ServerPacket {
|
||||
|
||||
@ -14,7 +15,7 @@ public class EntitySoundEffect implements ServerPacket {
|
||||
public float pitch;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(soundId);
|
||||
writer.writeVarInt(soundCategory.ordinal());
|
||||
writer.writeVarInt(entityId);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityStatusPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class EntityStatusPacket implements ServerPacket {
|
||||
public byte status;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeInt(entityId);
|
||||
writer.writeByte(status);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityTeleportPacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class EntityTeleportPacket implements ServerPacket {
|
||||
public boolean onGround;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeDouble(position.getX());
|
||||
writer.writeDouble(position.getY());
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityVelocityPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class EntityVelocityPacket implements ServerPacket {
|
||||
public short velocityX, velocityY, velocityZ;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeShort(velocityX);
|
||||
writer.writeShort(velocityY);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ExplosionPacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class ExplosionPacket implements ServerPacket {
|
||||
public float playerMotionX, playerMotionY, playerMotionZ;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeFloat(x);
|
||||
writer.writeFloat(y);
|
||||
writer.writeFloat(z);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FacePlayerPacket implements ServerPacket {
|
||||
|
||||
@ -13,7 +14,7 @@ public class FacePlayerPacket implements ServerPacket {
|
||||
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(facePosition.ordinal());
|
||||
writer.writeDouble(targetX);
|
||||
writer.writeDouble(targetY);
|
||||
|
@ -3,13 +3,14 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HeldItemChangePacket implements ServerPacket {
|
||||
|
||||
public byte slot;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(slot);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class KeepAlivePacket implements ServerPacket {
|
||||
|
||||
@ -13,7 +14,7 @@ public class KeepAlivePacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeLong(id);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MapDataPacket implements ServerPacket {
|
||||
|
||||
@ -21,7 +22,7 @@ public class MapDataPacket implements ServerPacket {
|
||||
public byte[] data;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(mapId);
|
||||
writer.writeByte(scale);
|
||||
writer.writeBoolean(trackingPosition);
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MultiBlockChangePacket implements ServerPacket {
|
||||
|
||||
@ -16,7 +17,7 @@ public class MultiBlockChangePacket implements ServerPacket {
|
||||
public BlockChange[] blockChanges;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeLong(ChunkUtils.getChunkIndexWithSection(chunkX, chunkZ, section));
|
||||
writer.writeBoolean(suppressLightUpdates);
|
||||
if (blockChanges != null) {
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.sound.SoundCategory;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NamedSoundEffectPacket implements ServerPacket {
|
||||
|
||||
@ -14,7 +15,7 @@ public class NamedSoundEffectPacket implements ServerPacket {
|
||||
public float pitch;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(soundName);
|
||||
writer.writeVarInt(soundCategory.ordinal());
|
||||
writer.writeInt(x);
|
||||
|
@ -4,13 +4,14 @@ import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OpenBookPacket implements ServerPacket {
|
||||
|
||||
public Player.Hand hand;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(hand.ordinal());
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OpenHorseWindowPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class OpenHorseWindowPacket implements ServerPacket {
|
||||
public int entityId;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
writer.writeVarInt(slotCount);
|
||||
writer.writeInt(entityId);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OpenSignEditorPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class OpenSignEditorPacket implements ServerPacket {
|
||||
public BlockPosition signPosition;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeBlockPosition(signPosition);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OpenWindowPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class OpenWindowPacket implements ServerPacket {
|
||||
public String title;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(windowId);
|
||||
writer.writeVarInt(windowType);
|
||||
writer.writeSizedString("{\"text\": \"" + title + " \"}");
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -18,7 +19,7 @@ public class ParticlePacket implements ServerPacket {
|
||||
public Consumer<BinaryWriter> dataConsumer;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeInt(particleId);
|
||||
writer.writeBoolean(longDistance);
|
||||
writer.writeDouble(x);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerAbilitiesPacket implements ServerPacket {
|
||||
|
||||
@ -17,7 +18,7 @@ public class PlayerAbilitiesPacket implements ServerPacket {
|
||||
public float walkingSpeed;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
byte flags = 0;
|
||||
if (invulnerable)
|
||||
flags += 1;
|
||||
|
@ -21,7 +21,7 @@ public class PlayerInfoPacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(action.ordinal());
|
||||
writer.writeVarInt(playerInfos.size());
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerListHeaderAndFooterPacket implements ServerPacket {
|
||||
|
||||
@ -17,7 +18,7 @@ public class PlayerListHeaderAndFooterPacket implements ServerPacket {
|
||||
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
if (emptyHeader) {
|
||||
writer.writeSizedString(EMPTY_COMPONENT);
|
||||
} else {
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerPositionAndLookPacket implements ServerPacket {
|
||||
|
||||
@ -13,7 +14,7 @@ public class PlayerPositionAndLookPacket implements ServerPacket {
|
||||
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeDouble(position.getX());
|
||||
writer.writeDouble(position.getY());
|
||||
writer.writeDouble(position.getZ());
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PluginMessagePacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class PluginMessagePacket implements ServerPacket {
|
||||
public byte[] data;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(channel);
|
||||
writer.writeBytes(data);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.potion.PotionEffect;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RemoveEntityEffectPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class RemoveEntityEffectPacket implements ServerPacket {
|
||||
public PotionEffect effect;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeByte((byte) effect.getId());
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ResourcePackSendPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class ResourcePackSendPacket implements ServerPacket {
|
||||
public String hash; // Size 40
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(url);
|
||||
writer.writeSizedString(hash);
|
||||
}
|
||||
|
@ -5,17 +5,19 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import net.minestom.server.world.LevelType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RespawnPacket implements ServerPacket {
|
||||
|
||||
public DimensionType dimensionType;
|
||||
public long hashedSeed;
|
||||
public GameMode gameMode;
|
||||
public LevelType levelType;
|
||||
public boolean isDebug = false;
|
||||
public boolean isFlat = true;
|
||||
public boolean copyMeta = true;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
//TODO add api
|
||||
writer.writeNBT("", dimensionType.toNBT());
|
||||
|
||||
@ -25,12 +27,9 @@ public class RespawnPacket implements ServerPacket {
|
||||
writer.writeLong(hashedSeed);
|
||||
writer.writeByte(gameMode.getId());
|
||||
writer.writeByte(gameMode.getId()); // Hardcore flag not included
|
||||
//debug
|
||||
writer.writeBoolean(false);
|
||||
//is flat
|
||||
writer.writeBoolean(true);
|
||||
//copy meta
|
||||
writer.writeBoolean(true);
|
||||
writer.writeBoolean(isDebug);
|
||||
writer.writeBoolean(isFlat);
|
||||
writer.writeBoolean(copyMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ScoreboardObjectivePacket implements ServerPacket {
|
||||
|
||||
@ -27,7 +28,7 @@ public class ScoreboardObjectivePacket implements ServerPacket {
|
||||
public Type type;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(objectiveName);
|
||||
writer.writeByte(mode);
|
||||
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import net.minestom.server.world.Difficulty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ServerDifficultyPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class ServerDifficultyPacket implements ServerPacket {
|
||||
public boolean locked;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte((byte) difficulty.ordinal());
|
||||
writer.writeBoolean(locked);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SetCooldownPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class SetCooldownPacket implements ServerPacket {
|
||||
public int cooldownTicks;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(itemId);
|
||||
writer.writeVarInt(cooldownTicks);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SetExperiencePacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class SetExperiencePacket implements ServerPacket {
|
||||
public int totalExperience;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeFloat(percentage);
|
||||
writer.writeVarInt(level);
|
||||
writer.writeVarInt(totalExperience);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SetPassengersPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class SetPassengersPacket implements ServerPacket {
|
||||
public int[] passengersId;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(vehicleEntityId);
|
||||
writer.writeVarIntArray(passengersId);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SetSlotPacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class SetSlotPacket implements ServerPacket {
|
||||
public ItemStack itemStack;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
writer.writeShort(slot);
|
||||
writer.writeItemStack(itemStack);
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.sound.Sound;
|
||||
import net.minestom.server.sound.SoundCategory;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SoundEffectPacket implements ServerPacket {
|
||||
|
||||
@ -28,7 +29,7 @@ public class SoundEffectPacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(soundId);
|
||||
writer.writeVarInt(soundCategory.ordinal());
|
||||
writer.writeInt(x);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -17,7 +18,7 @@ public class SpawnEntityPacket implements ServerPacket {
|
||||
public short velocityX, velocityY, velocityZ;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeUuid(uuid);
|
||||
writer.writeVarInt(type);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpawnExperienceOrbPacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class SpawnExperienceOrbPacket implements ServerPacket {
|
||||
public short expCount;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeDouble(position.getX());
|
||||
writer.writeDouble(position.getY());
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -17,7 +18,7 @@ public class SpawnLivingEntityPacket implements ServerPacket {
|
||||
public short velocityX, velocityY, velocityZ;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeUuid(entityUuid);
|
||||
writer.writeVarInt(entityType);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -16,7 +17,7 @@ public class SpawnPaintingPacket implements ServerPacket {
|
||||
public byte direction;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeUuid(entityUuid);
|
||||
writer.writeVarInt(motive);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -14,7 +15,7 @@ public class SpawnPlayerPacket implements ServerPacket {
|
||||
public Position position;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(entityId);
|
||||
writer.writeUuid(playerUuid);
|
||||
writer.writeDouble(position.getX());
|
||||
|
@ -3,13 +3,14 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpawnPositionPacket implements ServerPacket {
|
||||
|
||||
public int x, y, z;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeBlockPosition(x, y, z);
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,14 @@ import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.stat.StatisticCategory;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StatisticsPacket implements ServerPacket {
|
||||
|
||||
public Statistic[] statistics;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(statistics.length);
|
||||
for (Statistic statistic : statistics) {
|
||||
statistic.write(writer);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class StopSoundPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class StopSoundPacket implements ServerPacket {
|
||||
public String sound;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(flags);
|
||||
if (flags == 3 || flags == 1)
|
||||
writer.writeVarInt(source);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TabCompletePacket implements ServerPacket {
|
||||
|
||||
@ -13,7 +14,7 @@ public class TabCompletePacket implements ServerPacket {
|
||||
public Match[] matches;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(transactionId);
|
||||
writer.writeVarInt(start);
|
||||
writer.writeVarInt(length);
|
||||
|
@ -6,6 +6,7 @@ import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.registry.Registries;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -20,7 +21,7 @@ public class TagsPacket implements ServerPacket {
|
||||
public List<Tag> entityTags = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writeTags(writer, blockTags, name -> Registries.getBlock(name).ordinal());
|
||||
writeTags(writer, itemTags, name -> Registries.getMaterial(name).ordinal());
|
||||
writeTags(writer, fluidTags, name -> Registries.getFluid(name).ordinal());
|
||||
|
@ -58,7 +58,7 @@ public class TeamsPacket implements ServerPacket {
|
||||
* @param writer The writer to writes
|
||||
*/
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(this.teamName);
|
||||
writer.writeByte((byte) this.action.ordinal());
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TimeUpdatePacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class TimeUpdatePacket implements ServerPacket {
|
||||
public long timeOfDay;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeLong(worldAge);
|
||||
writer.writeLong(timeOfDay);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.chat.JsonMessage;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TitlePacket implements ServerPacket {
|
||||
|
||||
@ -20,7 +21,7 @@ public class TitlePacket implements ServerPacket {
|
||||
public int fadeOut;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(action.ordinal());
|
||||
|
||||
switch (action) {
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TradeListPacket implements ServerPacket {
|
||||
|
||||
@ -15,7 +16,7 @@ public class TradeListPacket implements ServerPacket {
|
||||
public boolean canRestock;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(windowId);
|
||||
writer.writeByte((byte) trades.length);
|
||||
for (Trade trade : trades) {
|
||||
|
@ -3,13 +3,14 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UnloadChunkPacket implements ServerPacket {
|
||||
|
||||
public int chunkX, chunkZ;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeInt(chunkX);
|
||||
writer.writeInt(chunkZ);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UnlockRecipesPacket implements ServerPacket {
|
||||
|
||||
@ -19,7 +20,7 @@ public class UnlockRecipesPacket implements ServerPacket {
|
||||
public String[] initRecipesId;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(mode);
|
||||
|
||||
writer.writeBoolean(craftingRecipeBookOpen);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UpdateHealthPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class UpdateHealthPacket implements ServerPacket {
|
||||
public float foodSaturation;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeFloat(health);
|
||||
writer.writeVarInt(food);
|
||||
writer.writeFloat(foodSaturation);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -23,7 +24,7 @@ public class UpdateLightPacket implements ServerPacket {
|
||||
public List<byte[]> blockLight;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(chunkX);
|
||||
writer.writeVarInt(chunkZ);
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UpdateScorePacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class UpdateScorePacket implements ServerPacket {
|
||||
public int value;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(entityName);
|
||||
writer.writeByte(action);
|
||||
writer.writeSizedString(objectiveName);
|
||||
|
@ -3,13 +3,14 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UpdateViewPositionPacket implements ServerPacket {
|
||||
|
||||
public int chunkX, chunkZ;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(chunkX);
|
||||
writer.writeVarInt(chunkZ);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VehicleMovePacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class VehicleMovePacket implements ServerPacket {
|
||||
public float yaw, pitch;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeDouble(x);
|
||||
writer.writeDouble(y);
|
||||
writer.writeDouble(z);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WindowConfirmationPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class WindowConfirmationPacket implements ServerPacket {
|
||||
public boolean accepted;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
writer.writeShort(actionNumber);
|
||||
writer.writeBoolean(accepted);
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WindowItemsPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class WindowItemsPacket implements ServerPacket {
|
||||
public ItemStack[] items;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
|
||||
if (items == null) {
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WindowPropertyPacket implements ServerPacket {
|
||||
|
||||
@ -11,7 +12,7 @@ public class WindowPropertyPacket implements ServerPacket {
|
||||
public short value;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeByte(windowId);
|
||||
writer.writeShort(property);
|
||||
writer.writeShort(value);
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.network.packet.server.play;
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WorldBorderPacket implements ServerPacket {
|
||||
|
||||
@ -10,7 +11,7 @@ public class WorldBorderPacket implements ServerPacket {
|
||||
public WBAction wbAction;
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(action.ordinal());
|
||||
wbAction.write(writer);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.network.packet.server.status;
|
||||
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PongPacket implements ServerPacket {
|
||||
|
||||
@ -12,7 +13,7 @@ public class PongPacket implements ServerPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BinaryWriter writer) {
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeLong(number);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user