From 6e80f22ee9522e66cdce1d933d235679339d2960 Mon Sep 17 00:00:00 2001 From: DoctorMacc Date: Sun, 9 Aug 2020 22:43:57 -0400 Subject: [PATCH] Update to 1.16.2-rc1 --- connector/pom.xml | 2 +- .../java/JavaJoinGameTranslator.java | 7 ++--- .../java/JavaRespawnTranslator.java | 7 ++--- .../connector/utils/DimensionUtils.java | 26 ++++++++++++++++++- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/connector/pom.xml b/connector/pom.xml index f78cc875..7997efad 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -105,7 +105,7 @@ com.github.GeyserMC MCProtocolLib - da148409ff + 2ee53b72d1 compile diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java index 94b5bed3..06fa2016 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java @@ -51,10 +51,11 @@ public class JavaJoinGameTranslator extends PacketTranslator stopRainPacket.setPosition(Vector3f.ZERO); session.sendUpstreamPacket(stopRainPacket); - if (!entity.getDimension().equals(packet.getDimension())) { - DimensionUtils.switchDimension(session, packet.getDimension()); + String newDimension = DimensionUtils.getNewDimension(packet.getDimension()); + if (!entity.getDimension().equals(newDimension)) { + DimensionUtils.switchDimension(session, newDimension); } else { if (session.isManyDimPackets()) { //reloading world String fakeDim = entity.getDimension().equals(DimensionUtils.OVERWORLD) ? DimensionUtils.NETHER : DimensionUtils.OVERWORLD; DimensionUtils.switchDimension(session, fakeDim); - DimensionUtils.switchDimension(session, packet.getDimension()); + DimensionUtils.switchDimension(session, newDimension); } else { // Handled in JavaPlayerPositionRotationTranslator session.setSpawned(false); diff --git a/connector/src/main/java/org/geysermc/connector/utils/DimensionUtils.java b/connector/src/main/java/org/geysermc/connector/utils/DimensionUtils.java index 74db16bb..bcbc4ce0 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/DimensionUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/DimensionUtils.java @@ -26,8 +26,13 @@ package org.geysermc.connector.utils; import com.github.steveice10.mc.protocol.data.game.entity.Effect; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.nukkitx.math.vector.Vector3i; -import com.nukkitx.protocol.bedrock.packet.*; +import com.nukkitx.protocol.bedrock.packet.ChangeDimensionPacket; +import com.nukkitx.protocol.bedrock.packet.MobEffectPacket; +import com.nukkitx.protocol.bedrock.packet.StopSoundPacket; +import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.entity.Entity; import org.geysermc.connector.network.session.GeyserSession; @@ -99,6 +104,25 @@ public class DimensionUtils { } } + /** + * Determines the new dimension based on the {@link CompoundTag} sent by either the {@link com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket} + * or {@link com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket}. + * @param dimensionTag the packet's dimension tag. + * @return the dimension identifier. + */ + public static String getNewDimension(CompoundTag dimensionTag) { + if (dimensionTag == null || dimensionTag.isEmpty()) { + GeyserConnector.getInstance().getLogger().debug("Dimension tag was null or empty."); + return "minecraft:overworld"; + } + if (dimensionTag.getValue().get("effects") != null) { + System.out.println(((StringTag) dimensionTag.getValue().get("effects")).getValue()); + return ((StringTag) dimensionTag.getValue().get("effects")).getValue(); + } + GeyserConnector.getInstance().getLogger().debug("Effects portion of the tag was null or empty."); + return "minecraft:overworld"; + } + public static void changeBedrockNetherId() { // Change dimension ID to the End to allow for building above Bedrock BEDROCK_NETHER_ID = 2;