Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Helper methods for cancelling packets
Dieser Commit ist enthalten in:
Ursprung
abb5e27358
Commit
b11456d86b
@ -331,13 +331,6 @@ public interface ViaVersionConfig {
|
||||
|
||||
boolean is1_14HealthNaNFix();
|
||||
|
||||
/**
|
||||
* Fixes non full blocks having 0 light for 1.14+ clients on sub 1.14 servers.
|
||||
*
|
||||
* @return True if enabled
|
||||
*/
|
||||
boolean isNonFullBlockLightFix();
|
||||
|
||||
/**
|
||||
* Should 1.15 clients respawn instantly / without showing the death screen
|
||||
*
|
||||
|
@ -116,6 +116,15 @@ public abstract class Protocol {
|
||||
incoming.put(pair, protocolPacket);
|
||||
}
|
||||
|
||||
public void cancelIncoming(State state, int newPacketID) {
|
||||
registerIncoming(state, -1, newPacketID, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(PacketWrapper::cancel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an outgoing packet, with simple id transformation.
|
||||
*
|
||||
@ -149,6 +158,15 @@ public abstract class Protocol {
|
||||
outgoing.put(pair, protocolPacket);
|
||||
}
|
||||
|
||||
public void cancelOutgoing(State state, int oldPacketID) {
|
||||
registerIncoming(state, oldPacketID, -1, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(PacketWrapper::cancel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a packet using this protocol
|
||||
*
|
||||
|
@ -272,18 +272,8 @@ public class Protocol1_12To1_11_1 extends Protocol {
|
||||
|
||||
// Incoming
|
||||
// New packet at 0x01
|
||||
registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
cancelIncoming(State.PLAY, 0x01);
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
registerIncoming(State.PLAY, 0x01, 0x02);
|
||||
registerIncoming(State.PLAY, 0x02, 0x03);
|
||||
registerIncoming(State.PLAY, 0x03, 0x04);
|
||||
@ -336,33 +326,15 @@ public class Protocol1_12To1_11_1 extends Protocol {
|
||||
registerIncoming(State.PLAY, 0x13, 0x14);
|
||||
registerIncoming(State.PLAY, 0x14, 0x15);
|
||||
registerIncoming(State.PLAY, 0x15, 0x16);
|
||||
|
||||
// New packet at 0x17
|
||||
registerIncoming(State.PLAY, 0x17, 0x17, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
cancelIncoming(State.PLAY, 0x17);
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
registerIncoming(State.PLAY, 0x16, 0x18);
|
||||
// New packet 0x19
|
||||
registerIncoming(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// New packet 0x19
|
||||
cancelIncoming(State.PLAY, 0x19);
|
||||
|
||||
registerIncoming(State.PLAY, 0x17, 0x1a);
|
||||
// registerIncoming(State.PLAY, 0x18, 0x1b); - Handled in InventoryPackets
|
||||
registerIncoming(State.PLAY, 0x19, 0x1c);
|
||||
|
@ -799,30 +799,10 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
// Incoming packets
|
||||
|
||||
// New packet 0x02 - Login Plugin Message
|
||||
registerIncoming(State.LOGIN, -1, 0x02, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
cancelIncoming(State.LOGIN, 0x02);
|
||||
|
||||
// New 0x01 - Query Block NBT
|
||||
registerIncoming(State.PLAY, -1, 0x01, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
cancelIncoming(State.PLAY, 0x01);
|
||||
|
||||
// Tab-Complete
|
||||
registerIncoming(State.PLAY, 0x1, 0x5, new PacketRemapper() {
|
||||
@ -890,17 +870,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
||||
}
|
||||
});
|
||||
// New 0x0C - Query Entity NBT
|
||||
registerIncoming(State.PLAY, -1, 0x0C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
cancelIncoming(State.PLAY, 0x0C);
|
||||
|
||||
registerIncoming(State.PLAY, 0x0A, 0x0D);
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0E);
|
||||
registerIncoming(State.PLAY, 0x0C, 0x0F);
|
||||
|
@ -10,6 +10,7 @@ import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
||||
|
||||
public class EntityPackets {
|
||||
|
||||
@ -60,7 +61,7 @@ public class EntityPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0)) {
|
||||
wrapper.user().get(EntityTracker.class).removeEntity(entity);
|
||||
wrapper.user().get(EntityTracker1_14.class).removeEntity(entity);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -217,17 +217,8 @@ public class Protocol1_14To1_13_2 extends Protocol {
|
||||
});
|
||||
|
||||
//Set Difficulty packet added in 19w11a
|
||||
registerIncoming(State.PLAY, -1, 0x02, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
cancelIncoming(State.PLAY, 0x02);
|
||||
|
||||
registerIncoming(State.PLAY, 0x02, 0x03);
|
||||
registerIncoming(State.PLAY, 0x03, 0x04);
|
||||
registerIncoming(State.PLAY, 0x04, 0x05);
|
||||
@ -242,17 +233,8 @@ public class Protocol1_14To1_13_2 extends Protocol {
|
||||
registerIncoming(State.PLAY, 0x0D, 0x0E);
|
||||
|
||||
//Lock Difficulty packet added in 19w11a
|
||||
registerIncoming(State.PLAY, -1, 0x10, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
cancelIncoming(State.PLAY, 0x10);
|
||||
|
||||
registerIncoming(State.PLAY, 0x0E, 0x0F);
|
||||
registerIncoming(State.PLAY, 0x0F, 0x14);
|
||||
registerIncoming(State.PLAY, 0x10, 0x11);
|
||||
@ -276,17 +258,7 @@ public class Protocol1_14To1_13_2 extends Protocol {
|
||||
registerIncoming(State.PLAY, 0x23, 0x25);
|
||||
|
||||
//Unknown packet added in 19w13a
|
||||
registerIncoming(State.PLAY, -1, 0x27, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
cancelIncoming(State.PLAY, 0x27);
|
||||
|
||||
registerIncoming(State.PLAY, 0x27, 0x2A);
|
||||
registerIncoming(State.PLAY, 0x28, 0x2B);
|
||||
|
@ -249,17 +249,7 @@ public class EntityPackets {
|
||||
|
||||
|
||||
// Update Entity NBT
|
||||
protocol.registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.cancelOutgoing(State.PLAY, 0x49);
|
||||
|
||||
// Combat Event Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x42, 0x2C, new PacketRemapper() {
|
||||
|
@ -402,17 +402,7 @@ public class PlayerPackets {
|
||||
/* Removed packets */
|
||||
|
||||
// Set Compression
|
||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.cancelOutgoing(State.PLAY, 0x46);
|
||||
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
|
||||
@ -482,43 +472,13 @@ public class PlayerPackets {
|
||||
});
|
||||
|
||||
// TP Confirm
|
||||
protocol.registerIncoming(State.PLAY, -1, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.cancelIncoming(State.PLAY, 0x00);
|
||||
|
||||
// Vehicle Move
|
||||
protocol.registerIncoming(State.PLAY, -1, 0x10, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.cancelIncoming(State.PLAY, 0x10);
|
||||
|
||||
// Steer Boat
|
||||
protocol.registerIncoming(State.PLAY, -1, 0x11, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.cancelIncoming(State.PLAY, 0x11);
|
||||
|
||||
// Packet Plugin Message Incoming
|
||||
protocol.registerIncoming(State.PLAY, 0x17, 0x09, new PacketRemapper() {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren