From 35506f8befb0618a5814c4938258d65b6faa7cf7 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Sat, 25 Apr 2020 18:58:34 -0400 Subject: [PATCH 1/5] Add default copyright to files (#409) --- .idea/copyright/Geyser.xml | 6 ++++++ .idea/copyright/profiles_settings.xml | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 .idea/copyright/Geyser.xml create mode 100644 .idea/copyright/profiles_settings.xml diff --git a/.idea/copyright/Geyser.xml b/.idea/copyright/Geyser.xml new file mode 100644 index 00000000..568fa7b8 --- /dev/null +++ b/.idea/copyright/Geyser.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 00000000..f2d5911c --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file From 0caecf68db6fc68462d1d62af09857c1a25e9495 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Sun, 26 Apr 2020 00:54:42 -0400 Subject: [PATCH 2/5] Only add entity to entity cache if ID doesn't exist (#428) --- .../network/session/cache/EntityCache.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java index f0b394fd..80d10b1a 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java @@ -58,13 +58,19 @@ public class EntityCache { } public void spawnEntity(Entity entity) { - cacheEntity(entity); - entity.spawnEntity(session); + if (cacheEntity(entity)) { + entity.spawnEntity(session); + } } - public void cacheEntity(Entity entity) { - entityIdTranslations.put(entity.getEntityId(), entity.getGeyserId()); - entities.put(entity.getGeyserId(), entity); + public boolean cacheEntity(Entity entity) { + // Check to see if the entity exists, otherwise we can end up with duplicated mobs + if (!entityIdTranslations.containsKey(entity.getEntityId())) { + entityIdTranslations.put(entity.getEntityId(), entity.getGeyserId()); + entities.put(entity.getGeyserId(), entity); + return true; + } + return false; } public boolean removeEntity(Entity entity, boolean force) { From 257918904b5c4a599b75e7d27714578afcf7e04c Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sun, 26 Apr 2020 05:55:06 +0100 Subject: [PATCH 3/5] Fixed spawn egg colours not loading in (#429) --- .../network/session/GeyserSession.java | 14 +++++--------- .../org/geysermc/connector/utils/Toolbox.java | 13 +++++++++++++ .../resources/bedrock/entity_identifiers.dat | Bin 8349 -> 8477 bytes 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index fdfc1471..6d1d61d4 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -30,8 +30,8 @@ import com.github.steveice10.mc.auth.exception.request.InvalidCredentialsExcepti import com.github.steveice10.mc.auth.exception.request.RequestException; import com.github.steveice10.mc.protocol.MinecraftProtocol; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; -import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket; import com.github.steveice10.mc.protocol.packet.handshake.client.HandshakePacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket; import com.github.steveice10.packetlib.Client; import com.github.steveice10.packetlib.event.session.*; import com.github.steveice10.packetlib.packet.Packet; @@ -42,22 +42,17 @@ import com.nukkitx.math.vector.Vector2f; import com.nukkitx.math.vector.Vector2i; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3i; +import com.nukkitx.nbt.NbtUtils; +import com.nukkitx.nbt.stream.NBTInputStream; import com.nukkitx.nbt.tag.CompoundTag; import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.data.ContainerId; import com.nukkitx.protocol.bedrock.data.GamePublishSetting; -import com.nukkitx.protocol.bedrock.packet.AvailableEntityIdentifiersPacket; -import com.nukkitx.protocol.bedrock.packet.BiomeDefinitionListPacket; -import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket; -import com.nukkitx.protocol.bedrock.packet.StartGamePacket; -import com.nukkitx.protocol.bedrock.packet.TextPacket; import com.nukkitx.protocol.bedrock.data.GameRuleData; import com.nukkitx.protocol.bedrock.data.PlayerPermission; import com.nukkitx.protocol.bedrock.packet.*; - import lombok.Getter; import lombok.Setter; - import org.geysermc.common.AuthType; import org.geysermc.common.window.FormWindow; import org.geysermc.connector.GeyserConnector; @@ -77,6 +72,7 @@ import org.geysermc.floodgate.util.BedrockData; import org.geysermc.floodgate.util.EncryptionUtil; import java.io.IOException; +import java.io.InputStream; import java.net.InetSocketAddress; import java.security.NoSuchAlgorithmException; import java.security.PublicKey; @@ -166,7 +162,7 @@ public class GeyserSession implements CommandSender { upstream.sendPacket(biomeDefinitionListPacket); AvailableEntityIdentifiersPacket entityPacket = new AvailableEntityIdentifiersPacket(); - entityPacket.setTag(CompoundTag.EMPTY); + entityPacket.setTag(Toolbox.ENTITY_IDENTIFIERS); upstream.sendPacket(entityPacket); InventoryContentPacket creativePacket = new InventoryContentPacket(); diff --git a/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java b/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java index bb8075f8..09e2531c 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java +++ b/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java @@ -55,6 +55,8 @@ public class Toolbox { public static final Int2ObjectMap ITEM_ENTRIES = new Int2ObjectOpenHashMap<>(); + public static CompoundTag ENTITY_IDENTIFIERS; + public static int BARRIER_INDEX = 0; static { @@ -136,6 +138,7 @@ public class Toolbox { // Load the locale data LocaleUtils.init(); + /* Load creative items */ stream = getResource("bedrock/creative_items.json"); JsonNode creativeItemEntries; @@ -165,6 +168,16 @@ public class Toolbox { } } CREATIVE_ITEMS = creativeItems.toArray(new ItemData[0]); + + + /* Load entity identifiers */ + stream = Toolbox.getResource("bedrock/entity_identifiers.dat"); + + try (NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream)) { + ENTITY_IDENTIFIERS = (CompoundTag) nbtInputStream.readTag(); + } catch (Exception e) { + throw new AssertionError("Unable to get entities from entity identifiers", e); + } } /** diff --git a/connector/src/main/resources/bedrock/entity_identifiers.dat b/connector/src/main/resources/bedrock/entity_identifiers.dat index c4f1524a7b62a17d3d73b880eb99dace8737ba0c..cb8f0481b3198720f3e2ae0335b7ab2711ed6cb7 100644 GIT binary patch literal 8477 zcmbW7|I1}V9LMkVY+8@+thLtKHc67CP0}Vwk|arzBxBAwbI%!f&Y5Fo?!C{m`9a(M zAW4!WKS+`!Ns=EVNq&$dX_F*Lk{|pa`2)_1CpmzA;-so^7c zVk(v5xiD;ceE&uwv%$uOk=Y-^!Jdi3hIoEUOt}NnD^$`&Ey+!cQvzTwQ(+gku(Xir zSX4keu>KiqnFHt$5p-dz$`(S@fI3V>UC^RtT8)5oBqj}3cp_x*l9sgV37{Q~X{#I- zXqUFMQfpfntxLciBjPY(PfcV7sH=%6@R#99BGIhZ5Lw{*By#<=F^CfU5IAm7);k^B z_u>w;(U(S7EZ0h4_^*rQ^=1=drcajTSS;@w*GKs#R&sE~2_gz2R%^u# zO9VH-yOqd;YRV_vWRhd&Nr*IvS8_#o*?RkicdARps%h41*=Z|eRx;OzIrdV9|f9ndO& zqXN{uL=+@NR6dHau=|KK==D~r=|Zo+pU8ttValh1EoAxuA`l{%``alljSmu0aMqIh zgtBy!U?v_S@<3Xm_(?=P9HV;u47D*|Gr%B4%v$BOa4$cyVBg)HAikdeNv#WLSeeoO zkpNehpQ$v6o^^)fxO{ByCl2>SXnsQZl3+`=5s}dfL4|%BzUb*O!?AC`FK5ZU#z>3ot)*D2anxR**%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+1;P%t|d(3^!U^rNx!opby_ArPLFiJI&7qSD*Y z9ugA4+$r6JStUO#WP!Q4q8DG3G%?!_9uWdTTx``b#(I>q28#rmS8vn6_WBs7O0tFS z90_|@J-&BVMaOIQ#CSr;f_)%ssu`O2q!0y;`|p&qe4!!rDIpc+`Lt0!HT*sh3vtj` zwQX-LtDvb63i&)YMM`hy+Oeh23xTjIl$k1OKHBTO)4ZDZFZOdz8>|m#qRTL2bTc6g zrttFgm3lShufL}`aK>AY$udapOq z26@ovmCqfWPiq>Q7?NYVR~TMe&=JU1wjMkyRR;?ZEm^4QxBwMo!Le{chx~AQZ#M&k zo)AF8F%F`;S<)%L?mhpWmja6p*IXT2_^LXT+A8*St>=UCw1kTPLbEj!N2FGOz& zu)(XahqQMm_O1FYDGXXgyIl7_U%f5mK{3+De5{*y1gH>bkX9;F)D#osy({HG;?(q# ST@>_Do)%W#GF};vM*jd1UwL`} From 2fabcefb8de04529eeb2913455a684a330ff7215 Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sun, 26 Apr 2020 05:55:20 +0100 Subject: [PATCH 4/5] Fixed error when certain items are spawned from the creative inventory (#430) --- .../connector/network/translators/ItemStackTranslator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/ItemStackTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/ItemStackTranslator.java index ac4bb2f2..356dcf98 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/ItemStackTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/ItemStackTranslator.java @@ -54,7 +54,7 @@ public abstract class ItemStackTranslator { public ItemStack translateToJava(ItemData itemData, ItemEntry itemEntry) { if (itemData == null) return null; if (itemData.getTag() == null) { - return new ItemStack(itemEntry.getJavaId(), itemData.getCount()); + return new ItemStack(itemEntry.getJavaId(), itemData.getCount(), new com.github.steveice10.opennbt.tag.builtin.CompoundTag("")); } return new ItemStack(itemEntry.getJavaId(), itemData.getCount(), this.translateToJavaNBT(itemData.getTag())); } From 08b7857292e3629e23d36fa49457295dd2df3bc7 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 26 Apr 2020 00:24:06 -0500 Subject: [PATCH 5/5] Remove unused imports in GeyserSession --- .../org/geysermc/connector/network/session/GeyserSession.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 6d1d61d4..95c8c030 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -42,9 +42,6 @@ import com.nukkitx.math.vector.Vector2f; import com.nukkitx.math.vector.Vector2i; import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3i; -import com.nukkitx.nbt.NbtUtils; -import com.nukkitx.nbt.stream.NBTInputStream; -import com.nukkitx.nbt.tag.CompoundTag; import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.data.ContainerId; import com.nukkitx.protocol.bedrock.data.GamePublishSetting; @@ -72,7 +69,6 @@ import org.geysermc.floodgate.util.BedrockData; import org.geysermc.floodgate.util.EncryptionUtil; import java.io.IOException; -import java.io.InputStream; import java.net.InetSocketAddress; import java.security.NoSuchAlgorithmException; import java.security.PublicKey;