Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Update to latest MCPL changes
Dieser Commit ist enthalten in:
Ursprung
56daefb0a0
Commit
bcc68ee4b5
@ -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
|
||||
*/
|
||||
private void workAroundWeirdBug(GeyserBootstrap bootstrap) {
|
||||
MinecraftProtocol protocol = new MinecraftProtocol();
|
||||
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().getAddress(),
|
||||
bootstrap.getGeyserConfig().getRemote().getPort(), this.serverSocketAddress,
|
||||
InetAddress.getLoopbackAddress().getHostAddress(), new MinecraftProtocol());
|
||||
InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper());
|
||||
session.connect();
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.steveice10</groupId>
|
||||
<artifactId>packetlib</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<version>3.0</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -26,9 +26,7 @@
|
||||
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.Rotation;
|
||||
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.nukkitx.math.vector.Vector3f;
|
||||
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
|
||||
}
|
||||
|
||||
public void setHeadRotation(EntityMetadata<Rotation, ?> entityMetadata) {
|
||||
public void setHeadRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
||||
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());
|
||||
}
|
||||
|
||||
public void setLeftArmRotation(EntityMetadata<Rotation, ?> entityMetadata) {
|
||||
public void setLeftArmRotation(EntityMetadata<Vector3f, ?> entityMetadata) {
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@ -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 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
|
||||
setFlag(EntityFlag.BRIBED, true);
|
||||
|
||||
int rotationX = MathUtils.wrapDegreesToInt(rotation.getPitch());
|
||||
int rotationY = MathUtils.wrapDegreesToInt(rotation.getYaw());
|
||||
int rotationZ = MathUtils.wrapDegreesToInt(rotation.getRoll());
|
||||
int rotationX = MathUtils.wrapDegreesToInt(rotation.getX());
|
||||
int rotationY = MathUtils.wrapDegreesToInt(rotation.getY());
|
||||
int rotationZ = MathUtils.wrapDegreesToInt(rotation.getZ());
|
||||
// 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
|
||||
int topBit = (Math.abs(rotationX) >= 100 ? 4 : 0) + (Math.abs(rotationY) >= 100 ? 2 : 0) + (Math.abs(rotationZ) >= 100 ? 1 : 0);
|
||||
|
@ -26,6 +26,7 @@
|
||||
package org.geysermc.geyser.network.netty;
|
||||
|
||||
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.tcp.*;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
@ -47,11 +48,13 @@ public final class LocalSession extends TcpSession {
|
||||
|
||||
private final SocketAddress targetAddress;
|
||||
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);
|
||||
this.targetAddress = targetAddress;
|
||||
this.clientIp = clientIp;
|
||||
this.codecHelper = codecHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,6 +105,11 @@ public final class LocalSession extends TcpSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketCodecHelper getCodecHelper() {
|
||||
return this.codecHelper;
|
||||
}
|
||||
|
||||
// TODO duplicate code
|
||||
private void addHAProxySupport(ChannelPipeline pipeline) {
|
||||
InetSocketAddress clientAddress = getFlag(BuiltinFlags.CLIENT_PROXIED_ADDRESS);
|
||||
|
@ -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.protocol.MinecraftConstants;
|
||||
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.UnexpectedEncryptionException;
|
||||
import com.github.steveice10.mc.protocol.data.game.MessageType;
|
||||
@ -843,7 +844,8 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||
if (geyser.getBootstrap().getSocketAddress() != null) {
|
||||
// We're going to connect through the JVM and not through TCP
|
||||
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 {
|
||||
downstream = new TcpClientSession(this.remoteAddress, this.remotePort, this.protocol);
|
||||
disableSrvResolving();
|
||||
@ -1737,4 +1739,8 @@ public class GeyserSession implements GeyserConnection, CommandSender {
|
||||
packet.setExtraData(-1);
|
||||
sendUpstreamPacket(packet);
|
||||
}
|
||||
|
||||
public MinecraftCodecHelper getCodecHelper() {
|
||||
return (MinecraftCodecHelper) this.downstream.getCodecHelper();
|
||||
}
|
||||
}
|
||||
|
@ -62,11 +62,11 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
||||
Map<String, JavaDimension> dimensions = session.getDimensions();
|
||||
dimensions.clear();
|
||||
|
||||
JavaDimension.load(packet.getDimensionCodec(), dimensions);
|
||||
JavaDimension.load(packet.getRegistry(), dimensions);
|
||||
|
||||
Map<MessageType, TextDecoration> chatTypes = session.getChatTypes();
|
||||
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();
|
||||
CompoundTag element = tag.get("element");
|
||||
CompoundTag chat = element.get("chat");
|
||||
@ -77,7 +77,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
||||
if (decoration == null) {
|
||||
continue;
|
||||
}
|
||||
MessageType type = MessageType.VALUES[id];
|
||||
MessageType type = MessageType.from(id);
|
||||
chatTypes.put(type, new TextDecoration(decoration));
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class JavaLoginTranslator extends PacketTranslator<ClientboundLoginPacket
|
||||
}
|
||||
session.setWorldName(packet.getWorldName());
|
||||
|
||||
BiomeTranslator.loadServerBiomes(session, packet.getDimensionCodec());
|
||||
BiomeTranslator.loadServerBiomes(session, packet.getRegistry());
|
||||
session.getTagCache().clear();
|
||||
|
||||
session.setGameMode(packet.getGameMode());
|
||||
|
@ -55,7 +55,7 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
|
||||
|
||||
EntityEventPacket entityEventPacket = new EntityEventPacket();
|
||||
entityEventPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
switch (packet.getStatus()) {
|
||||
switch (packet.getEvent()) {
|
||||
case PLAYER_ENABLE_REDUCED_DEBUG:
|
||||
session.setReducedDebugInfo(true);
|
||||
return;
|
||||
|
@ -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.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket;
|
||||
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.nbt.NBTOutputStream;
|
||||
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.ByteBufAllocator;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
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.ChunkUtils;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
@ -110,9 +108,9 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
|
||||
GeyserChunkSection[] sections = new GeyserChunkSection[javaChunks.length - (yOffset + (bedrockDimension.minY() >> 4))];
|
||||
|
||||
try {
|
||||
NetInput in = new StreamNetInput(new ByteArrayInputStream(packet.getChunkData()));
|
||||
ByteBuf in = Unpooled.wrappedBuffer(packet.getChunkData());
|
||||
for (int sectionY = 0; sectionY < chunkSize; sectionY++) {
|
||||
ChunkSection javaSection = ChunkSection.read(in, biomeGlobalPalette);
|
||||
ChunkSection javaSection = session.getCodecHelper().readChunkSection(in, biomeGlobalPalette);
|
||||
javaChunks[sectionY] = javaSection.getChunkData();
|
||||
javaBiomes[sectionY] = javaSection.getBiomeData();
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren