From 257918904b5c4a599b75e7d27714578afcf7e04c Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sun, 26 Apr 2020 05:55:06 +0100 Subject: [PATCH] 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**%3FVJ z8(ca3{sNj#5lBH4Ove#dN>=%N^aArVf!R&OR?QOa;upJTsXS<>o~KO$;+`YG!hx@X zPOvSQ9)Hs3D>-RGMdr8L-}<6jBVrYA!41(*d}*sW@`FKDYjPJ7Od7z zMw8?{0yBgW+V#BpYX4e??t7m=3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