diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index fabed677..b294ed34 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -50,7 +50,6 @@ import org.geysermc.connector.plugin.GeyserPluginLoader; import org.geysermc.connector.plugin.GeyserPluginManager; import org.geysermc.connector.thread.PingPassthroughThread; import org.geysermc.connector.utils.FileUtils; -import org.geysermc.connector.utils.Toolbox; import java.io.File; import java.io.IOException; @@ -117,7 +116,6 @@ public class GeyserConnector implements Connector { try { File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString())); - config = FileUtils.loadConfig(configFile, GeyserConfiguration.class); } catch (IOException ex) { logger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex); 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 c7994858..649f6e85 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 @@ -29,7 +29,6 @@ import com.github.steveice10.mc.auth.data.GameProfile; 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.data.game.world.block.BlockFace; import com.github.steveice10.packetlib.Client; import com.github.steveice10.packetlib.event.session.ConnectedEvent; import com.github.steveice10.packetlib.event.session.DisconnectedEvent; @@ -296,7 +295,7 @@ public class GeyserSession implements Player { startGamePacket.setCurrentTick(0); startGamePacket.setEnchantmentSeed(0); startGamePacket.setMultiplayerCorrelationId(""); - startGamePacket.setBlockPalette(Toolbox.CACHED_PALLETE); + startGamePacket.setBlockPalette(Toolbox.BLOCKS); startGamePacket.setItemEntries(Toolbox.ITEMS); startGamePacket.setMovementServerAuthoritative(true); upstream.sendPacket(startGamePacket); 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 f5e9a20d..2d84249b 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java +++ b/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java @@ -21,34 +21,31 @@ import java.util.*; public class Toolbox { public static final Collection ITEMS; - public static ListTag CACHED_PALLETE; + public static ListTag BLOCKS; public static final TIntObjectMap ITEM_ENTRIES; public static final TIntObjectMap BLOCK_ENTRIES; static { - InputStream stream = GeyserConnector.class.getClassLoader().getResourceAsStream("bedrock/cached_palette.dat"); + InputStream stream = GeyserConnector.class.getClassLoader().getResourceAsStream("bedrock/runtime_block_states.dat"); if (stream == null) { - throw new AssertionError("Unable to find cached_palette.dat"); + throw new AssertionError("Unable to find bedrock/runtime_block_states.dat"); } Map blockIdToIdentifier = new HashMap<>(); - CompoundTag tag; + ListTag blocksTag; - NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream); + NBTInputStream nbtInputStream = NbtUtils.createReader(stream); try { - tag = (CompoundTag) nbtInputStream.readTag(); - System.out.println(tag.getValue().values()); - System.out.println(tag.getAsList("Palette", CompoundTag.class)); + blocksTag = (ListTag) nbtInputStream.readTag(); nbtInputStream.close(); } catch (Exception ex) { - GeyserLogger.DEFAULT.warning("Failed to get blocks from cached palette, please report this error!"); + GeyserLogger.DEFAULT.warning("Failed to get blocks from runtime block states, please report this error!"); throw new AssertionError(ex); } - List entries = tag.getAsList("Palette", CompoundTag.class); - for (CompoundTag entry : entries) { - String name = entry.getAsString("name"); + for (CompoundTag entry : blocksTag.getValue()) { + String name = entry.getAsCompound("block").getAsString("name"); int id = entry.getAsShort("id"); int data = entry.getAsShort("meta"); @@ -56,7 +53,7 @@ public class Toolbox { GlobalBlockPalette.registerMapping(id << 4 | data); } - CACHED_PALLETE = new ListTag<>("Palette", CompoundTag.class, tag.getAsList("Palette", CompoundTag.class)); + BLOCKS = blocksTag; InputStream stream2 = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/items.json"); if (stream2 == null) { throw new AssertionError("Items Table not found"); @@ -112,7 +109,7 @@ public class Toolbox { for (Map.Entry> itemEntry : blocks.entrySet()) { if (!blockIdToIdentifier.containsKey(itemEntry.getValue().get("bedrock_identifier"))) { - GeyserLogger.DEFAULT.debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " does not exist on bedrock edition!"); + GeyserLogger.DEFAULT.debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " was not found for bedrock edition!"); blockEntries.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, 248, 0)); // update block } else { blockEntries.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, blockIdToIdentifier.get(itemEntry.getValue().get("bedrock_identifier")), (int) itemEntry.getValue().get("bedrock_data"))); diff --git a/connector/src/main/resources/bedrock/cached_palette.dat b/connector/src/main/resources/bedrock/runtime_block_states.dat similarity index 53% rename from connector/src/main/resources/bedrock/cached_palette.dat rename to connector/src/main/resources/bedrock/runtime_block_states.dat index 32c99394..8e49d318 100644 Binary files a/connector/src/main/resources/bedrock/cached_palette.dat and b/connector/src/main/resources/bedrock/runtime_block_states.dat differ