From 9cbdafb65989e86e2a14597c96e72c5f6bcb4715 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 20 Apr 2020 13:43:56 +0200 Subject: [PATCH 01/15] add hand to edit book --- .../packet/ingame/client/window/ClientEditBookPacket.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientEditBookPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientEditBookPacket.java index 8b3b7a91..199271c3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientEditBookPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientEditBookPacket.java @@ -1,6 +1,8 @@ package com.github.steveice10.mc.protocol.packet.ingame.client.window; +import com.github.steveice10.mc.protocol.data.MagicValues; import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; @@ -20,17 +22,20 @@ import java.io.IOException; public class ClientEditBookPacket implements Packet { private @NonNull ItemStack book; private boolean signing; + private @NonNull Hand hand; @Override public void read(NetInput in) throws IOException { this.book = ItemStack.read(in); this.signing = in.readBoolean(); + this.hand = MagicValues.key(Hand.class, in.readVarInt()); } @Override public void write(NetOutput out) throws IOException { ItemStack.write(out, this.book); out.writeBoolean(this.signing); + out.writeVarInt(MagicValues.value(Integer.class, hand)); } @Override From 58ed868db2776049e2f85c3634d54eee61ea9d88 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Mon, 20 Apr 2020 14:58:49 -0700 Subject: [PATCH 02/15] Bump PacketLib and MCAuthLib versions. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7f97cc1d..79e7fc7c 100644 --- a/pom.xml +++ b/pom.xml @@ -62,13 +62,13 @@ com.github.steveice10 packetlib - master-SNAPSHOT + 1.5 compile com.github.steveice10 mcauthlib - 1.1 + 1.2 compile From 50022ee098c27cf7f7ef141ded246af0f571a526 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Tue, 21 Apr 2020 12:02:52 -0700 Subject: [PATCH 03/15] Use latest commit of PacketLib. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 79e7fc7c..ef4f92df 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ com.github.steveice10 packetlib - 1.5 + b98e525016 compile From 8fa519ee8ba3be4f5e9018bb7ebcdd522b225ca4 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Tue, 21 Apr 2020 12:12:01 -0700 Subject: [PATCH 04/15] Update PacketLib again to fix tests. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ef4f92df..f54745c0 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ com.github.steveice10 packetlib - b98e525016 + 43b394dfdc compile From d335d5f4bcab969cc60602377da99340e17cd816 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Thu, 23 Apr 2020 12:10:21 -0500 Subject: [PATCH 05/15] Allow icon in advancement to be null Sometimes the server does not send over an icon, and when one is not sent over, the player is kicked through MCProtocolLib because this was null --- .../mc/protocol/data/game/advancement/Advancement.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java index dc1954c1..7edf20d9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java @@ -34,7 +34,7 @@ public class Advancement { public static class DisplayData { private final @NonNull Message title; private final @NonNull Message description; - private final @NonNull ItemStack icon; + private final ItemStack icon; private final @NonNull FrameType frameType; private final boolean showToast; private final boolean hidden; @@ -42,7 +42,7 @@ public class Advancement { private final float posY; private final String backgroundTexture; - public DisplayData(@NonNull Message title, @NonNull Message description, @NonNull ItemStack icon, @NonNull FrameType frameType, + public DisplayData(@NonNull Message title, @NonNull Message description, ItemStack icon, @NonNull FrameType frameType, boolean showToast, boolean hidden, float posX, float posY) { this(title, description, icon, frameType, showToast, hidden, posX, posY, null); } From f1efbed86c9911fd66f5d702f8bfb19a321991a8 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Thu, 23 Apr 2020 10:45:35 -0700 Subject: [PATCH 06/15] Use GameProfile.setProperties in ServerPlayerListEntryPacket. --- .../server/ServerPlayerListEntryPacket.java | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java index 32272a0d..3ab62062 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java @@ -17,6 +17,8 @@ import lombok.NonNull; import lombok.Setter; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; @Data @@ -42,8 +44,9 @@ public class ServerPlayerListEntryPacket implements Packet { PlayerListEntry entry = null; switch(this.action) { - case ADD_PLAYER: + case ADD_PLAYER: { int properties = in.readVarInt(); + List propertyList = new ArrayList<>(); for(int index = 0; index < properties; index++) { String propertyName = in.readString(); String value = in.readString(); @@ -52,11 +55,13 @@ public class ServerPlayerListEntryPacket implements Packet { signature = in.readString(); } - profile.getProperties().add(new GameProfile.Property(propertyName, value, signature)); + propertyList.add(new GameProfile.Property(propertyName, value, signature)); } - int g = in.readVarInt(); - GameMode gameMode = MagicValues.key(GameMode.class, g < 0 ? 0 : g); + profile.setProperties(propertyList); + + int rawGameMode = in.readVarInt(); + GameMode gameMode = MagicValues.key(GameMode.class, rawGameMode < 0 ? 0 : rawGameMode); int ping = in.readVarInt(); Message displayName = null; if(in.readBoolean()) { @@ -65,23 +70,29 @@ public class ServerPlayerListEntryPacket implements Packet { entry = new PlayerListEntry(profile, gameMode, ping, displayName); break; - case UPDATE_GAMEMODE: - g = in.readVarInt(); - GameMode mode = MagicValues.key(GameMode.class, g < 0 ? 0 : g); + } + case UPDATE_GAMEMODE: { + int rawGameMode = in.readVarInt(); + GameMode mode = MagicValues.key(GameMode.class, rawGameMode < 0 ? 0 : rawGameMode); + entry = new PlayerListEntry(profile, mode); break; - case UPDATE_LATENCY: - int png = in.readVarInt(); - entry = new PlayerListEntry(profile, png); + } + case UPDATE_LATENCY: { + int ping = in.readVarInt(); + + entry = new PlayerListEntry(profile, ping); break; - case UPDATE_DISPLAY_NAME: - Message disp = null; + } + case UPDATE_DISPLAY_NAME: { + Message displayName = null; if(in.readBoolean()) { - disp = Message.fromString(in.readString()); + displayName = Message.fromString(in.readString()); } - entry = new PlayerListEntry(profile, disp); + entry = new PlayerListEntry(profile, displayName); break; + } case REMOVE_PLAYER: entry = new PlayerListEntry(profile); break; From 328f020489a1af749511ca74ea7d98f728ae17d0 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Sat, 25 Apr 2020 10:15:57 +0200 Subject: [PATCH 07/15] Add new particle types --- .../com/github/steveice10/mc/protocol/data/MagicValues.java | 4 ++++ .../mc/protocol/data/game/world/particle/ParticleType.java | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java index 2ff47795..f27eb638 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java @@ -878,6 +878,10 @@ public class MagicValues { register(ParticleType.DOLPHIN, 55); register(ParticleType.CAMPFIRE_COSY_SMOKE, 56); register(ParticleType.CAMPFIRE_SIGNAL_SMOKE, 57); + register(ParticleType.DRIPPING_HONEY, 58); + register(ParticleType.FALLING_HONEY, 59); + register(ParticleType.LANDING_HONEY, 60); + register(ParticleType.FALLING_NECTAR, 61); register(NoteBlockValueType.HARP, 0); register(NoteBlockValueType.DOUBLE_BASS, 1); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/particle/ParticleType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/particle/ParticleType.java index e7b96c1f..f1f0dda2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/particle/ParticleType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/particle/ParticleType.java @@ -58,5 +58,9 @@ public enum ParticleType { NAUTILUS, DOLPHIN, CAMPFIRE_COSY_SMOKE, - CAMPFIRE_SIGNAL_SMOKE; + CAMPFIRE_SIGNAL_SMOKE, + DRIPPING_HONEY, + FALLING_HONEY, + LANDING_HONEY, + FALLING_NECTAR } From 2ff26946acb25b2463f5a1cbc78fac438acf653d Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Sun, 26 Apr 2020 12:58:48 -0700 Subject: [PATCH 08/15] Use latest commit of MCAuthLib. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f54745c0..06af1d76 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ com.github.steveice10 mcauthlib - 1.2 + 1113225d7d compile From 5ae680aaeb0539629c113c262df1e5894b3ddcd1 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Sun, 26 Apr 2020 13:13:21 -0700 Subject: [PATCH 09/15] Update MCAuthLib commit again. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 06af1d76..a6eb63dd 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,7 @@ com.github.steveice10 mcauthlib - 1113225d7d + 401c99c722 compile From 920ccdb1a1ef0adeae5467abb74352013385a7ad Mon Sep 17 00:00:00 2001 From: rtm516 Date: Thu, 14 May 2020 01:42:44 +0100 Subject: [PATCH 10/15] Added shulker box UpdatedTileType to prevent errors on older versions --- .../java/com/github/steveice10/mc/protocol/data/MagicValues.java | 1 + .../mc/protocol/data/game/world/block/UpdatedTileType.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java index f27eb638..2f245552 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java @@ -688,6 +688,7 @@ public class MagicValues { register(UpdatedTileType.STRUCTURE_BLOCK, 7); register(UpdatedTileType.END_GATEWAY, 8); register(UpdatedTileType.SIGN, 9); + register(UpdatedTileType.SHULKER_BOX, 10); register(UpdatedTileType.BED, 11); register(UpdatedTileType.JIGSAW_BLOCK, 12); register(UpdatedTileType.CAMPFIRE, 13); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/UpdatedTileType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/UpdatedTileType.java index 50e5989e..184a68d1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/UpdatedTileType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/UpdatedTileType.java @@ -10,6 +10,7 @@ public enum UpdatedTileType { STRUCTURE_BLOCK, END_GATEWAY, SIGN, + SHULKER_BOX, BED, JIGSAW_BLOCK, CAMPFIRE, From e61bc838230e08c286fd09b7267e613c24ead5a3 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Thu, 21 May 2020 14:15:47 -0700 Subject: [PATCH 11/15] Update world border packet field names. --- .../server/world/ServerWorldBorderPacket.java | 101 +++++++++--------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java index 85d980fc..6a5b8067 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java @@ -19,63 +19,62 @@ import java.io.IOException; public class ServerWorldBorderPacket implements Packet { private @NonNull WorldBorderAction action; - private double radius; + private double newSize; - private double oldRadius; - private double newRadius; - private long speed; + private double oldSize; + private long lerpTime; - private double centerX; - private double centerY; + private double newCenterX; + private double newCenterY; - private int portalTeleportBoundary; + private int newAbsoluteMaxSize; private int warningTime; private int warningBlocks; - public ServerWorldBorderPacket(double radius) { + public ServerWorldBorderPacket(double newSize) { this.action = WorldBorderAction.SET_SIZE; - this.radius = radius; + this.newSize = newSize; } - public ServerWorldBorderPacket(double oldRadius, double newRadius, long speed) { + public ServerWorldBorderPacket(double oldSize, double newSize, long lerpTime) { this.action = WorldBorderAction.LERP_SIZE; - this.oldRadius = oldRadius; - this.newRadius = newRadius; - this.speed = speed; + this.oldSize = oldSize; + this.newSize = newSize; + this.lerpTime = lerpTime; } - public ServerWorldBorderPacket(double centerX, double centerY) { + public ServerWorldBorderPacket(double newCenterX, double newCenterY) { this.action = WorldBorderAction.SET_CENTER; - this.centerX = centerX; - this.centerY = centerY; + this.newCenterX = newCenterX; + this.newCenterY = newCenterY; } - public ServerWorldBorderPacket(boolean time, int warning) { - if(time) { + public ServerWorldBorderPacket(boolean isTime, int warningValue) { + if(isTime) { this.action = WorldBorderAction.SET_WARNING_TIME; - this.warningTime = warning; + this.warningTime = warningValue; } else { this.action = WorldBorderAction.SET_WARNING_BLOCKS; - this.warningBlocks = warning; + this.warningBlocks = warningValue; } } - public ServerWorldBorderPacket(double centerX, double centerY, double oldRadius, double newRadius, long speed, int portalTeleportBoundary, int warningTime, int warningBlocks) { + public ServerWorldBorderPacket(double newCenterX, double newCenterY, double oldSize, double newSize, long lerpTime, int newAbsoluteMaxSize, int warningTime, int warningBlocks) { this.action = WorldBorderAction.INITIALIZE; - this.centerX = centerX; - this.centerY = centerY; - this.oldRadius = oldRadius; - this.newRadius = newRadius; - this.speed = speed; - this.portalTeleportBoundary = portalTeleportBoundary; + this.newCenterX = newCenterX; + this.newCenterY = newCenterY; + this.oldSize = oldSize; + this.newSize = newSize; + this.lerpTime = lerpTime; + this.newAbsoluteMaxSize = newAbsoluteMaxSize; this.warningTime = warningTime; this.warningBlocks = warningBlocks; } @@ -84,21 +83,21 @@ public class ServerWorldBorderPacket implements Packet { public void read(NetInput in) throws IOException { this.action = MagicValues.key(WorldBorderAction.class, in.readVarInt()); if(this.action == WorldBorderAction.SET_SIZE) { - this.radius = in.readDouble(); + this.newSize = in.readDouble(); } else if(this.action == WorldBorderAction.LERP_SIZE) { - this.oldRadius = in.readDouble(); - this.newRadius = in.readDouble(); - this.speed = in.readVarLong(); + this.oldSize = in.readDouble(); + this.newSize = in.readDouble(); + this.lerpTime = in.readVarLong(); } else if(this.action == WorldBorderAction.SET_CENTER) { - this.centerX = in.readDouble(); - this.centerY = in.readDouble(); + this.newCenterX = in.readDouble(); + this.newCenterY = in.readDouble(); } else if(this.action == WorldBorderAction.INITIALIZE) { - this.centerX = in.readDouble(); - this.centerY = in.readDouble(); - this.oldRadius = in.readDouble(); - this.newRadius = in.readDouble(); - this.speed = in.readVarLong(); - this.portalTeleportBoundary = in.readVarInt(); + this.newCenterX = in.readDouble(); + this.newCenterY = in.readDouble(); + this.oldSize = in.readDouble(); + this.newSize = in.readDouble(); + this.lerpTime = in.readVarLong(); + this.newAbsoluteMaxSize = in.readVarInt(); this.warningTime = in.readVarInt(); this.warningBlocks = in.readVarInt(); } else if(this.action == WorldBorderAction.SET_WARNING_TIME) { @@ -112,21 +111,21 @@ public class ServerWorldBorderPacket implements Packet { public void write(NetOutput out) throws IOException { out.writeVarInt(MagicValues.value(Integer.class, this.action)); if(this.action == WorldBorderAction.SET_SIZE) { - out.writeDouble(this.radius); + out.writeDouble(this.newSize); } else if(this.action == WorldBorderAction.LERP_SIZE) { - out.writeDouble(this.oldRadius); - out.writeDouble(this.newRadius); - out.writeVarLong(this.speed); + out.writeDouble(this.oldSize); + out.writeDouble(this.newSize); + out.writeVarLong(this.lerpTime); } else if(this.action == WorldBorderAction.SET_CENTER) { - out.writeDouble(this.centerX); - out.writeDouble(this.centerY); + out.writeDouble(this.newCenterX); + out.writeDouble(this.newCenterY); } else if(this.action == WorldBorderAction.INITIALIZE) { - out.writeDouble(this.centerX); - out.writeDouble(this.centerY); - out.writeDouble(this.oldRadius); - out.writeDouble(this.newRadius); - out.writeVarLong(this.speed); - out.writeVarInt(this.portalTeleportBoundary); + out.writeDouble(this.newCenterX); + out.writeDouble(this.newCenterY); + out.writeDouble(this.oldSize); + out.writeDouble(this.newSize); + out.writeVarLong(this.lerpTime); + out.writeVarInt(this.newAbsoluteMaxSize); out.writeVarInt(this.warningTime); out.writeVarInt(this.warningBlocks); } else if(this.action == WorldBorderAction.SET_WARNING_TIME) { From 898b45ec6c9513a0a4f7f17283cef0d0e94f58f7 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Thu, 21 May 2020 14:18:28 -0700 Subject: [PATCH 12/15] Border Y should be Z. --- .../server/world/ServerWorldBorderPacket.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java index 6a5b8067..7d934ad1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/world/ServerWorldBorderPacket.java @@ -25,7 +25,7 @@ public class ServerWorldBorderPacket implements Packet { private long lerpTime; private double newCenterX; - private double newCenterY; + private double newCenterZ; private int newAbsoluteMaxSize; @@ -47,11 +47,11 @@ public class ServerWorldBorderPacket implements Packet { this.lerpTime = lerpTime; } - public ServerWorldBorderPacket(double newCenterX, double newCenterY) { + public ServerWorldBorderPacket(double newCenterX, double newCenterZ) { this.action = WorldBorderAction.SET_CENTER; this.newCenterX = newCenterX; - this.newCenterY = newCenterY; + this.newCenterZ = newCenterZ; } public ServerWorldBorderPacket(boolean isTime, int warningValue) { @@ -66,11 +66,11 @@ public class ServerWorldBorderPacket implements Packet { } } - public ServerWorldBorderPacket(double newCenterX, double newCenterY, double oldSize, double newSize, long lerpTime, int newAbsoluteMaxSize, int warningTime, int warningBlocks) { + public ServerWorldBorderPacket(double newCenterX, double newCenterZ, double oldSize, double newSize, long lerpTime, int newAbsoluteMaxSize, int warningTime, int warningBlocks) { this.action = WorldBorderAction.INITIALIZE; this.newCenterX = newCenterX; - this.newCenterY = newCenterY; + this.newCenterZ = newCenterZ; this.oldSize = oldSize; this.newSize = newSize; this.lerpTime = lerpTime; @@ -90,10 +90,10 @@ public class ServerWorldBorderPacket implements Packet { this.lerpTime = in.readVarLong(); } else if(this.action == WorldBorderAction.SET_CENTER) { this.newCenterX = in.readDouble(); - this.newCenterY = in.readDouble(); + this.newCenterZ = in.readDouble(); } else if(this.action == WorldBorderAction.INITIALIZE) { this.newCenterX = in.readDouble(); - this.newCenterY = in.readDouble(); + this.newCenterZ = in.readDouble(); this.oldSize = in.readDouble(); this.newSize = in.readDouble(); this.lerpTime = in.readVarLong(); @@ -118,10 +118,10 @@ public class ServerWorldBorderPacket implements Packet { out.writeVarLong(this.lerpTime); } else if(this.action == WorldBorderAction.SET_CENTER) { out.writeDouble(this.newCenterX); - out.writeDouble(this.newCenterY); + out.writeDouble(this.newCenterZ); } else if(this.action == WorldBorderAction.INITIALIZE) { out.writeDouble(this.newCenterX); - out.writeDouble(this.newCenterY); + out.writeDouble(this.newCenterZ); out.writeDouble(this.oldSize); out.writeDouble(this.newSize); out.writeVarLong(this.lerpTime); From a5bc122b93dc8cea539b5c478acddf40e610995b Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Thu, 21 May 2020 15:19:39 -0700 Subject: [PATCH 13/15] Handle protocol version translators that may send -1 for sound IDs. --- .../com/github/steveice10/mc/protocol/data/MagicValues.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java index 2f245552..2571aed7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java @@ -1206,6 +1206,10 @@ public class MagicValues { register(SoundCategory.AMBIENT, 8); register(SoundCategory.VOICE, 9); + // Handle some protocol version translators that may send -1 for untranslatable sound IDs. + // Choice of sound is based on what (I think?) vanilla would default to. + register(BuiltinSound.ENTITY_ITEM_PICKUP, -1); + for(BuiltinSound sound : BuiltinSound.values()) { register(sound, sound.ordinal()); register(sound, sound.getName()); From aae3a9d2765d8ff23093d6e8fd958639ff8eb676 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Fri, 22 May 2020 23:46:59 -0700 Subject: [PATCH 14/15] Add workaround for -1 MobType. --- .../github/steveice10/mc/protocol/data/MagicValues.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java index 2571aed7..74a74ac7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java @@ -1206,14 +1206,15 @@ public class MagicValues { register(SoundCategory.AMBIENT, 8); register(SoundCategory.VOICE, 9); - // Handle some protocol version translators that may send -1 for untranslatable sound IDs. - // Choice of sound is based on what (I think?) vanilla would default to. - register(BuiltinSound.ENTITY_ITEM_PICKUP, -1); - for(BuiltinSound sound : BuiltinSound.values()) { register(sound, sound.ordinal()); register(sound, sound.getName()); } + + // Handle some protocol version translators that may send -1 for untranslatable IDs. + // Choics are based on what (I think?) vanilla would default to. + register(MobType.PIG, -1); + register(BuiltinSound.ENTITY_ITEM_PICKUP, -1); } private MagicValues() { From 8e6bc6386b8bbd2be84f50a8ab847a1bd54cfca7 Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Sat, 23 May 2020 00:10:53 -0700 Subject: [PATCH 15/15] Merge ObjectType and EntityType and bring spawn packet naming in line with latest wiki info. --- .../mc/protocol/MinecraftProtocol.java | 18 +- .../mc/protocol/data/MagicValues.java | 253 ++++++++---------- .../{type => }/object/FallingBlockData.java | 2 +- .../{type => }/object/GenericObjectData.java | 2 +- .../{type => }/object/HangingDirection.java | 2 +- .../{type => }/object/MinecartType.java | 2 +- .../data/game/entity/object/ObjectData.java | 4 + .../{type => }/object/ProjectileData.java | 2 +- .../{type => }/object/SplashPotionData.java | 2 +- .../type/{MobType.java => EntityType.java} | 2 +- ...EntityType.java => WeatherEntityType.java} | 2 +- .../game/entity/type/object/ObjectData.java | 4 - .../game/entity/type/object/ObjectType.java | 39 --- ...cket.java => ServerSpawnEntityPacket.java} | 40 +-- ...ava => ServerSpawnLivingEntityPacket.java} | 8 +- .../spawn/ServerSpawnPaintingPacket.java | 2 +- ...va => ServerSpawnWeatherEntityPacket.java} | 8 +- .../mc/protocol/data/MagicValuesTest.java | 14 +- 18 files changed, 164 insertions(+), 242 deletions(-) rename src/main/java/com/github/steveice10/mc/protocol/data/game/entity/{type => }/object/FallingBlockData.java (73%) rename src/main/java/com/github/steveice10/mc/protocol/data/game/entity/{type => }/object/GenericObjectData.java (70%) rename src/main/java/com/github/steveice10/mc/protocol/data/game/entity/{type => }/object/HangingDirection.java (61%) rename src/main/java/com/github/steveice10/mc/protocol/data/game/entity/{type => }/object/MinecartType.java (66%) create mode 100644 src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/ObjectData.java rename src/main/java/com/github/steveice10/mc/protocol/data/game/entity/{type => }/object/ProjectileData.java (69%) rename src/main/java/com/github/steveice10/mc/protocol/data/game/entity/{type => }/object/SplashPotionData.java (70%) rename src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/{MobType.java => EntityType.java} (98%) rename src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/{GlobalEntityType.java => WeatherEntityType.java} (73%) delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ObjectData.java delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ObjectType.java rename src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/{ServerSpawnObjectPacket.java => ServerSpawnEntityPacket.java} (71%) rename src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/{ServerSpawnMobPacket.java => ServerSpawnLivingEntityPacket.java} (89%) rename src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/{ServerSpawnGlobalEntityPacket.java => ServerSpawnWeatherEntityPacket.java} (82%) diff --git a/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java b/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java index aa68d450..a1a9d9d1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java +++ b/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java @@ -103,9 +103,9 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.Serv import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerSetExperiencePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket; -import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnGlobalEntityPacket; -import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnMobPacket; -import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnWeatherEntityPacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnLivingEntityPacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnEntityPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPaintingPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket; @@ -372,10 +372,10 @@ public class MinecraftProtocol extends PacketProtocol { } private void initClientGame(Session session) { - this.registerIncoming(0x00, ServerSpawnObjectPacket.class); + this.registerIncoming(0x00, ServerSpawnEntityPacket.class); this.registerIncoming(0x01, ServerSpawnExpOrbPacket.class); - this.registerIncoming(0x02, ServerSpawnGlobalEntityPacket.class); - this.registerIncoming(0x03, ServerSpawnMobPacket.class); + this.registerIncoming(0x02, ServerSpawnWeatherEntityPacket.class); + this.registerIncoming(0x03, ServerSpawnLivingEntityPacket.class); this.registerIncoming(0x04, ServerSpawnPaintingPacket.class); this.registerIncoming(0x05, ServerSpawnPlayerPacket.class); this.registerIncoming(0x06, ServerEntityAnimationPacket.class); @@ -562,10 +562,10 @@ public class MinecraftProtocol extends PacketProtocol { this.registerIncoming(0x2C, ClientPlayerPlaceBlockPacket.class); this.registerIncoming(0x2D, ClientPlayerUseItemPacket.class); - this.registerOutgoing(0x00, ServerSpawnObjectPacket.class); + this.registerOutgoing(0x00, ServerSpawnEntityPacket.class); this.registerOutgoing(0x01, ServerSpawnExpOrbPacket.class); - this.registerOutgoing(0x02, ServerSpawnGlobalEntityPacket.class); - this.registerOutgoing(0x03, ServerSpawnMobPacket.class); + this.registerOutgoing(0x02, ServerSpawnWeatherEntityPacket.class); + this.registerOutgoing(0x03, ServerSpawnLivingEntityPacket.class); this.registerOutgoing(0x04, ServerSpawnPaintingPacket.class); this.registerOutgoing(0x05, ServerSpawnPlayerPacket.class); this.registerOutgoing(0x06, ServerEntityAnimationPacket.class); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java index 74a74ac7..07186ea6 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java @@ -32,12 +32,11 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState; import com.github.steveice10.mc.protocol.data.game.entity.player.PositionElement; -import com.github.steveice10.mc.protocol.data.game.entity.type.GlobalEntityType; -import com.github.steveice10.mc.protocol.data.game.entity.type.MobType; +import com.github.steveice10.mc.protocol.data.game.entity.type.WeatherEntityType; +import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType; import com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.HangingDirection; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.MinecartType; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType; +import com.github.steveice10.mc.protocol.data.game.entity.object.HangingDirection; +import com.github.steveice10.mc.protocol.data.game.entity.object.MinecartType; import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType; import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule; import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility; @@ -381,146 +380,110 @@ public class MagicValues { register(PositionElement.PITCH, 3); register(PositionElement.YAW, 4); - register(GlobalEntityType.LIGHTNING_BOLT, 1); + register(WeatherEntityType.LIGHTNING_BOLT, 1); - register(MobType.AREA_EFFECT_CLOUD, 0); - register(MobType.ARMOR_STAND, 1); - register(MobType.ARROW, 2); - register(MobType.BAT, 3); - register(MobType.BEE, 4); - register(MobType.BLAZE, 5); - register(MobType.BOAT, 6); - register(MobType.CAT, 7); - register(MobType.CAVE_SPIDER, 8); - register(MobType.CHICKEN, 9); - register(MobType.COD, 10); - register(MobType.COW, 11); - register(MobType.CREEPER, 12); - register(MobType.DONKEY, 13); - register(MobType.DOLPHIN, 14); - register(MobType.DRAGON_FIREBALL, 15); - register(MobType.DROWNED, 16); - register(MobType.ELDER_GUARDIAN, 17); - register(MobType.END_CRYSTAL, 18); - register(MobType.ENDER_DRAGON, 19); - register(MobType.ENDERMAN, 20); - register(MobType.ENDERMITE, 21); - register(MobType.EVOKER_FANGS, 22); - register(MobType.EVOKER, 23); - register(MobType.EXPERIENCE_ORB, 24); - register(MobType.EYE_OF_ENDER, 25); - register(MobType.FALLING_BLOCK, 26); - register(MobType.FIREWORK_ROCKET, 27); - register(MobType.FOX, 28); - register(MobType.GHAST, 29); - register(MobType.GIANT, 30); - register(MobType.GUARDIAN, 31); - register(MobType.HORSE, 32); - register(MobType.HUSK, 33); - register(MobType.ILLUSIONER, 34); - register(MobType.ITEM, 35); - register(MobType.ITEM_FRAME, 36); - register(MobType.FIREBALL, 37); - register(MobType.LEASH_KNOT, 38); - register(MobType.LLAMA, 39); - register(MobType.LLAMA_SPIT, 40); - register(MobType.MAGMA_CUBE, 41); - register(MobType.MINECART, 42); - register(MobType.MINECART_CHEST, 43); - register(MobType.MINECART_COMMAND_BLOCK, 44); - register(MobType.MINECART_FURNACE, 45); - register(MobType.MINECART_HOPPER, 46); - register(MobType.MINECART_SPAWNER, 47); - register(MobType.MINECART_TNT, 48); - register(MobType.MULE, 49); - register(MobType.MOOSHROOM, 50); - register(MobType.OCELOT, 51); - register(MobType.PAINTING, 52); - register(MobType.PANDA, 53); - register(MobType.PARROT, 54); - register(MobType.PIG, 55); - register(MobType.PUFFERFISH, 56); - register(MobType.ZOMBIE_PIGMAN, 57); - register(MobType.POLAR_BEAR, 58); - register(MobType.PRIMED_TNT, 59); - register(MobType.RABBIT, 60); - register(MobType.SALMON, 61); - register(MobType.SHEEP, 62); - register(MobType.SHULKER, 63); - register(MobType.SHULKER_BULLET, 64); - register(MobType.SILVERFISH, 65); - register(MobType.SKELETON, 66); - register(MobType.SKELETON_HORSE, 67); - register(MobType.SLIME, 68); - register(MobType.SMALL_FIREBALL, 69); - register(MobType.SNOW_GOLEM, 70); - register(MobType.SNOWBALL, 71); - register(MobType.SPECTRAL_ARROW, 72); - register(MobType.SPIDER, 73); - register(MobType.SQUID, 74); - register(MobType.STRAY, 75); - register(MobType.TRADER_LLAMA, 76); - register(MobType.TROPICAL_FISH, 77); - register(MobType.TURTLE, 78); - register(MobType.THROWN_EGG, 79); - register(MobType.THROWN_ENDERPEARL, 80); - register(MobType.THROWN_EXP_BOTTLE, 81); - register(MobType.THROWN_POTION, 82); - register(MobType.TRIDENT, 83); - register(MobType.VEX, 84); - register(MobType.VILLAGER, 85); - register(MobType.IRON_GOLEM, 86); - register(MobType.VINDICATOR, 87); - register(MobType.PILLAGER, 88); - register(MobType.WANDERING_TRADER, 89); - register(MobType.WITCH, 90); - register(MobType.WITHER, 91); - register(MobType.WITHER_SKELETON, 92); - register(MobType.WITHER_SKULL, 93); - register(MobType.WOLF, 94); - register(MobType.ZOMBIE, 95); - register(MobType.ZOMBIE_HORSE, 96); - register(MobType.ZOMBIE_VILLAGER, 97); - register(MobType.PHANTOM, 98); - register(MobType.RAVAGER, 99); - register(MobType.PLAYER, 101); - register(MobType.FISHING_BOBBER, 102); - - register(ObjectType.AREA_EFFECT_CLOUD, 0); - register(ObjectType.ARMOR_STAND, 1); - register(ObjectType.ARROW, 2); - register(ObjectType.BOAT, 6); - register(ObjectType.DRAGON_FIREBALL, 15); - register(ObjectType.END_CRYSTAL, 18); - register(ObjectType.EVOKER_FANGS, 22); - register(ObjectType.EXPERIENCE_ORB, 24); - register(ObjectType.EYE_OF_ENDER, 25); - register(ObjectType.FALLING_BLOCK, 26); - register(ObjectType.FIREWORK_ROCKET, 27); - register(ObjectType.ITEM, 35); - register(ObjectType.ITEM_FRAME, 36); - register(ObjectType.FIREBALL, 37); - register(ObjectType.LEASH_KNOT, 38); - register(ObjectType.LLAMA_SPIT, 40); - register(ObjectType.MINECART, 42); - register(ObjectType.CHEST_MINECART, 43); - register(ObjectType.COMMAND_BLOCK_MINECART, 44); - register(ObjectType.FURNACE_MINECART, 45); - register(ObjectType.HOPPER_MINECART, 46); - register(ObjectType.SPAWNER_MINECART, 47); - register(ObjectType.TNT_MINECART, 48); - register(ObjectType.TNT, 59); - register(ObjectType.SHULKER_BULLET, 64); - register(ObjectType.SMALL_FIREBALL, 69); - register(ObjectType.SNOWBALL, 71); - register(ObjectType.SPECTRAL_ARROW, 72); - register(ObjectType.EGG, 79); - register(ObjectType.ENDER_PEARL, 80); - register(ObjectType.EXPERIENCE_BOTTLE, 81); - register(ObjectType.POTION, 82); - register(ObjectType.TRIDENT, 83); - register(ObjectType.WITHER_SKULL, 93); - register(ObjectType.FISHING_BOBBER, 102); + register(EntityType.AREA_EFFECT_CLOUD, 0); + register(EntityType.ARMOR_STAND, 1); + register(EntityType.ARROW, 2); + register(EntityType.BAT, 3); + register(EntityType.BEE, 4); + register(EntityType.BLAZE, 5); + register(EntityType.BOAT, 6); + register(EntityType.CAT, 7); + register(EntityType.CAVE_SPIDER, 8); + register(EntityType.CHICKEN, 9); + register(EntityType.COD, 10); + register(EntityType.COW, 11); + register(EntityType.CREEPER, 12); + register(EntityType.DONKEY, 13); + register(EntityType.DOLPHIN, 14); + register(EntityType.DRAGON_FIREBALL, 15); + register(EntityType.DROWNED, 16); + register(EntityType.ELDER_GUARDIAN, 17); + register(EntityType.END_CRYSTAL, 18); + register(EntityType.ENDER_DRAGON, 19); + register(EntityType.ENDERMAN, 20); + register(EntityType.ENDERMITE, 21); + register(EntityType.EVOKER_FANGS, 22); + register(EntityType.EVOKER, 23); + register(EntityType.EXPERIENCE_ORB, 24); + register(EntityType.EYE_OF_ENDER, 25); + register(EntityType.FALLING_BLOCK, 26); + register(EntityType.FIREWORK_ROCKET, 27); + register(EntityType.FOX, 28); + register(EntityType.GHAST, 29); + register(EntityType.GIANT, 30); + register(EntityType.GUARDIAN, 31); + register(EntityType.HORSE, 32); + register(EntityType.HUSK, 33); + register(EntityType.ILLUSIONER, 34); + register(EntityType.ITEM, 35); + register(EntityType.ITEM_FRAME, 36); + register(EntityType.FIREBALL, 37); + register(EntityType.LEASH_KNOT, 38); + register(EntityType.LLAMA, 39); + register(EntityType.LLAMA_SPIT, 40); + register(EntityType.MAGMA_CUBE, 41); + register(EntityType.MINECART, 42); + register(EntityType.MINECART_CHEST, 43); + register(EntityType.MINECART_COMMAND_BLOCK, 44); + register(EntityType.MINECART_FURNACE, 45); + register(EntityType.MINECART_HOPPER, 46); + register(EntityType.MINECART_SPAWNER, 47); + register(EntityType.MINECART_TNT, 48); + register(EntityType.MULE, 49); + register(EntityType.MOOSHROOM, 50); + register(EntityType.OCELOT, 51); + register(EntityType.PAINTING, 52); + register(EntityType.PANDA, 53); + register(EntityType.PARROT, 54); + register(EntityType.PIG, 55); + register(EntityType.PUFFERFISH, 56); + register(EntityType.ZOMBIE_PIGMAN, 57); + register(EntityType.POLAR_BEAR, 58); + register(EntityType.PRIMED_TNT, 59); + register(EntityType.RABBIT, 60); + register(EntityType.SALMON, 61); + register(EntityType.SHEEP, 62); + register(EntityType.SHULKER, 63); + register(EntityType.SHULKER_BULLET, 64); + register(EntityType.SILVERFISH, 65); + register(EntityType.SKELETON, 66); + register(EntityType.SKELETON_HORSE, 67); + register(EntityType.SLIME, 68); + register(EntityType.SMALL_FIREBALL, 69); + register(EntityType.SNOW_GOLEM, 70); + register(EntityType.SNOWBALL, 71); + register(EntityType.SPECTRAL_ARROW, 72); + register(EntityType.SPIDER, 73); + register(EntityType.SQUID, 74); + register(EntityType.STRAY, 75); + register(EntityType.TRADER_LLAMA, 76); + register(EntityType.TROPICAL_FISH, 77); + register(EntityType.TURTLE, 78); + register(EntityType.THROWN_EGG, 79); + register(EntityType.THROWN_ENDERPEARL, 80); + register(EntityType.THROWN_EXP_BOTTLE, 81); + register(EntityType.THROWN_POTION, 82); + register(EntityType.TRIDENT, 83); + register(EntityType.VEX, 84); + register(EntityType.VILLAGER, 85); + register(EntityType.IRON_GOLEM, 86); + register(EntityType.VINDICATOR, 87); + register(EntityType.PILLAGER, 88); + register(EntityType.WANDERING_TRADER, 89); + register(EntityType.WITCH, 90); + register(EntityType.WITHER, 91); + register(EntityType.WITHER_SKELETON, 92); + register(EntityType.WITHER_SKULL, 93); + register(EntityType.WOLF, 94); + register(EntityType.ZOMBIE, 95); + register(EntityType.ZOMBIE_HORSE, 96); + register(EntityType.ZOMBIE_VILLAGER, 97); + register(EntityType.PHANTOM, 98); + register(EntityType.RAVAGER, 99); + register(EntityType.PLAYER, 101); + register(EntityType.FISHING_BOBBER, 102); register(MinecartType.NORMAL, 0); register(MinecartType.CHEST, 1); @@ -1213,7 +1176,7 @@ public class MagicValues { // Handle some protocol version translators that may send -1 for untranslatable IDs. // Choics are based on what (I think?) vanilla would default to. - register(MobType.PIG, -1); + register(EntityType.PIG, -1); register(BuiltinSound.ENTITY_ITEM_PICKUP, -1); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/FallingBlockData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/FallingBlockData.java similarity index 73% rename from src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/FallingBlockData.java rename to src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/FallingBlockData.java index 8d1bf0dd..9cb7fab0 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/FallingBlockData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/FallingBlockData.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.data.game.entity.type.object; +package com.github.steveice10.mc.protocol.data.game.entity.object; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/GenericObjectData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/GenericObjectData.java similarity index 70% rename from src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/GenericObjectData.java rename to src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/GenericObjectData.java index 804da28d..478801b7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/GenericObjectData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/GenericObjectData.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.data.game.entity.type.object; +package com.github.steveice10.mc.protocol.data.game.entity.object; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/HangingDirection.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/HangingDirection.java similarity index 61% rename from src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/HangingDirection.java rename to src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/HangingDirection.java index 3de1e7f2..0db456c7 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/HangingDirection.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/HangingDirection.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.data.game.entity.type.object; +package com.github.steveice10.mc.protocol.data.game.entity.object; public enum HangingDirection implements ObjectData { DOWN, diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/MinecartType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/MinecartType.java similarity index 66% rename from src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/MinecartType.java rename to src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/MinecartType.java index e246e0f5..7d57ac73 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/MinecartType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/MinecartType.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.data.game.entity.type.object; +package com.github.steveice10.mc.protocol.data.game.entity.object; public enum MinecartType implements ObjectData { NORMAL, diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/ObjectData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/ObjectData.java new file mode 100644 index 00000000..c5728d85 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/ObjectData.java @@ -0,0 +1,4 @@ +package com.github.steveice10.mc.protocol.data.game.entity.object; + +public interface ObjectData { +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ProjectileData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/ProjectileData.java similarity index 69% rename from src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ProjectileData.java rename to src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/ProjectileData.java index 0d5aa240..cdacdc2f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ProjectileData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/ProjectileData.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.data.game.entity.type.object; +package com.github.steveice10.mc.protocol.data.game.entity.object; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/SplashPotionData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/SplashPotionData.java similarity index 70% rename from src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/SplashPotionData.java rename to src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/SplashPotionData.java index 67bf5268..64d6e723 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/SplashPotionData.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/object/SplashPotionData.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.data.game.entity.type.object; +package com.github.steveice10.mc.protocol.data.game.entity.object; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/MobType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/EntityType.java similarity index 98% rename from src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/MobType.java rename to src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/EntityType.java index c841a94d..89217e3f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/MobType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/EntityType.java @@ -1,6 +1,6 @@ package com.github.steveice10.mc.protocol.data.game.entity.type; -public enum MobType { +public enum EntityType { AREA_EFFECT_CLOUD, ARMOR_STAND, ARROW, diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/GlobalEntityType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/WeatherEntityType.java similarity index 73% rename from src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/GlobalEntityType.java rename to src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/WeatherEntityType.java index e1f76268..0192e304 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/GlobalEntityType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/WeatherEntityType.java @@ -1,5 +1,5 @@ package com.github.steveice10.mc.protocol.data.game.entity.type; -public enum GlobalEntityType { +public enum WeatherEntityType { LIGHTNING_BOLT; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ObjectData.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ObjectData.java deleted file mode 100644 index 417eff41..00000000 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ObjectData.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.github.steveice10.mc.protocol.data.game.entity.type.object; - -public interface ObjectData { -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ObjectType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ObjectType.java deleted file mode 100644 index 4964c8fe..00000000 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/object/ObjectType.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.github.steveice10.mc.protocol.data.game.entity.type.object; - -public enum ObjectType { - EVOKER_FANGS, - AREA_EFFECT_CLOUD, - ARROW, - ARMOR_STAND, - BOAT, - DRAGON_FIREBALL, - END_CRYSTAL, - EXPERIENCE_ORB, - EYE_OF_ENDER, - FALLING_BLOCK, - FIREWORK_ROCKET, - ITEM, - ITEM_FRAME, - FIREBALL, - LEASH_KNOT, - LLAMA_SPIT, - MINECART, - CHEST_MINECART, - COMMAND_BLOCK_MINECART, - FURNACE_MINECART, - HOPPER_MINECART, - SPAWNER_MINECART, - TNT_MINECART, - TNT, - SMALL_FIREBALL, - SNOWBALL, - SPECTRAL_ARROW, - SHULKER_BULLET, - EGG, - ENDER_PEARL, - EXPERIENCE_BOTTLE, - POTION, - TRIDENT, - WITHER_SKULL, - FISHING_BOBBER, -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnObjectPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnEntityPacket.java similarity index 71% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnObjectPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnEntityPacket.java index 3643110b..07572b97 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnObjectPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnEntityPacket.java @@ -1,14 +1,14 @@ package com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn; import com.github.steveice10.mc.protocol.data.MagicValues; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.FallingBlockData; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.GenericObjectData; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.HangingDirection; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.MinecartType; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectData; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.ProjectileData; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.SplashPotionData; +import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType; +import com.github.steveice10.mc.protocol.data.game.entity.object.FallingBlockData; +import com.github.steveice10.mc.protocol.data.game.entity.object.GenericObjectData; +import com.github.steveice10.mc.protocol.data.game.entity.object.HangingDirection; +import com.github.steveice10.mc.protocol.data.game.entity.object.MinecartType; +import com.github.steveice10.mc.protocol.data.game.entity.object.ObjectData; +import com.github.steveice10.mc.protocol.data.game.entity.object.ProjectileData; +import com.github.steveice10.mc.protocol.data.game.entity.object.SplashPotionData; import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; @@ -26,10 +26,10 @@ import java.util.UUID; @Setter(AccessLevel.NONE) @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor -public class ServerSpawnObjectPacket implements Packet { +public class ServerSpawnEntityPacket implements Packet { private int entityId; private @NonNull UUID uuid; - private @NonNull ObjectType type; + private @NonNull EntityType type; private @NonNull ObjectData data; private double x; private double y; @@ -40,17 +40,17 @@ public class ServerSpawnObjectPacket implements Packet { private double motionY; private double motionZ; - public ServerSpawnObjectPacket(int entityId, @NonNull UUID uuid, @NonNull ObjectType type, + public ServerSpawnEntityPacket(int entityId, @NonNull UUID uuid, @NonNull EntityType type, double x, double y, double z, float yaw, float pitch) { this(entityId, uuid, type, new GenericObjectData(0), x, y, z, yaw, pitch, 0, 0, 0); } - public ServerSpawnObjectPacket(int entityId, @NonNull UUID uuid, @NonNull ObjectType type, @NonNull ObjectData data, + public ServerSpawnEntityPacket(int entityId, @NonNull UUID uuid, @NonNull EntityType type, @NonNull ObjectData data, double x, double y, double z, float yaw, float pitch) { this(entityId, uuid, type, data, x, y, z, yaw, pitch, 0, 0, 0); } - public ServerSpawnObjectPacket(int entityId, @NonNull UUID uuid, @NonNull ObjectType type, + public ServerSpawnEntityPacket(int entityId, @NonNull UUID uuid, @NonNull EntityType type, double x, double y, double z, float yaw, float pitch, double motionX, double motionY, double motionZ) { this(entityId, uuid, type, new GenericObjectData(0), x, y, z, yaw, pitch, motionX, motionY, motionZ); @@ -60,7 +60,7 @@ public class ServerSpawnObjectPacket implements Packet { public void read(NetInput in) throws IOException { this.entityId = in.readVarInt(); this.uuid = in.readUUID(); - this.type = MagicValues.key(ObjectType.class, in.readVarInt()); + this.type = MagicValues.key(EntityType.class, in.readVarInt()); this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); @@ -68,16 +68,16 @@ public class ServerSpawnObjectPacket implements Packet { this.yaw = in.readByte() * 360 / 256f; int data = in.readInt(); - if(this.type == ObjectType.MINECART) { + if(this.type == EntityType.MINECART) { this.data = MagicValues.key(MinecartType.class, data); - } else if(this.type == ObjectType.ITEM_FRAME) { + } else if(this.type == EntityType.ITEM_FRAME) { this.data = MagicValues.key(HangingDirection.class, data); - } else if(this.type == ObjectType.FALLING_BLOCK) { + } else if(this.type == EntityType.FALLING_BLOCK) { this.data = new FallingBlockData(data & 65535, data >> 16); - } else if(this.type == ObjectType.POTION) { + } else if(this.type == EntityType.THROWN_POTION) { this.data = new SplashPotionData(data); - } else if(this.type == ObjectType.SPECTRAL_ARROW || this.type == ObjectType.FIREBALL || this.type == ObjectType.SMALL_FIREBALL - || this.type == ObjectType.DRAGON_FIREBALL || this.type == ObjectType.WITHER_SKULL || this.type == ObjectType.FISHING_BOBBER) { + } else if(this.type == EntityType.SPECTRAL_ARROW || this.type == EntityType.FIREBALL || this.type == EntityType.SMALL_FIREBALL + || this.type == EntityType.DRAGON_FIREBALL || this.type == EntityType.WITHER_SKULL || this.type == EntityType.FISHING_BOBBER) { this.data = new ProjectileData(data); } else { this.data = new GenericObjectData(data); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnMobPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnLivingEntityPacket.java similarity index 89% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnMobPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnLivingEntityPacket.java index 8becea08..e23599e9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnMobPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnLivingEntityPacket.java @@ -1,7 +1,7 @@ package com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn; import com.github.steveice10.mc.protocol.data.MagicValues; -import com.github.steveice10.mc.protocol.data.game.entity.type.MobType; +import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType; import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; @@ -19,10 +19,10 @@ import java.util.UUID; @Setter(AccessLevel.NONE) @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor -public class ServerSpawnMobPacket implements Packet { +public class ServerSpawnLivingEntityPacket implements Packet { private int entityId; private @NonNull UUID uuid; - private @NonNull MobType type; + private @NonNull EntityType type; private double x; private double y; private double z; @@ -37,7 +37,7 @@ public class ServerSpawnMobPacket implements Packet { public void read(NetInput in) throws IOException { this.entityId = in.readVarInt(); this.uuid = in.readUUID(); - this.type = MagicValues.key(MobType.class, in.readVarInt()); + this.type = MagicValues.key(EntityType.class, in.readVarInt()); this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPaintingPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPaintingPacket.java index 14de45d7..66e93886 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPaintingPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnPaintingPacket.java @@ -3,7 +3,7 @@ package com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn; import com.github.steveice10.mc.protocol.data.MagicValues; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.HangingDirection; +import com.github.steveice10.mc.protocol.data.game.entity.object.HangingDirection; import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnGlobalEntityPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnWeatherEntityPacket.java similarity index 82% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnGlobalEntityPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnWeatherEntityPacket.java index 24a87858..cddd8816 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnGlobalEntityPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/entity/spawn/ServerSpawnWeatherEntityPacket.java @@ -1,7 +1,7 @@ package com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn; import com.github.steveice10.mc.protocol.data.MagicValues; -import com.github.steveice10.mc.protocol.data.game.entity.type.GlobalEntityType; +import com.github.steveice10.mc.protocol.data.game.entity.type.WeatherEntityType; import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; @@ -18,9 +18,9 @@ import java.io.IOException; @Setter(AccessLevel.NONE) @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor -public class ServerSpawnGlobalEntityPacket implements Packet { +public class ServerSpawnWeatherEntityPacket implements Packet { private int entityId; - private @NonNull GlobalEntityType type; + private @NonNull WeatherEntityType type; private double x; private double y; private double z; @@ -28,7 +28,7 @@ public class ServerSpawnGlobalEntityPacket implements Packet { @Override public void read(NetInput in) throws IOException { this.entityId = in.readVarInt(); - this.type = MagicValues.key(GlobalEntityType.class, in.readByte()); + this.type = MagicValues.key(WeatherEntityType.class, in.readByte()); this.x = in.readDouble(); this.y = in.readDouble(); this.z = in.readDouble(); diff --git a/src/test/java/com/github/steveice10/mc/protocol/data/MagicValuesTest.java b/src/test/java/com/github/steveice10/mc/protocol/data/MagicValuesTest.java index 5834186f..4e5cad33 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/data/MagicValuesTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/data/MagicValuesTest.java @@ -32,12 +32,11 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState; import com.github.steveice10.mc.protocol.data.game.entity.player.PositionElement; -import com.github.steveice10.mc.protocol.data.game.entity.type.GlobalEntityType; -import com.github.steveice10.mc.protocol.data.game.entity.type.MobType; +import com.github.steveice10.mc.protocol.data.game.entity.type.WeatherEntityType; +import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType; import com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.HangingDirection; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.MinecartType; -import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType; +import com.github.steveice10.mc.protocol.data.game.entity.object.HangingDirection; +import com.github.steveice10.mc.protocol.data.game.entity.object.MinecartType; import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType; import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule; import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility; @@ -145,9 +144,8 @@ public class MagicValuesTest { this.register(Effect.class, Integer.class); this.register(EntityStatus.class, Integer.class); this.register(PositionElement.class, Integer.class); - this.register(GlobalEntityType.class, Integer.class); - this.register(MobType.class, Integer.class); - this.register(ObjectType.class, Integer.class); + this.register(WeatherEntityType.class, Integer.class); + this.register(EntityType.class, Integer.class); this.register(MinecartType.class, Integer.class); this.register(HangingDirection.class, Integer.class); this.register(PaintingType.class, Integer.class);