3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 16:12:46 +01:00

Update to latest MCPL changes

Dieser Commit ist enthalten in:
RednedEpic 2022-06-05 13:12:36 -05:00
Ursprung 56daefb0a0
Commit bcc68ee4b5
8 geänderte Dateien mit 37 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -169,9 +169,10 @@ public class GeyserSpigotInjector extends GeyserInjector {
* For the future, if someone wants to properly fix this - as of December 28, 2021, it happens on 1.16.5/1.17.1/1.18.1 EXCEPT Spigot 1.16.5 * For the future, if someone wants to properly fix this - as of December 28, 2021, it happens on 1.16.5/1.17.1/1.18.1 EXCEPT Spigot 1.16.5
*/ */
private void workAroundWeirdBug(GeyserBootstrap bootstrap) { private void workAroundWeirdBug(GeyserBootstrap bootstrap) {
MinecraftProtocol protocol = new MinecraftProtocol();
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().getAddress(), LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().getAddress(),
bootstrap.getGeyserConfig().getRemote().getPort(), this.serverSocketAddress, bootstrap.getGeyserConfig().getRemote().getPort(), this.serverSocketAddress,
InetAddress.getLoopbackAddress().getHostAddress(), new MinecraftProtocol()); InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper());
session.connect(); session.connect();
} }

Datei anzeigen

@ -171,7 +171,7 @@
<dependency> <dependency>
<groupId>com.github.steveice10</groupId> <groupId>com.github.steveice10</groupId>
<artifactId>packetlib</artifactId> <artifactId>packetlib</artifactId>
<version>2.1-SNAPSHOT</version> <version>3.0</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

Datei anzeigen

@ -26,9 +26,7 @@
package org.geysermc.geyser.entity.type.living; package org.geysermc.geyser.entity.type.living;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Rotation;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityData;
@ -165,27 +163,27 @@ public class ArmorStandEntity extends LivingEntity {
setFlag(EntityFlag.ADMIRING, (xd & 0x08) == 0x08); // Has no baseplate setFlag(EntityFlag.ADMIRING, (xd & 0x08) == 0x08); // Has no baseplate
} }
public void setHeadRotation(EntityMetadata<Rotation, ?> entityMetadata) { public void setHeadRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
onRotationUpdate(EntityData.MARK_VARIANT, EntityFlag.INTERESTED, EntityFlag.CHARGED, EntityFlag.POWERED, entityMetadata.getValue()); onRotationUpdate(EntityData.MARK_VARIANT, EntityFlag.INTERESTED, EntityFlag.CHARGED, EntityFlag.POWERED, entityMetadata.getValue());
} }
public void setBodyRotation(EntityMetadata<Rotation, ?> entityMetadata) { public void setBodyRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
onRotationUpdate(EntityData.VARIANT, EntityFlag.IN_LOVE, EntityFlag.CELEBRATING, EntityFlag.CELEBRATING_SPECIAL, entityMetadata.getValue()); onRotationUpdate(EntityData.VARIANT, EntityFlag.IN_LOVE, EntityFlag.CELEBRATING, EntityFlag.CELEBRATING_SPECIAL, entityMetadata.getValue());
} }
public void setLeftArmRotation(EntityMetadata<Rotation, ?> entityMetadata) { public void setLeftArmRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
onRotationUpdate(EntityData.TRADE_TIER, EntityFlag.CHARGING, EntityFlag.CRITICAL, EntityFlag.DANCING, entityMetadata.getValue()); onRotationUpdate(EntityData.TRADE_TIER, EntityFlag.CHARGING, EntityFlag.CRITICAL, EntityFlag.DANCING, entityMetadata.getValue());
} }
public void setRightArmRotation(EntityMetadata<Rotation, ?> entityMetadata) { public void setRightArmRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
onRotationUpdate(EntityData.MAX_TRADE_TIER, EntityFlag.ELDER, EntityFlag.EMOTING, EntityFlag.IDLING, entityMetadata.getValue()); onRotationUpdate(EntityData.MAX_TRADE_TIER, EntityFlag.ELDER, EntityFlag.EMOTING, EntityFlag.IDLING, entityMetadata.getValue());
} }
public void setLeftLegRotation(EntityMetadata<Rotation, ?> entityMetadata) { public void setLeftLegRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
onRotationUpdate(EntityData.SKIN_ID, EntityFlag.IS_ILLAGER_CAPTAIN, EntityFlag.IS_IN_UI, EntityFlag.LINGERING, entityMetadata.getValue()); onRotationUpdate(EntityData.SKIN_ID, EntityFlag.IS_ILLAGER_CAPTAIN, EntityFlag.IS_IN_UI, EntityFlag.LINGERING, entityMetadata.getValue());
} }
public void setRightLegRotation(EntityMetadata<Rotation, ?> entityMetadata) { public void setRightLegRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
onRotationUpdate(EntityData.HURT_DIRECTION, EntityFlag.IS_PREGNANT, EntityFlag.SHEARED, EntityFlag.STALKING, entityMetadata.getValue()); onRotationUpdate(EntityData.HURT_DIRECTION, EntityFlag.IS_PREGNANT, EntityFlag.SHEARED, EntityFlag.STALKING, entityMetadata.getValue());
} }
@ -200,13 +198,13 @@ public class ArmorStandEntity extends LivingEntity {
* @param negativeZToggle the flag to set true if the Z value of rotation is negative * @param negativeZToggle the flag to set true if the Z value of rotation is negative
* @param rotation the Java rotation value * @param rotation the Java rotation value
*/ */
private void onRotationUpdate(EntityData dataLeech, EntityFlag negativeXToggle, EntityFlag negativeYToggle, EntityFlag negativeZToggle, Rotation rotation) { private void onRotationUpdate(EntityData dataLeech, EntityFlag negativeXToggle, EntityFlag negativeYToggle, EntityFlag negativeZToggle, Vector3f rotation) {
// Indicate that rotation should be checked // Indicate that rotation should be checked
setFlag(EntityFlag.BRIBED, true); setFlag(EntityFlag.BRIBED, true);
int rotationX = MathUtils.wrapDegreesToInt(rotation.getPitch()); int rotationX = MathUtils.wrapDegreesToInt(rotation.getX());
int rotationY = MathUtils.wrapDegreesToInt(rotation.getYaw()); int rotationY = MathUtils.wrapDegreesToInt(rotation.getY());
int rotationZ = MathUtils.wrapDegreesToInt(rotation.getRoll()); int rotationZ = MathUtils.wrapDegreesToInt(rotation.getZ());
// The top bit acts like binary and determines if each rotation goes above 100 // The top bit acts like binary and determines if each rotation goes above 100
// We don't do this for the negative values out of concerns of the number being too big // We don't do this for the negative values out of concerns of the number being too big
int topBit = (Math.abs(rotationX) >= 100 ? 4 : 0) + (Math.abs(rotationY) >= 100 ? 2 : 0) + (Math.abs(rotationZ) >= 100 ? 1 : 0); int topBit = (Math.abs(rotationX) >= 100 ? 4 : 0) + (Math.abs(rotationY) >= 100 ? 2 : 0) + (Math.abs(rotationZ) >= 100 ? 1 : 0);

Datei anzeigen

@ -26,6 +26,7 @@
package org.geysermc.geyser.network.netty; package org.geysermc.geyser.network.netty;
import com.github.steveice10.packetlib.BuiltinFlags; import com.github.steveice10.packetlib.BuiltinFlags;
import com.github.steveice10.packetlib.codec.PacketCodecHelper;
import com.github.steveice10.packetlib.packet.PacketProtocol; import com.github.steveice10.packetlib.packet.PacketProtocol;
import com.github.steveice10.packetlib.tcp.*; import com.github.steveice10.packetlib.tcp.*;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
@ -47,11 +48,13 @@ public final class LocalSession extends TcpSession {
private final SocketAddress targetAddress; private final SocketAddress targetAddress;
private final String clientIp; private final String clientIp;
private final PacketCodecHelper codecHelper;
public LocalSession(String host, int port, SocketAddress targetAddress, String clientIp, PacketProtocol protocol) { public LocalSession(String host, int port, SocketAddress targetAddress, String clientIp, PacketProtocol protocol, PacketCodecHelper codecHelper) {
super(host, port, protocol); super(host, port, protocol);
this.targetAddress = targetAddress; this.targetAddress = targetAddress;
this.clientIp = clientIp; this.clientIp = clientIp;
this.codecHelper = codecHelper;
} }
@Override @Override
@ -102,6 +105,11 @@ public final class LocalSession extends TcpSession {
} }
} }
@Override
public PacketCodecHelper getCodecHelper() {
return this.codecHelper;
}
// TODO duplicate code // TODO duplicate code
private void addHAProxySupport(ChannelPipeline pipeline) { private void addHAProxySupport(ChannelPipeline pipeline) {
InetSocketAddress clientAddress = getFlag(BuiltinFlags.CLIENT_PROXIED_ADDRESS); InetSocketAddress clientAddress = getFlag(BuiltinFlags.CLIENT_PROXIED_ADDRESS);

Datei anzeigen

@ -34,6 +34,7 @@ import com.github.steveice10.mc.auth.service.MojangAuthenticationService;
import com.github.steveice10.mc.auth.service.MsaAuthenticationService; import com.github.steveice10.mc.auth.service.MsaAuthenticationService;
import com.github.steveice10.mc.protocol.MinecraftConstants; import com.github.steveice10.mc.protocol.MinecraftConstants;
import com.github.steveice10.mc.protocol.MinecraftProtocol; import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.data.ProtocolState; import com.github.steveice10.mc.protocol.data.ProtocolState;
import com.github.steveice10.mc.protocol.data.UnexpectedEncryptionException; import com.github.steveice10.mc.protocol.data.UnexpectedEncryptionException;
import com.github.steveice10.mc.protocol.data.game.MessageType; import com.github.steveice10.mc.protocol.data.game.MessageType;
@ -843,7 +844,8 @@ public class GeyserSession implements GeyserConnection, CommandSender {
if (geyser.getBootstrap().getSocketAddress() != null) { if (geyser.getBootstrap().getSocketAddress() != null) {
// We're going to connect through the JVM and not through TCP // We're going to connect through the JVM and not through TCP
downstream = new LocalSession(this.remoteAddress, this.remotePort, downstream = new LocalSession(this.remoteAddress, this.remotePort,
geyser.getBootstrap().getSocketAddress(), upstream.getAddress().getAddress().getHostAddress(), this.protocol); geyser.getBootstrap().getSocketAddress(), upstream.getAddress().getAddress().getHostAddress(),
this.protocol, this.downstream.getCodecHelper());
} else { } else {
downstream = new TcpClientSession(this.remoteAddress, this.remotePort, this.protocol); downstream = new TcpClientSession(this.remoteAddress, this.remotePort, this.protocol);
disableSrvResolving(); disableSrvResolving();
@ -1737,4 +1739,8 @@ public class GeyserSession implements GeyserConnection, CommandSender {
packet.setExtraData(-1); packet.setExtraData(-1);
sendUpstreamPacket(packet); sendUpstreamPacket(packet);
} }
public MinecraftCodecHelper getCodecHelper() {
return (MinecraftCodecHelper) this.downstream.getCodecHelper();
}
} }

Datei anzeigen

@ -62,11 +62,11 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
Map<String, JavaDimension> dimensions = session.getDimensions(); Map<String, JavaDimension> dimensions = session.getDimensions();
dimensions.clear(); dimensions.clear();
JavaDimension.load(packet.getDimensionCodec(), dimensions); JavaDimension.load(packet.getRegistry(), dimensions);
Map<MessageType, TextDecoration> chatTypes = session.getChatTypes(); Map<MessageType, TextDecoration> chatTypes = session.getChatTypes();
chatTypes.clear(); chatTypes.clear();
for (CompoundTag tag : JavaCodecEntry.iterateAsTag(packet.getDimensionCodec().get("minecraft:chat_type"))) { for (CompoundTag tag : JavaCodecEntry.iterateAsTag(packet.getRegistry().get("minecraft:chat_type"))) {
int id = ((IntTag) tag.get("id")).getValue(); int id = ((IntTag) tag.get("id")).getValue();
CompoundTag element = tag.get("element"); CompoundTag element = tag.get("element");
CompoundTag chat = element.get("chat"); CompoundTag chat = element.get("chat");
@ -77,7 +77,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
if (decoration == null) { if (decoration == null) {
continue; continue;
} }
MessageType type = MessageType.VALUES[id]; MessageType type = MessageType.from(id);
chatTypes.put(type, new TextDecoration(decoration)); chatTypes.put(type, new TextDecoration(decoration));
} }
@ -91,7 +91,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
} }
session.setWorldName(packet.getWorldName()); session.setWorldName(packet.getWorldName());
BiomeTranslator.loadServerBiomes(session, packet.getDimensionCodec()); BiomeTranslator.loadServerBiomes(session, packet.getRegistry());
session.getTagCache().clear(); session.getTagCache().clear();
session.setGameMode(packet.getGameMode()); session.setGameMode(packet.getGameMode());

Datei anzeigen

@ -55,7 +55,7 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
EntityEventPacket entityEventPacket = new EntityEventPacket(); EntityEventPacket entityEventPacket = new EntityEventPacket();
entityEventPacket.setRuntimeEntityId(entity.getGeyserId()); entityEventPacket.setRuntimeEntityId(entity.getGeyserId());
switch (packet.getStatus()) { switch (packet.getEvent()) {
case PLAYER_ENABLE_REDUCED_DEBUG: case PLAYER_ENABLE_REDUCED_DEBUG:
session.setReducedDebugInfo(true); session.setReducedDebugInfo(true);
return; return;

Datei anzeigen

@ -35,8 +35,6 @@ import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityInfo;
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType; import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.packetlib.io.NetInput;
import com.github.steveice10.packetlib.io.stream.StreamNetInput;
import com.nukkitx.math.vector.Vector3i; import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.nbt.NBTOutputStream; import com.nukkitx.nbt.NBTOutputStream;
import com.nukkitx.nbt.NbtMap; import com.nukkitx.nbt.NbtMap;
@ -46,6 +44,7 @@ import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntLists; import it.unimi.dsi.fastutil.ints.IntLists;
@ -69,7 +68,6 @@ import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.BlockEntityUtils; import org.geysermc.geyser.util.BlockEntityUtils;
import org.geysermc.geyser.util.ChunkUtils; import org.geysermc.geyser.util.ChunkUtils;
import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.BitSet; import java.util.BitSet;
import java.util.List; import java.util.List;
@ -110,9 +108,9 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
GeyserChunkSection[] sections = new GeyserChunkSection[javaChunks.length - (yOffset + (bedrockDimension.minY() >> 4))]; GeyserChunkSection[] sections = new GeyserChunkSection[javaChunks.length - (yOffset + (bedrockDimension.minY() >> 4))];
try { try {
NetInput in = new StreamNetInput(new ByteArrayInputStream(packet.getChunkData())); ByteBuf in = Unpooled.wrappedBuffer(packet.getChunkData());
for (int sectionY = 0; sectionY < chunkSize; sectionY++) { for (int sectionY = 0; sectionY < chunkSize; sectionY++) {
ChunkSection javaSection = ChunkSection.read(in, biomeGlobalPalette); ChunkSection javaSection = session.getCodecHelper().readChunkSection(in, biomeGlobalPalette);
javaChunks[sectionY] = javaSection.getChunkData(); javaChunks[sectionY] = javaSection.getChunkData();
javaBiomes[sectionY] = javaSection.getBiomeData(); javaBiomes[sectionY] = javaSection.getBiomeData();