diff --git a/README.md b/README.md
index 2a8fd14e..0108781c 100644
--- a/README.md
+++ b/README.md
@@ -13,39 +13,31 @@ Geyser is a bridge between Minecraft: Bedrock Edition and Minecraft: Java Editio
Geyser is a proxy, bridging the gap between Minecraft: Bedrock Edition and Minecraft: Java Edition servers.
The ultimate goal of this project is to allow Minecraft: Bedrock Edition users to join Minecraft: Java Edition servers as seamlessly as possible.
-### Please note, this project is still a work in progress and should not be used on production.
+### Please note, this project is still a work in progress and should not be used on production. Expect bugs!
## Setting Up
-Please note, Geyser is **not** a plugin. Watch the video below or take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up.
+Please note, Geyser is **not** (currently) a plugin. Watch the video below or take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up.
-[![YouTube Video](https://img.youtube.com/vi/OmLxwl7_UzQ/0.jpg)](https://www.youtube.com/watch?v=OmLxwl7_UzQ)
+[![YouTube Video](https://img.youtube.com/vi/U7dZZ8w7Gi4/0.jpg)](https://www.youtube.com/watch?v=U7dZZ8w7Gi4)
-Links:
+## Links:
- Website: https://geysermc.org
- Docs: https://github.com/GeyserMC/Geyser/wiki
- Download: http://ci.geysermc.org
- Discord: http://discord.geysermc.org/
+- Donate: https://patreon.com/GeyserMC
-## What's Completed
-- [x] Server recognized in server list
-- [x] Join detection from remote
-- [x] Online mode/auth support
-- [x] Chat/command support
-- [x] Scoreboard
-- [ ] Inventory support
- - [x] Inventory viewing
- - [x] NBT data
- - [ ] Inventory movement (transactions)
-- [x] Player movement support
-- [x] Entity support
-- [x] Player support
-- [ ] Chunks
- - [x] Block translation (may be missing mappings)
- - [x] Block updates
- - [ ] Block entities
- - [x] Extra data
- - [ ] Biome colors
-- [x] Block break/place support
+## What's Left to be Added/Fixed
+- Inventories ([#67](https://github.com/GeyserMC/Geyser/pull/67))
+- Crafting ([#67](https://github.com/GeyserMC/Geyser/pull/67))
+- Creative Mode ([#67](https://github.com/GeyserMC/Geyser/pull/67))
+- Sounds
+- Block Particles
+- Block Entities ([`block-entities`](https://github.com/GeyserMC/Geyser/tree/block-entities))
+- Biome Colors
+- Some Entity Flags
+- Proper Movement
+- Support to be Ran as a Plugin ([`plugin`](https://github.com/GeyserMC/Geyser/tree/plugin))
## Compiling
1. Clone the repo to your computer
diff --git a/connector/pom.xml b/connector/pom.xml
index ee8b9049..82e3adb1 100644
--- a/connector/pom.xml
+++ b/connector/pom.xml
@@ -66,8 +66,8 @@
com.nukkitx.protocol
- bedrock-v388
- 2.4.2
+ bedrock-v389
+ 2.4.4
compile
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
index 46443ffa..8b6638da 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
@@ -27,7 +27,7 @@ package org.geysermc.connector;
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
import com.nukkitx.protocol.bedrock.BedrockServer;
-import com.nukkitx.protocol.bedrock.v388.Bedrock_v388;
+import com.nukkitx.protocol.bedrock.v389.Bedrock_v389;
import lombok.Getter;
import org.fusesource.jansi.AnsiConsole;
@@ -67,8 +67,7 @@ import java.util.concurrent.TimeUnit;
@Getter
public class GeyserConnector implements Connector {
- public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v388.V388_CODEC;
- public static final int BEDROCK_1_14_PROTOCOL_VERSION = 389;
+ public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v389.V389_CODEC;
public static final String NAME = "Geyser";
public static final String VERSION = "1.0-SNAPSHOT";
diff --git a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java
index 555e54e6..1709fcb1 100644
--- a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java
+++ b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java
@@ -45,7 +45,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
@Override
public boolean handle(LoginPacket loginPacket) {
- if (loginPacket.getProtocolVersion() != GeyserConnector.BEDROCK_1_14_PROTOCOL_VERSION) {
+ if (loginPacket.getProtocolVersion() != GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion()) {
session.getUpstream().disconnect("Unsupported Bedrock version. Are you running an outdated version?");
return true;
}
@@ -72,7 +72,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
ResourcePackStackPacket stack = new ResourcePackStackPacket();
stack.setExperimental(false);
stack.setForcedToAccept(false);
- stack.setGameVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
+ stack.setGameVersion("*");
session.getUpstream().sendPacket(stack);
break;
default:
@@ -131,4 +131,4 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
public boolean handle(InventoryTransactionPacket packet) {
return translateAndDefault(packet);
}
-}
\ No newline at end of file
+}
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 623e93ce..62b96473 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
@@ -331,7 +331,7 @@ public class GeyserSession implements Player {
startGamePacket.setMultiplayerCorrelationId("");
startGamePacket.setBlockPalette(Toolbox.BLOCKS);
startGamePacket.setItemEntries(Toolbox.ITEMS);
- startGamePacket.setVanillaVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion());
+ startGamePacket.setVanillaVersion("*");
// startGamePacket.setMovementServerAuthoritative(true);
upstream.sendPacket(startGamePacket);
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
index 44de2b00..3ff1b7f9 100644
--- a/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
+++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
@@ -79,7 +79,7 @@ public class ChunkCache {
Position blockPosition = chunkPosition.getChunkBlock(position.getX(), position.getY(), position.getZ());
if (chunk != null) {
BlockState blockState = chunk.get(blockPosition.getX(), blockPosition.getY(), blockPosition.getZ());
- return TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);
+ return TranslatorsInit.getBlockTranslator().getBlockEntry(blockState);
}
return BlockEntry.AIR;
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockEntry.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockEntry.java
index 47edde73..ab126eeb 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockEntry.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockEntry.java
@@ -25,23 +25,30 @@
package org.geysermc.connector.network.translators.block;
-import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
-@AllArgsConstructor
public class BlockEntry {
- public static BlockEntry AIR = new BlockEntry("minecraft:air", 0, 0, 0);
+ public static BlockEntry AIR = new BlockEntry("minecraft:air", 0, 0);
- private String javaIdentifier;
- private int javaId;
+ private final String javaIdentifier;
+ private final int javaId;
+ private final int bedrockRuntimeId;
+ private final boolean waterlogged;
- private int bedrockId;
- private int bedrockData;
+ public BlockEntry(String javaIdentifier, int javaId, int bedrockRuntimeId) {
+ this.javaIdentifier = javaIdentifier;
+ this.javaId = javaId;
+ this.bedrockRuntimeId = bedrockRuntimeId;
+ this.waterlogged = (javaIdentifier.contains("waterlogged=true")
+ || javaIdentifier.startsWith("minecraft:kelp")
+ || javaIdentifier.contains("seagrass")
+ || javaIdentifier.startsWith("minecraft:bubble_column"));
+ }
@Override
public boolean equals(Object obj) {
- return obj == this || (obj instanceof BlockEntry && ((BlockEntry) obj).getBedrockId() == this.getBedrockId() && ((BlockEntry) obj).getJavaIdentifier().equals(this.getJavaIdentifier()));
+ return obj == this || (obj instanceof BlockEntry && ((BlockEntry) obj).getBedrockRuntimeId() == this.getBedrockRuntimeId() && ((BlockEntry) obj).getJavaIdentifier().equals(this.getJavaIdentifier()));
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java
index c9a967da..7ff630c3 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/block/BlockTranslator.java
@@ -3,9 +3,18 @@ package org.geysermc.connector.network.translators.block;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
import org.geysermc.connector.utils.Toolbox;
-public class BlockTranslator {
+import java.util.HashMap;
+import java.util.Map;
- public BlockEntry getBedrockBlock(BlockState state) {
+public class BlockTranslator {
+ private final Map javaIdentifierMap = new HashMap<>();
+
+ public BlockEntry getBlockEntry(BlockState state) {
return Toolbox.BLOCK_ENTRIES.get(state.getId());
}
+
+ public BlockEntry getBlockEntry(String javaIdentifier) {
+ return javaIdentifierMap.computeIfAbsent(javaIdentifier, key -> Toolbox.BLOCK_ENTRIES.values()
+ .stream().filter(blockEntry -> blockEntry.getJavaIdentifier().equals(key)).findFirst().orElse(null));
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerActionAckTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerActionAckTranslator.java
index 3213a2fd..df2c914f 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerActionAckTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerActionAckTranslator.java
@@ -26,13 +26,9 @@
package org.geysermc.connector.network.translators.java.entity.player;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket;
-import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
-import org.geysermc.connector.network.translators.TranslatorsInit;
-import org.geysermc.connector.network.translators.block.BlockEntry;
-import org.geysermc.connector.world.GlobalBlockPalette;
+import org.geysermc.connector.utils.ChunkUtils;
public class JavaPlayerActionAckTranslator extends PacketTranslator {
@@ -40,18 +36,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator {
+
@Override
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
- BlockChangeRecord record = packet.getRecord();
- UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
- updateBlockPacket.setDataLayer(0);
- updateBlockPacket.setBlockPosition(Vector3i.from(
- record.getPosition().getX(),
- record.getPosition().getY(),
- record.getPosition().getZ()
- ));
-
- BlockEntry itemEntry = TranslatorsInit.getBlockTranslator().getBedrockBlock(record.getBlock());
- updateBlockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(itemEntry.getBedrockId() << 4 | itemEntry.getBedrockData()));
- updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
-
- session.getUpstream().sendPacket(updateBlockPacket);
+ ChunkUtils.updateBlock(session, packet.getRecord().getBlock(), packet.getRecord().getPosition());
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMultiBlockChangeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMultiBlockChangeTranslator.java
index 14864b8c..9f4e36cc 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMultiBlockChangeTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMultiBlockChangeTranslator.java
@@ -27,32 +27,16 @@ package org.geysermc.connector.network.translators.java.world;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerMultiBlockChangePacket;
-import com.nukkitx.math.vector.Vector3i;
-import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
-import org.geysermc.connector.network.translators.TranslatorsInit;
-import org.geysermc.connector.network.translators.block.BlockEntry;
-import org.geysermc.connector.world.GlobalBlockPalette;
+import org.geysermc.connector.utils.ChunkUtils;
public class JavaMultiBlockChangeTranslator extends PacketTranslator {
@Override
public void translate(ServerMultiBlockChangePacket packet, GeyserSession session) {
for (BlockChangeRecord record : packet.getRecords()) {
- UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
- updateBlockPacket.setDataLayer(0);
- updateBlockPacket.setBlockPosition(Vector3i.from(
- record.getPosition().getX(),
- record.getPosition().getY(),
- record.getPosition().getZ()
- ));
-
- BlockEntry blockEntry = TranslatorsInit.getBlockTranslator().getBedrockBlock(record.getBlock());
- updateBlockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(blockEntry.getBedrockId() << 4 | blockEntry.getBedrockData()));
- updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
-
- session.getUpstream().sendPacket(updateBlockPacket);
+ ChunkUtils.updateBlock(session, record.getBlock(), record.getPosition());
}
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java
index 6f2b6d3c..a80621a8 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java
@@ -2,13 +2,17 @@ package org.geysermc.connector.utils;
import com.github.steveice10.mc.protocol.data.game.chunk.Chunk;
import com.github.steveice10.mc.protocol.data.game.chunk.Column;
+import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
+import com.github.steveice10.mc.protocol.data.game.world.block.BlockChangeRecord;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
+import com.nukkitx.math.vector.Vector3i;
+import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
+import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.TranslatorsInit;
import org.geysermc.connector.network.translators.block.BlockEntry;
import org.geysermc.connector.world.chunk.ChunkSection;
public class ChunkUtils {
-
public static ChunkData translateToBedrock(Column column) {
ChunkData chunkData = new ChunkData();
@@ -29,14 +33,14 @@ public class ChunkUtils {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
BlockState blockState = chunk.get(x, y, z);
- BlockEntry block = TranslatorsInit.getBlockTranslator().getBedrockBlock(blockState);
+ BlockEntry block = TranslatorsInit.getBlockTranslator().getBlockEntry(blockState);
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z),
- block.getBedrockId() << 4 | block.getBedrockData());
+ block.getBedrockRuntimeId());
- if (block.getJavaIdentifier().contains("waterlogged=true")) {
- section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z),
- 9 << 4); // water id
+ if (block.isWaterlogged()) {
+ BlockEntry water = TranslatorsInit.getBlockTranslator().getBlockEntry("minecraft:water[level=0]");
+ section.getBlockStorageArray()[1].setFullBlock(ChunkSection.blockPosition(x, y, z), water.getBedrockRuntimeId());
}
}
}
@@ -45,6 +49,29 @@ public class ChunkUtils {
return chunkData;
}
+ public static void updateBlock(GeyserSession session, BlockState blockState, Position position) {
+ BlockEntry blockEntry = TranslatorsInit.getBlockTranslator().getBlockEntry(blockState);
+ Vector3i pos = Vector3i.from(position.getX(), position.getY(), position.getZ());
+
+ UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket();
+ updateBlockPacket.setDataLayer(0);
+ updateBlockPacket.setBlockPosition(pos);
+ updateBlockPacket.setRuntimeId(blockEntry.getBedrockRuntimeId());
+ updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
+ session.getUpstream().sendPacket(updateBlockPacket);
+
+ UpdateBlockPacket waterPacket = new UpdateBlockPacket();
+ waterPacket.setDataLayer(1);
+ waterPacket.setBlockPosition(pos);
+ if (blockEntry.isWaterlogged()) {
+ BlockEntry water = TranslatorsInit.getBlockTranslator().getBlockEntry("minecraft:water[level=0]");
+ waterPacket.setRuntimeId(water.getBedrockRuntimeId());
+ } else {
+ waterPacket.setRuntimeId(0);
+ }
+ session.getUpstream().sendPacket(waterPacket);
+ }
+
public static final class ChunkData {
public ChunkSection[] sections;
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 c47256da..f01530d6 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java
@@ -6,6 +6,7 @@ import com.nukkitx.nbt.stream.NBTInputStream;
import com.nukkitx.nbt.tag.CompoundTag;
import com.nukkitx.nbt.tag.ListTag;
import com.nukkitx.protocol.bedrock.data.ItemData;
+import com.nukkitx.nbt.tag.Tag;
import com.nukkitx.protocol.bedrock.packet.StartGamePacket;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@@ -14,7 +15,6 @@ import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.console.GeyserLogger;
import org.geysermc.connector.network.translators.block.BlockEntry;
import org.geysermc.connector.network.translators.item.ItemEntry;
-import org.geysermc.connector.world.GlobalBlockPalette;
import java.io.*;
import java.util.*;
@@ -34,7 +34,6 @@ public class Toolbox {
throw new AssertionError("Unable to find bedrock/runtime_block_states.dat");
}
- Map blockIdToIdentifier = new HashMap<>();
ListTag blocksTag;
NBTInputStream nbtInputStream = NbtUtils.createNetworkReader(stream);
@@ -46,15 +45,6 @@ public class Toolbox {
throw new AssertionError(ex);
}
- for (CompoundTag entry : blocksTag.getValue()) {
- String name = entry.getAsCompound("block").getAsString("name");
- int id = entry.getAsShort("id");
- int data = entry.getAsShort("meta");
-
- blockIdToIdentifier.put(name, id);
- GlobalBlockPalette.registerMapping(id << 4 | data);
- }
-
BLOCKS = blocksTag;
InputStream stream2 = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/items.json");
if (stream2 == null) {
@@ -99,16 +89,38 @@ public class Toolbox {
ex.printStackTrace();
}
- int blockIndex = 0;
- for (Map.Entry> itemEntry : blocks.entrySet()) {
- if (!blockIdToIdentifier.containsKey(itemEntry.getValue().get("bedrock_identifier"))) {
- GeyserLogger.DEFAULT.debug("Mapping " + itemEntry.getValue().get("bedrock_identifier") + " was not found for bedrock edition!");
- BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, 248, 0)); // update block
- } else {
- BLOCK_ENTRIES.put(blockIndex, new BlockEntry(itemEntry.getKey(), blockIndex, blockIdToIdentifier.get(itemEntry.getValue().get("bedrock_identifier")), (int) itemEntry.getValue().get("bedrock_data")));
- }
+ int javaIndex = -1;
+ javaLoop:
+ for (Map.Entry> javaEntry : blocks.entrySet()) {
+ javaIndex++;
+ String wantedIdentifier = (String) javaEntry.getValue().get("bedrock_identifier");
+ Map wantedStates = (Map) javaEntry.getValue().get("bedrock_states");
- blockIndex++;
+ int bedrockIndex = -1;
+ bedrockLoop:
+ for (CompoundTag bedrockEntry : BLOCKS.getValue()) {
+ bedrockIndex++;
+ CompoundTag blockTag = bedrockEntry.getAsCompound("block");
+ if (blockTag.getAsString("name").equals(wantedIdentifier)) {
+ if (wantedStates != null) {
+ Map> bedrockStates = blockTag.getAsCompound("states").getValue();
+ for (Map.Entry stateEntry : wantedStates.entrySet()) {
+ Tag> bedrockStateTag = bedrockStates.get(stateEntry.getKey());
+ if (bedrockStateTag == null)
+ continue bedrockLoop;
+ Object bedrockStateValue = bedrockStateTag.getValue();
+ if (bedrockStateValue instanceof Byte)
+ bedrockStateValue = ((Byte) bedrockStateValue).intValue();
+ if (!stateEntry.getValue().equals(bedrockStateValue))
+ continue bedrockLoop;
+ }
+ }
+ BlockEntry blockEntry = new BlockEntry(javaEntry.getKey(), javaIndex, bedrockIndex);
+ BLOCK_ENTRIES.put(javaIndex, blockEntry);
+ continue javaLoop;
+ }
+ }
+ GeyserLogger.DEFAULT.debug("Mapping " + javaEntry.getKey() + " was not found for bedrock edition!");
}
InputStream creativeItemStream = Toolbox.class.getClassLoader().getResourceAsStream("bedrock/creative_items.json");
diff --git a/connector/src/main/java/org/geysermc/connector/world/GlobalBlockPalette.java b/connector/src/main/java/org/geysermc/connector/world/GlobalBlockPalette.java
deleted file mode 100644
index 9965acfa..00000000
--- a/connector/src/main/java/org/geysermc/connector/world/GlobalBlockPalette.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.geysermc.connector.world;
-
-import it.unimi.dsi.fastutil.ints.Int2IntMap;
-import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
-
-import java.util.NoSuchElementException;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Adapted from NukkitX: https://github.com/NukkitX/Nukkit
- */
-public class GlobalBlockPalette {
-
- private static final Int2IntMap legacyToRuntimeId = new Int2IntOpenHashMap();
- private static final Int2IntMap runtimeIdToLegacy = new Int2IntOpenHashMap();
- private static final AtomicInteger runtimeIdAllocator = new AtomicInteger(0);
-
- static {
- legacyToRuntimeId.defaultReturnValue(-1);
- runtimeIdToLegacy.defaultReturnValue(-1);
- }
-
- public static int getOrCreateRuntimeId(int id, int meta) {
- return getOrCreateRuntimeId((id << 4) | meta);
- }
-
- public static int getOrCreateRuntimeId(int legacyId) throws NoSuchElementException {
- int runtimeId = legacyToRuntimeId.get(legacyId);
- if (!legacyToRuntimeId.containsKey(legacyId) || runtimeId == -1) {
- //runtimeId = registerMapping(runtimeIdAllocator.incrementAndGet(), legacyId);
- // throw new NoSuchElementException("Unmapped block registered id:" + (legacyId >>> 4) + " meta:" + (legacyId & 0xf));
- return 0;
- }
- return runtimeId;
- }
-
- public static int registerMapping(int legacyId) {
- int runtimeId = runtimeIdAllocator.getAndIncrement();
- runtimeIdToLegacy.put(runtimeId, legacyId);
- legacyToRuntimeId.put(legacyId, runtimeId);
- return runtimeId;
- }
-
- public static int getLegacyId(int runtimeId) {
- return runtimeIdToLegacy.get(runtimeId);
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/world/chunk/BlockStorage.java b/connector/src/main/java/org/geysermc/connector/world/chunk/BlockStorage.java
index dbb967d4..4d0cb9c2 100644
--- a/connector/src/main/java/org/geysermc/connector/world/chunk/BlockStorage.java
+++ b/connector/src/main/java/org/geysermc/connector/world/chunk/BlockStorage.java
@@ -4,7 +4,6 @@ import com.nukkitx.network.VarInts;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
-import org.geysermc.connector.world.GlobalBlockPalette;
import org.geysermc.connector.world.chunk.bitarray.BitArray;
import org.geysermc.connector.world.chunk.bitarray.BitArrayVersion;
@@ -44,11 +43,11 @@ public class BlockStorage {
}
public synchronized int getFullBlock(int index) {
- return this.legacyIdFor(this.bitArray.get(index));
+ return this.palette.getInt(this.bitArray.get(index));
}
- public synchronized void setFullBlock(int index, int legacyId) {
- int idx = this.idFor(legacyId);
+ public synchronized void setFullBlock(int index, int runtimeId) {
+ int idx = this.idFor(runtimeId);
this.bitArray.set(index, idx);
}
@@ -72,8 +71,7 @@ public class BlockStorage {
this.bitArray = newBitArray;
}
- private int idFor(int legacyId) {
- int runtimeId = GlobalBlockPalette.getOrCreateRuntimeId(legacyId);
+ private int idFor(int runtimeId) {
int index = this.palette.indexOf(runtimeId);
if (index != -1) {
return index;
@@ -91,11 +89,6 @@ public class BlockStorage {
return index;
}
- private int legacyIdFor(int index) {
- int runtimeId = this.palette.get(index);
- return GlobalBlockPalette.getLegacyId(runtimeId);
- }
-
public boolean isEmpty() {
if (this.palette.size() == 1) {
return true;
diff --git a/connector/src/main/resources/bedrock/runtime_block_states-1.14.dat b/connector/src/main/resources/bedrock/runtime_block_states-1.14.dat
deleted file mode 100644
index 38b413c2..00000000
Binary files a/connector/src/main/resources/bedrock/runtime_block_states-1.14.dat and /dev/null differ
diff --git a/connector/src/main/resources/bedrock/runtime_block_states.dat b/connector/src/main/resources/bedrock/runtime_block_states.dat
index a0623f43..0c79ab2f 100644
Binary files a/connector/src/main/resources/bedrock/runtime_block_states.dat and b/connector/src/main/resources/bedrock/runtime_block_states.dat differ
diff --git a/connector/src/main/resources/mappings b/connector/src/main/resources/mappings
index 0f3d65b6..582fb160 160000
--- a/connector/src/main/resources/mappings
+++ b/connector/src/main/resources/mappings
@@ -1 +1 @@
-Subproject commit 0f3d65b65076b16fc7dc9226230b31291b8f2cde
+Subproject commit 582fb1609ffde735e514b99550362a9a533fc88a