Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Expand the remapping stuff.
Dieser Commit ist enthalten in:
Ursprung
6b5cd703f0
Commit
515248fa99
@ -24,6 +24,6 @@ public interface EntityIdRemapper {
|
||||
void setServerEntityId(int id);
|
||||
|
||||
static EntityIdRemapper getMapper(int eid, int protocolVersion) {
|
||||
return DummyEntityIdRemapper.INSTANCE;
|
||||
return NoopEntityIdRemapper.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package com.velocitypowered.proxy.protocol.remap;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class Minecraft18EntityIdRemapper implements EntityIdRemapper {
|
||||
private final int clientId;
|
||||
private int serverId;
|
||||
|
||||
public Minecraft18EntityIdRemapper(int clientId, int serverId) {
|
||||
this.clientId = clientId;
|
||||
this.serverId = serverId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuf remap(ByteBuf original, ProtocolConstants.Direction direction) {
|
||||
if (clientId == serverId) {
|
||||
// If these are equal (i.e. first connection), no remapping is required.
|
||||
return original.retain();
|
||||
}
|
||||
|
||||
// TODO: Implement.
|
||||
throw new UnsupportedOperationException("1.8 doesn't allow switching servers.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClientEntityId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerEntityId() {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServerEntityId(int id) {
|
||||
this.serverId = id;
|
||||
}
|
||||
}
|
@ -3,10 +3,10 @@ package com.velocitypowered.proxy.protocol.remap;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class DummyEntityIdRemapper implements EntityIdRemapper {
|
||||
public static final DummyEntityIdRemapper INSTANCE = new DummyEntityIdRemapper();
|
||||
public class NoopEntityIdRemapper implements EntityIdRemapper {
|
||||
public static final NoopEntityIdRemapper INSTANCE = new NoopEntityIdRemapper();
|
||||
|
||||
private DummyEntityIdRemapper() {
|
||||
private NoopEntityIdRemapper() {
|
||||
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren