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();
|
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
|
* Should 1.15 clients respawn instantly / without showing the death screen
|
||||||
*
|
*
|
||||||
|
@ -116,6 +116,15 @@ public abstract class Protocol {
|
|||||||
incoming.put(pair, protocolPacket);
|
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.
|
* Register an outgoing packet, with simple id transformation.
|
||||||
*
|
*
|
||||||
@ -149,6 +158,15 @@ public abstract class Protocol {
|
|||||||
outgoing.put(pair, protocolPacket);
|
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
|
* Transform a packet using this protocol
|
||||||
*
|
*
|
||||||
|
@ -272,18 +272,8 @@ public class Protocol1_12To1_11_1 extends Protocol {
|
|||||||
|
|
||||||
// Incoming
|
// Incoming
|
||||||
// New packet at 0x01
|
// New packet at 0x01
|
||||||
registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
cancelIncoming(State.PLAY, 0x01);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
registerIncoming(State.PLAY, 0x01, 0x02);
|
registerIncoming(State.PLAY, 0x01, 0x02);
|
||||||
registerIncoming(State.PLAY, 0x02, 0x03);
|
registerIncoming(State.PLAY, 0x02, 0x03);
|
||||||
registerIncoming(State.PLAY, 0x03, 0x04);
|
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, 0x13, 0x14);
|
||||||
registerIncoming(State.PLAY, 0x14, 0x15);
|
registerIncoming(State.PLAY, 0x14, 0x15);
|
||||||
registerIncoming(State.PLAY, 0x15, 0x16);
|
registerIncoming(State.PLAY, 0x15, 0x16);
|
||||||
|
|
||||||
// New packet at 0x17
|
// New packet at 0x17
|
||||||
registerIncoming(State.PLAY, 0x17, 0x17, new PacketRemapper() {
|
cancelIncoming(State.PLAY, 0x17);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
registerIncoming(State.PLAY, 0x16, 0x18);
|
registerIncoming(State.PLAY, 0x16, 0x18);
|
||||||
// New packet 0x19
|
|
||||||
registerIncoming(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
|
|
||||||
@Override
|
// New packet 0x19
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
cancelIncoming(State.PLAY, 0x19);
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
registerIncoming(State.PLAY, 0x17, 0x1a);
|
registerIncoming(State.PLAY, 0x17, 0x1a);
|
||||||
// registerIncoming(State.PLAY, 0x18, 0x1b); - Handled in InventoryPackets
|
// registerIncoming(State.PLAY, 0x18, 0x1b); - Handled in InventoryPackets
|
||||||
registerIncoming(State.PLAY, 0x19, 0x1c);
|
registerIncoming(State.PLAY, 0x19, 0x1c);
|
||||||
|
@ -799,30 +799,10 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
// Incoming packets
|
// Incoming packets
|
||||||
|
|
||||||
// New packet 0x02 - Login Plugin Message
|
// New packet 0x02 - Login Plugin Message
|
||||||
registerIncoming(State.LOGIN, -1, 0x02, new PacketRemapper() {
|
cancelIncoming(State.LOGIN, 0x02);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// New 0x01 - Query Block NBT
|
// New 0x01 - Query Block NBT
|
||||||
registerIncoming(State.PLAY, -1, 0x01, new PacketRemapper() {
|
cancelIncoming(State.PLAY, 0x01);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Tab-Complete
|
// Tab-Complete
|
||||||
registerIncoming(State.PLAY, 0x1, 0x5, new PacketRemapper() {
|
registerIncoming(State.PLAY, 0x1, 0x5, new PacketRemapper() {
|
||||||
@ -890,17 +870,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// New 0x0C - Query Entity NBT
|
// New 0x0C - Query Entity NBT
|
||||||
registerIncoming(State.PLAY, -1, 0x0C, new PacketRemapper() {
|
cancelIncoming(State.PLAY, 0x0C);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
registerIncoming(State.PLAY, 0x0A, 0x0D);
|
registerIncoming(State.PLAY, 0x0A, 0x0D);
|
||||||
registerIncoming(State.PLAY, 0x0B, 0x0E);
|
registerIncoming(State.PLAY, 0x0B, 0x0E);
|
||||||
registerIncoming(State.PLAY, 0x0C, 0x0F);
|
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.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.metadata.MetadataRewriter1_14_1To1_14;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1;
|
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 {
|
public class EntityPackets {
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ public class EntityPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0)) {
|
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
|
//Set Difficulty packet added in 19w11a
|
||||||
registerIncoming(State.PLAY, -1, 0x02, new PacketRemapper() {
|
cancelIncoming(State.PLAY, 0x02);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
registerIncoming(State.PLAY, 0x02, 0x03);
|
registerIncoming(State.PLAY, 0x02, 0x03);
|
||||||
registerIncoming(State.PLAY, 0x03, 0x04);
|
registerIncoming(State.PLAY, 0x03, 0x04);
|
||||||
registerIncoming(State.PLAY, 0x04, 0x05);
|
registerIncoming(State.PLAY, 0x04, 0x05);
|
||||||
@ -242,17 +233,8 @@ public class Protocol1_14To1_13_2 extends Protocol {
|
|||||||
registerIncoming(State.PLAY, 0x0D, 0x0E);
|
registerIncoming(State.PLAY, 0x0D, 0x0E);
|
||||||
|
|
||||||
//Lock Difficulty packet added in 19w11a
|
//Lock Difficulty packet added in 19w11a
|
||||||
registerIncoming(State.PLAY, -1, 0x10, new PacketRemapper() {
|
cancelIncoming(State.PLAY, 0x10);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
registerIncoming(State.PLAY, 0x0E, 0x0F);
|
registerIncoming(State.PLAY, 0x0E, 0x0F);
|
||||||
registerIncoming(State.PLAY, 0x0F, 0x14);
|
registerIncoming(State.PLAY, 0x0F, 0x14);
|
||||||
registerIncoming(State.PLAY, 0x10, 0x11);
|
registerIncoming(State.PLAY, 0x10, 0x11);
|
||||||
@ -276,17 +258,7 @@ public class Protocol1_14To1_13_2 extends Protocol {
|
|||||||
registerIncoming(State.PLAY, 0x23, 0x25);
|
registerIncoming(State.PLAY, 0x23, 0x25);
|
||||||
|
|
||||||
//Unknown packet added in 19w13a
|
//Unknown packet added in 19w13a
|
||||||
registerIncoming(State.PLAY, -1, 0x27, new PacketRemapper() {
|
cancelIncoming(State.PLAY, 0x27);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
registerIncoming(State.PLAY, 0x27, 0x2A);
|
registerIncoming(State.PLAY, 0x27, 0x2A);
|
||||||
registerIncoming(State.PLAY, 0x28, 0x2B);
|
registerIncoming(State.PLAY, 0x28, 0x2B);
|
||||||
|
@ -249,17 +249,7 @@ public class EntityPackets {
|
|||||||
|
|
||||||
|
|
||||||
// Update Entity NBT
|
// Update Entity NBT
|
||||||
protocol.registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() {
|
protocol.cancelOutgoing(State.PLAY, 0x49);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Combat Event Packet
|
// Combat Event Packet
|
||||||
protocol.registerOutgoing(State.PLAY, 0x42, 0x2C, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, 0x42, 0x2C, new PacketRemapper() {
|
||||||
|
@ -402,17 +402,7 @@ public class PlayerPackets {
|
|||||||
/* Removed packets */
|
/* Removed packets */
|
||||||
|
|
||||||
// Set Compression
|
// Set Compression
|
||||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() {
|
protocol.cancelOutgoing(State.PLAY, 0x46);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Packets which do not have any field remapping or handlers */
|
/* Packets which do not have any field remapping or handlers */
|
||||||
|
|
||||||
@ -482,43 +472,13 @@ public class PlayerPackets {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TP Confirm
|
// TP Confirm
|
||||||
protocol.registerIncoming(State.PLAY, -1, 0x00, new PacketRemapper() {
|
protocol.cancelIncoming(State.PLAY, 0x00);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Vehicle Move
|
// Vehicle Move
|
||||||
protocol.registerIncoming(State.PLAY, -1, 0x10, new PacketRemapper() {
|
protocol.cancelIncoming(State.PLAY, 0x10);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Steer Boat
|
// Steer Boat
|
||||||
protocol.registerIncoming(State.PLAY, -1, 0x11, new PacketRemapper() {
|
protocol.cancelIncoming(State.PLAY, 0x11);
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Packet Plugin Message Incoming
|
// Packet Plugin Message Incoming
|
||||||
protocol.registerIncoming(State.PLAY, 0x17, 0x09, new PacketRemapper() {
|
protocol.registerIncoming(State.PLAY, 0x17, 0x09, new PacketRemapper() {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren