Skip to content

Commit

Permalink
Drop <1.20.50
Browse files Browse the repository at this point in the history
  • Loading branch information
Konicai committed Dec 15, 2023
1 parent a89aa4e commit f38d82c
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 16,152 deletions.
28 changes: 2 additions & 26 deletions core/src/main/java/org/geysermc/geyser/network/GameProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@
import com.github.steveice10.mc.protocol.codec.PacketCodec;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec;
import org.cloudburstmc.protocol.bedrock.codec.v589.Bedrock_v589;
import org.cloudburstmc.protocol.bedrock.codec.v594.Bedrock_v594;
import org.cloudburstmc.protocol.bedrock.codec.v618.Bedrock_v618;
import org.cloudburstmc.protocol.bedrock.codec.v622.Bedrock_v622;
import org.cloudburstmc.protocol.bedrock.codec.v630.Bedrock_v630;
import org.cloudburstmc.protocol.bedrock.netty.codec.packet.BedrockPacketCodec;
import org.geysermc.geyser.session.GeyserSession;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -63,18 +58,11 @@ public final class GameProtocol {
private static final PacketCodec DEFAULT_JAVA_CODEC = MinecraftCodec.CODEC;

static {
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v589.CODEC.toBuilder()
.minecraftVersion("1.20.0/1.20.1")
.build());
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v594.CODEC.toBuilder()
.minecraftVersion("1.20.10/1.20.15")
.build());
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v618.CODEC.toBuilder()
.minecraftVersion("1.20.30/1.20.32")
.build());
/*
SUPPORTED_BEDROCK_CODECS.add(Bedrock_v622.CODEC.toBuilder()
.minecraftVersion("1.20.40/1.20.41")
.build());
*/
SUPPORTED_BEDROCK_CODECS.add(DEFAULT_BEDROCK_CODEC);
}

Expand All @@ -94,18 +82,6 @@ public final class GameProtocol {

/* Bedrock convenience methods to gatekeep features and easily remove the check on version removal */

public static boolean isPre1_20_10(GeyserSession session) {
return session.getUpstream().getProtocolVersion() < Bedrock_v594.CODEC.getProtocolVersion();
}

/**
* @param session the session to check
* @return true if the session needs an experiment for recipe unlocking
*/
public static boolean isUsingExperimentalRecipeUnlocking(GeyserSession session) {
return session.getUpstream().getProtocolVersion() == Bedrock_v594.CODEC.getProtocolVersion();
}

/**
* Gets the {@link PacketCodec} for Minecraft: Java Edition.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,9 @@ private static void nullifyBlocksNode() {
}

private static void registerBedrockBlocks() {
Remapper mapper594 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE);
Remapper mapper618 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE);
Remapper mapper622 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE, BlockStateUpdater_1_20_40.INSTANCE);
Remapper mapper630 = Remapper.of(BlockStateUpdater_1_20_10.INSTANCE, BlockStateUpdater_1_20_30.INSTANCE, BlockStateUpdater_1_20_40.INSTANCE, BlockStateUpdater_1_20_50.INSTANCE);

var blockMappers = ImmutableMap.<ObjectIntPair<String>, Remapper>builder()
.put(ObjectIntPair.of("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()), tag -> tag)
.put(ObjectIntPair.of("1_20_10", Bedrock_v594.CODEC.getProtocolVersion()), mapper594)
.put(ObjectIntPair.of("1_20_30", Bedrock_v618.CODEC.getProtocolVersion()), mapper618)
.put(ObjectIntPair.of("1_20_40", Bedrock_v622.CODEC.getProtocolVersion()), mapper622)
.put(ObjectIntPair.of("1_20_50", Bedrock_v630.CODEC.getProtocolVersion()), mapper630)
//.put(ObjectIntPair.of("1_20_40", Bedrock_v622.CODEC.getProtocolVersion()), mapper622)
.put(ObjectIntPair.of("1_20_50", Bedrock_v630.CODEC.getProtocolVersion()), tag -> tag)
.build();

// We can keep this strong as nothing should be garbage collected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,8 @@ interface Remapper {
}

public static void populate() {
// Forward-map 1.20 mappings to 1.20.10
Remapper remapper594 = (item, mapping) -> {
// 1.20.10+ received parity for concrete and shulker boxes
String id = item.javaIdentifier();
if (id.endsWith("_concrete") || id.endsWith("_shulker_box")) {
// the first underscore in "_shulker_box" accounts for ignoring "minecraft:shulker_box"
// which is mapped to "minecraft:undyed_shulker_box"
return mapping.withBedrockIdentifier(id);
}
return mapping;
};
// 1.20 to 1.20.30
Remapper remapper618 = (item, mapping) -> {
mapping = remapper594.remap(item, mapping); // apply 1.20.10 remapper first

String id = item.javaIdentifier();
if (id.endsWith("concrete_powder") || id.contains("stained_glass") || (id.endsWith("_terracotta") && !id.contains("glazed"))) {
// parity: concrete powder, stained-glass blocks and panes, and coloured terracotta
// 1. 'minecraft:terracotta' is still 'minecraft:hardened_clay'
// 2. there were no changes for glazed, but it doesn't have full parity, so ignore it.
return mapping.withBedrockIdentifier(id);
}
return mapping;
};

/*
Remapper remapper630 = (item, mapping) -> {
mapping = remapper618.remap(item, mapping); // apply 1.20.30 remapper first

String id = item.javaIdentifier();
// 1.20.50 replaced stone & planks to individual stone types
// E.g.: granite, diorite, andesite, polished variants, dark_oak_planks etc
Expand All @@ -126,13 +100,11 @@ public static void populate() {
return mapping;
};
*/

List<PaletteVersion> paletteVersions = new ArrayList<>(3);
paletteVersions.add(new PaletteVersion("1_20_0", Bedrock_v589.CODEC.getProtocolVersion()));
paletteVersions.add(new PaletteVersion("1_20_10", Bedrock_v594.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper594));
paletteVersions.add(new PaletteVersion("1_20_30", Bedrock_v618.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper618));
paletteVersions.add(new PaletteVersion("1_20_40", Bedrock_v622.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper618)); // NO item changes between 1.20.30 and 1.20.40
paletteVersions.add(new PaletteVersion("1_20_50", Bedrock_v630.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper630));
//paletteVersions.add(new PaletteVersion("1_20_40", Bedrock_v622.CODEC.getProtocolVersion(), Collections.emptyMap(), remapper618)); // NO item changes between 1.20.30 and 1.20.40
paletteVersions.add(new PaletteVersion("1_20_50", Bedrock_v630.CODEC.getProtocolVersion()));

GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
import org.geysermc.geyser.level.JavaDimension;
import org.geysermc.geyser.level.WorldManager;
import org.geysermc.geyser.level.physics.CollisionManager;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.network.netty.LocalSession;
import org.geysermc.geyser.registry.Registries;
import org.geysermc.geyser.registry.type.BlockMappings;
Expand Down Expand Up @@ -699,10 +698,8 @@ public void connect() {
gamerulePacket.getGameRules().add(new GameRuleData<>("keepinventory", true));
// Ensure client doesn't try and do anything funky; the server handles this for us
gamerulePacket.getGameRules().add(new GameRuleData<>("spawnradius", 0));
// Recipe unlocking - only needs to be added if 1. it isn't already on via an experiment, or 2. the client is on pre 1.20.10
if (!GameProtocol.isPre1_20_10(this) && !GameProtocol.isUsingExperimentalRecipeUnlocking(this)) {
gamerulePacket.getGameRules().add(new GameRuleData<>("recipesunlock", true));
}
// Recipe unlocking
gamerulePacket.getGameRules().add(new GameRuleData<>("recipesunlock", true));
upstream.sendPacket(gamerulePacket);
}

Expand Down Expand Up @@ -1561,10 +1558,6 @@ private void startGame() {
startGamePacket.setRewindHistorySize(0);
startGamePacket.setServerAuthoritativeBlockBreaking(false);

if (GameProtocol.isUsingExperimentalRecipeUnlocking(this)) {
startGamePacket.getExperiments().add(new ExperimentData("recipe_unlocking", true));
}

upstream.sendPacket(startGamePacket);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public class JavaClientboundRecipesTranslator extends PacketTranslator<Clientbou

@Override
public void translate(GeyserSession session, ClientboundRecipePacket packet) {
// recipe unlocking does not exist pre 1.20.10
if (GameProtocol.isPre1_20_10(session)) {
return;
}

UnlockedRecipesPacket recipesPacket = new UnlockedRecipesPacket();
switch (packet.getAction()) {
case INIT -> {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit f38d82c

Please sign in to comment.