Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-24 15:20:35 +01:00
Removed all entity ID rewriting logic.
This was all a no-op anyway, and should the need for this arise again, it is trivial to re-add. However, Velocity does not need this, and probably will never need it. Let's have the complexity go away.
Dieser Commit ist enthalten in:
Ursprung
f27b7e4e2f
Commit
c7469ec13c
@ -86,11 +86,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
connection.getMinecraftConnection().close();
|
connection.getMinecraftConnection().close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
connection.getPlayer().getConnection().write(buf.retain());
|
||||||
ClientPlaySessionHandler playerHandler =
|
|
||||||
(ClientPlaySessionHandler) connection.getPlayer().getConnection().getSessionHandler();
|
|
||||||
ByteBuf remapped = playerHandler.getIdRemapper().remap(buf, ProtocolConstants.Direction.CLIENTBOUND);
|
|
||||||
connection.getPlayer().getConnection().write(remapped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,7 +8,6 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
||||||
import com.velocitypowered.proxy.protocol.packet.*;
|
import com.velocitypowered.proxy.protocol.packet.*;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
||||||
import com.velocitypowered.proxy.protocol.remap.EntityIdRemapper;
|
|
||||||
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
import com.velocitypowered.proxy.protocol.util.PluginMessageUtil;
|
||||||
import com.velocitypowered.proxy.util.ThrowableUtils;
|
import com.velocitypowered.proxy.util.ThrowableUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@ -33,7 +32,6 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
private boolean spawned = false;
|
private boolean spawned = false;
|
||||||
private final List<UUID> serverBossBars = new ArrayList<>();
|
private final List<UUID> serverBossBars = new ArrayList<>();
|
||||||
private final Set<String> clientPluginMsgChannels = new HashSet<>();
|
private final Set<String> clientPluginMsgChannels = new HashSet<>();
|
||||||
private EntityIdRemapper idRemapper;
|
|
||||||
|
|
||||||
public ClientPlaySessionHandler(ConnectedPlayer player) {
|
public ClientPlaySessionHandler(ConnectedPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@ -127,8 +125,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUnknown(ByteBuf buf) {
|
public void handleUnknown(ByteBuf buf) {
|
||||||
ByteBuf remapped = idRemapper.remap(buf, ProtocolConstants.Direction.SERVERBOUND);
|
player.getConnectedServer().getMinecraftConnection().write(buf.retain());
|
||||||
player.getConnectedServer().getMinecraftConnection().write(remapped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -152,7 +149,6 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
// nothing special to do here
|
// nothing special to do here
|
||||||
spawned = true;
|
spawned = true;
|
||||||
player.getConnection().delayedWrite(joinGame);
|
player.getConnection().delayedWrite(joinGame);
|
||||||
idRemapper = EntityIdRemapper.getMapper(joinGame.getEntityId(), player.getConnection().getProtocolVersion());
|
|
||||||
} else {
|
} else {
|
||||||
// Ah, this is the meat and potatoes of the whole venture!
|
// Ah, this is the meat and potatoes of the whole venture!
|
||||||
//
|
//
|
||||||
@ -167,7 +163,6 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
// Most notably, by having the client accept the join game packet, we can work around the need to perform
|
// Most notably, by having the client accept the join game packet, we can work around the need to perform
|
||||||
// entity ID rewrites, eliminating potential issues from rewriting packets and improving compatibility with
|
// entity ID rewrites, eliminating potential issues from rewriting packets and improving compatibility with
|
||||||
// mods.
|
// mods.
|
||||||
idRemapper.setServerEntityId(joinGame.getEntityId());
|
|
||||||
player.getConnection().delayedWrite(joinGame);
|
player.getConnection().delayedWrite(joinGame);
|
||||||
int tempDim = joinGame.getDimension() == 0 ? -1 : 0;
|
int tempDim = joinGame.getDimension() == 0 ? -1 : 0;
|
||||||
player.getConnection().delayedWrite(new Respawn(tempDim, joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType()));
|
player.getConnection().delayedWrite(new Respawn(tempDim, joinGame.getDifficulty(), joinGame.getGamemode(), joinGame.getLevelType()));
|
||||||
@ -250,10 +245,6 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
return clientPluginMsgChannels;
|
return clientPluginMsgChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityIdRemapper getIdRemapper() {
|
|
||||||
return idRemapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastPing(long lastPing) {
|
public void setLastPing(long lastPing) {
|
||||||
this.lastPingID = lastPing;
|
this.lastPingID = lastPing;
|
||||||
this.lastPingSent = System.currentTimeMillis();
|
this.lastPingSent = System.currentTimeMillis();
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
package com.velocitypowered.proxy.protocol.remap;
|
|
||||||
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a protocol-specific entity ID remapper for certain Minecraft packets. This is mostly required to support
|
|
||||||
* old versions of Minecraft. For Minecraft 1.8 clients and above, Velocity can use a more efficient method based on
|
|
||||||
* sending JoinGame packets multiple times.
|
|
||||||
*/
|
|
||||||
public interface EntityIdRemapper {
|
|
||||||
/**
|
|
||||||
* Remaps the entity IDs in this packet so that they apply to the player.
|
|
||||||
* @param original the packet to remap
|
|
||||||
* @param direction the direction of the packet
|
|
||||||
* @return a remapped packet, which may either be a retained version of the original buffer or an entirely new buffer
|
|
||||||
*/
|
|
||||||
ByteBuf remap(ByteBuf original, ProtocolConstants.Direction direction);
|
|
||||||
|
|
||||||
int getClientEntityId();
|
|
||||||
|
|
||||||
int getServerEntityId();
|
|
||||||
|
|
||||||
void setServerEntityId(int id);
|
|
||||||
|
|
||||||
static EntityIdRemapper getMapper(int eid, int protocolVersion) {
|
|
||||||
return NoopEntityIdRemapper.INSTANCE;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.velocitypowered.proxy.protocol.remap;
|
|
||||||
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
public class NoopEntityIdRemapper implements EntityIdRemapper {
|
|
||||||
public static final NoopEntityIdRemapper INSTANCE = new NoopEntityIdRemapper();
|
|
||||||
|
|
||||||
private NoopEntityIdRemapper() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ByteBuf remap(ByteBuf original, ProtocolConstants.Direction direction) {
|
|
||||||
return original.retain();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getClientEntityId() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getServerEntityId() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setServerEntityId(int id) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren