forked from GeyserMC/Geyser
Update to 1.16.2-rc1
This commit is contained in:
parent
098a0e7993
commit
6e80f22ee9
4 changed files with 34 additions and 8 deletions
|
@ -105,7 +105,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.GeyserMC</groupId>
|
<groupId>com.github.GeyserMC</groupId>
|
||||||
<artifactId>MCProtocolLib</artifactId>
|
<artifactId>MCProtocolLib</artifactId>
|
||||||
<version>da148409ff</version>
|
<version>2ee53b72d1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
|
|
@ -51,10 +51,11 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
||||||
entity.setEntityId(packet.getEntityId());
|
entity.setEntityId(packet.getEntityId());
|
||||||
// If the player is already initialized and a join game packet is sent, they
|
// If the player is already initialized and a join game packet is sent, they
|
||||||
// are swapping servers
|
// are swapping servers
|
||||||
|
String newDimension = DimensionUtils.getNewDimension(packet.getDimension());
|
||||||
if (session.isSpawned()) {
|
if (session.isSpawned()) {
|
||||||
String fakeDim = entity.getDimension().equals(DimensionUtils.OVERWORLD) ? DimensionUtils.NETHER : DimensionUtils.OVERWORLD;
|
String fakeDim = entity.getDimension().equals(DimensionUtils.OVERWORLD) ? DimensionUtils.NETHER : DimensionUtils.OVERWORLD;
|
||||||
DimensionUtils.switchDimension(session, fakeDim);
|
DimensionUtils.switchDimension(session, fakeDim);
|
||||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
DimensionUtils.switchDimension(session, newDimension);
|
||||||
|
|
||||||
session.getScoreboardCache().removeScoreboard();
|
session.getScoreboardCache().removeScoreboard();
|
||||||
}
|
}
|
||||||
|
@ -91,8 +92,8 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
||||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, skinParts, HandPreference.RIGHT_HAND);
|
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, skinParts, HandPreference.RIGHT_HAND);
|
||||||
session.sendDownstreamPacket(clientSettingsPacket);
|
session.sendDownstreamPacket(clientSettingsPacket);
|
||||||
|
|
||||||
if (!packet.getDimension().equals(entity.getDimension())) {
|
if (!newDimension.equals(entity.getDimension())) {
|
||||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
DimensionUtils.switchDimension(session, newDimension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,13 +65,14 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
||||||
stopRainPacket.setPosition(Vector3f.ZERO);
|
stopRainPacket.setPosition(Vector3f.ZERO);
|
||||||
session.sendUpstreamPacket(stopRainPacket);
|
session.sendUpstreamPacket(stopRainPacket);
|
||||||
|
|
||||||
if (!entity.getDimension().equals(packet.getDimension())) {
|
String newDimension = DimensionUtils.getNewDimension(packet.getDimension());
|
||||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
if (!entity.getDimension().equals(newDimension)) {
|
||||||
|
DimensionUtils.switchDimension(session, newDimension);
|
||||||
} else {
|
} else {
|
||||||
if (session.isManyDimPackets()) { //reloading world
|
if (session.isManyDimPackets()) { //reloading world
|
||||||
String fakeDim = entity.getDimension().equals(DimensionUtils.OVERWORLD) ? DimensionUtils.NETHER : DimensionUtils.OVERWORLD;
|
String fakeDim = entity.getDimension().equals(DimensionUtils.OVERWORLD) ? DimensionUtils.NETHER : DimensionUtils.OVERWORLD;
|
||||||
DimensionUtils.switchDimension(session, fakeDim);
|
DimensionUtils.switchDimension(session, fakeDim);
|
||||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
DimensionUtils.switchDimension(session, newDimension);
|
||||||
} else {
|
} else {
|
||||||
// Handled in JavaPlayerPositionRotationTranslator
|
// Handled in JavaPlayerPositionRotationTranslator
|
||||||
session.setSpawned(false);
|
session.setSpawned(false);
|
||||||
|
|
|
@ -26,8 +26,13 @@
|
||||||
package org.geysermc.connector.utils;
|
package org.geysermc.connector.utils;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
|
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.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.entity.Entity;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
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() {
|
public static void changeBedrockNetherId() {
|
||||||
// Change dimension ID to the End to allow for building above Bedrock
|
// Change dimension ID to the End to allow for building above Bedrock
|
||||||
BEDROCK_NETHER_ID = 2;
|
BEDROCK_NETHER_ID = 2;
|
||||||
|
|
Loading…
Reference in a new issue