Skip to content

Commit

Permalink
Support 1.17-pre3 and Bedrock 1.17.0.58
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Jun 2, 2021
1 parent f09a32b commit f5c5d0c
Show file tree
Hide file tree
Showing 17 changed files with 1,349 additions and 961 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t

Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have joined us here!

### Currently supporting Minecraft Bedrock v1.16.220.52 and Minecraft Java 21w20a.
### Currently supporting Minecraft Bedrock v1.17.0.58 and Minecraft Java 1.17-pre3.

## Setting Up
Take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set up Geyser.
Expand Down
10 changes: 5 additions & 5 deletions connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</dependency>
<dependency>
<groupId>com.github.CloudburstMC.Protocol</groupId>
<artifactId>bedrock-v431</artifactId>
<version>530a0e3</version>
<artifactId>bedrock-v440</artifactId>
<version>a8f4e93</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down Expand Up @@ -120,9 +120,9 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId>
<version>1.17-pre1-SNAPSHOT</version>
<groupId>com.github.GeyserMC</groupId>
<artifactId>MCProtocolLib</artifactId>
<version>9ba9d7e</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
package org.geysermc.connector.network;

import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
import com.nukkitx.protocol.bedrock.v431.Bedrock_v431;
import com.nukkitx.protocol.bedrock.v440.Bedrock_v440;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -39,7 +39,7 @@ public class BedrockProtocol {
* Default Bedrock codec that should act as a fallback. Should represent the latest available
* release of the game that Geyser supports.
*/
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v431.V431_CODEC;
public static final BedrockPacketCodec DEFAULT_BEDROCK_CODEC = Bedrock_v440.V440_CODEC;
/**
* A list of all supported Bedrock versions that can join Geyser
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.geysermc.connector.network.session.cache.AdvancementsCache;
import org.geysermc.connector.network.translators.PacketTranslatorRegistry;
import org.geysermc.connector.network.translators.item.ItemRegistry;
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_16_210;
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_17_0;
import org.geysermc.connector.utils.*;

import java.io.FileInputStream;
Expand Down Expand Up @@ -72,7 +72,7 @@ public boolean handle(LoginPacket loginPacket) {
session.getUpstream().getSession().setPacketCodec(packetCodec);

// Set the block translation based off of version
session.setBlockTranslator(BlockTranslator1_16_210.INSTANCE);
session.setBlockTranslator(BlockTranslator1_17_0.INSTANCE);

LoginEncryptionUtils.encryptPlayerConnection(connector, session, loginPacket);

Expand Down Expand Up @@ -137,8 +137,6 @@ public boolean handle(ResourcePackClientResponsePacket packet) {
stackPacket.getExperiments().add(new ExperimentData("data_driven_items", true));
}

stackPacket.getExperiments().add(new ExperimentData("caves_and_cliffs", true));

session.sendUpstreamPacket(stackPacket);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,12 +512,7 @@ public void connect() {
upstream.sendPacket(entityPacket);

CreativeContentPacket creativePacket = new CreativeContentPacket();
if (upstream.getSession().getPacketCodec().getProtocolVersion() < Bedrock_v431.V431_CODEC.getProtocolVersion()) {
creativePacket.setContents(ItemRegistry.getPre1_16_220CreativeContents());
} else {
// No additional work required
creativePacket.setContents(ItemRegistry.CREATIVE_ITEMS);
}
creativePacket.setContents(ItemRegistry.CREATIVE_ITEMS);
upstream.sendPacket(creativePacket);

PlayStatusPacket playStatusPacket = new PlayStatusPacket();
Expand Down Expand Up @@ -1048,14 +1043,13 @@ private void startGame() {
startGamePacket.setItemEntries(ItemRegistry.ITEMS);
startGamePacket.setVanillaVersion("*");
startGamePacket.setInventoriesServerAuthoritative(true);
startGamePacket.setServerEngine(""); // Do we want to fill this in?

SyncedPlayerMovementSettings settings = new SyncedPlayerMovementSettings();
settings.setMovementMode(AuthoritativeMovementMode.CLIENT);
settings.setRewindHistorySize(0);
settings.setServerAuthoritativeBlockBreaking(false);
startGamePacket.setPlayerMovementSettings(settings);

startGamePacket.getExperiments().add(new ExperimentData("caves_and_cliffs", true));

upstream.sendPacket(startGamePacket);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_16_210;
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_17_0;

@Getter
@AllArgsConstructor
@ToString
public class ItemEntry {

public static ItemEntry AIR = new ItemEntry("minecraft:air", "minecraft:air", 0, 0, 0,
BlockTranslator1_16_210.INSTANCE.getBedrockAirId(), 64);
BlockTranslator1_17_0.INSTANCE.getBedrockAirId(), 64);

private final String javaIdentifier;
private final String bedrockIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_16_210;
import org.geysermc.connector.network.translators.world.block.BlockTranslator1_17_0;
import org.geysermc.connector.utils.FileUtils;
import org.geysermc.connector.utils.LanguageUtils;

Expand Down Expand Up @@ -250,7 +250,7 @@ public static void init() {
throw new AssertionError(LanguageUtils.getLocaleStringLog("geyser.toolbox.fail.runtime_java"), e);
}

BlockTranslator blockTranslator = BlockTranslator1_16_210.INSTANCE;
BlockTranslator blockTranslator = BlockTranslator1_17_0.INSTANCE;

int itemIndex = 0;
int javaFurnaceMinecartId = 0;
Expand Down Expand Up @@ -537,37 +537,6 @@ public static void init() {
JAVA_ONLY_ITEMS = ImmutableSet.copyOf(javaOnlyItems);
}

/* pre-1.16.220 support start */

private static ItemData[] LEGACY_CREATIVE_CONTENTS = null;

/**
* Built on the fly so extra memory isn't used if there are no 1.16.210-or-below clients joining.
*
* @return a list of creative items built for versions before 1.16.220.
*/
public static ItemData[] getPre1_16_220CreativeContents() {
if (LEGACY_CREATIVE_CONTENTS != null) {
return LEGACY_CREATIVE_CONTENTS;
}

// Pre-1.16.220 relies on item damage values that the creative content packet drops
ItemData[] creativeContents = new ItemData[CREATIVE_ITEMS.length];
for (int i = 0; i < CREATIVE_ITEMS.length; i++) {
ItemData item = CREATIVE_ITEMS[i];
if (item.getBlockRuntimeId() != 0) {
creativeContents[i] = item.toBuilder().damage(getItem(item).getBedrockData()).build();
} else {
// No block runtime ID means that this item is backwards-compatible
creativeContents[i] = item;
}
}
LEGACY_CREATIVE_CONTENTS = creativeContents;
return creativeContents;
}

/* pre-1.16.220 support end */

/**
* Gets an {@link ItemEntry} from the given {@link ItemStack}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@

import java.io.DataInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.*;
import java.util.zip.GZIPInputStream;

public abstract class BlockTranslator {
Expand Down Expand Up @@ -221,7 +219,7 @@ public abstract class BlockTranslator {

BlockMapping.AIR = JAVA_RUNTIME_ID_TO_BLOCK_MAPPING.get(JAVA_AIR_ID);

BlockTranslator1_16_210.init();
BlockTranslator1_17_0.init();
BLOCKS_JSON = null; // We no longer require this so let it garbage collect away
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

package org.geysermc.connector.network.translators.world.block;

public class BlockTranslator1_16_210 extends BlockTranslator {
public static final BlockTranslator1_16_210 INSTANCE = new BlockTranslator1_16_210();
public class BlockTranslator1_17_0 extends BlockTranslator {
public static final BlockTranslator1_17_0 INSTANCE = new BlockTranslator1_17_0();

public BlockTranslator1_16_210() {
super("bedrock/blockpalette.1_16_210.nbt");
public BlockTranslator1_17_0() {
super("bedrock/block_palette.1_17_0.nbt");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,7 @@ private static int indexYZXtoXZY(int yzx) {

public static ChunkData translateToBedrock(GeyserSession session, Column column) {
Chunk[] javaSections = column.getChunks();

//FIXME TEMPORARY UNTIL THE CAVES AND CLIFFS EXPERIMENTAL DATA IS REMOVED UNLESS IT'S NOT REMOVED THEN HMMMM
int sectionYOffset;
if (session.getDimension().equals(DimensionUtils.OVERWORLD)) {
sectionYOffset = 4;
} else {
sectionYOffset = 0;
}
//FIXME END

ChunkSection[] sections = new ChunkSection[javaSections.length + sectionYOffset];
ChunkSection[] sections = new ChunkSection[javaSections.length];

// Temporarily stores compound tags of Bedrock-only block entities
List<NbtMap> bedrockOnlyBlockEntities = new ArrayList<>();
Expand Down Expand Up @@ -197,7 +187,7 @@ public static ChunkData translateToBedrock(GeyserSession session, Column column)
layers = new BlockStorage[]{ layer0, new BlockStorage(BitArrayVersion.V1.createArray(BlockStorage.SIZE, layer1Data), layer1Palette) };
}

sections[sectionY + sectionYOffset] = new ChunkSection(layers);
sections[sectionY] = new ChunkSection(layers);
}

CompoundTag[] blockEntities = column.getTileEntities();
Expand Down
Binary file modified connector/src/main/resources/bedrock/biome_definitions.dat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit f5c5d0c

Please sign in to comment.