3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 16:40:10 +01:00

Go through the rest of the send usages

Dieser Commit ist enthalten in:
KennyTV 2021-06-01 23:27:33 +02:00
Ursprung eaa58affd1
Commit 48436e7caf
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
9 geänderte Dateien mit 19 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.bungee.service.ProtocolDetectorService; import com.viaversion.viaversion.bungee.service.ProtocolDetectorService;
import com.viaversion.viaversion.bungee.storage.BungeeStorage; import com.viaversion.viaversion.bungee.storage.BungeeStorage;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.EntityIdProvider; import com.viaversion.viaversion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
@ -169,7 +170,7 @@ public class BungeeServerHandler implements Listener {
// This ensures we can encode it properly as only the 1.9 protocol is currently implemented. // This ensures we can encode it properly as only the 1.9 protocol is currently implemented.
if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) { if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
for (UUID uuid : storage.getBossbar()) { for (UUID uuid : storage.getBossbar()) {
PacketWrapper wrapper = PacketWrapper.create(0x0C, null, user); PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.BOSSBAR, null, user);
wrapper.write(Type.UUID, uuid); wrapper.write(Type.UUID, uuid);
wrapper.write(Type.VAR_INT, 1); // remove wrapper.write(Type.VAR_INT, 1); // remove
wrapper.send(Protocol1_9To1_8.class); wrapper.send(Protocol1_9To1_8.class);

Datei anzeigen

@ -129,7 +129,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server
wrapper.write(Type.VAR_INT, 0); // Root node index wrapper.write(Type.VAR_INT, 0); // Root node index
}).send(Protocol1_13To1_12_2.class); }).scheduleSend(Protocol1_13To1_12_2.class);
// Send tags packet // Send tags packet
w.create(ClientboundPackets1_13.TAGS, wrapper -> { w.create(ClientboundPackets1_13.TAGS, wrapper -> {
@ -151,7 +151,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
// Needs copy as other protocols may modify it // Needs copy as other protocols may modify it
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue())); wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
} }
}).send(Protocol1_13To1_12_2.class); }).scheduleSend(Protocol1_13To1_12_2.class);
}; };
@Override @Override
@ -349,7 +349,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
for (int i = 0; i < 44; i++) { for (int i = 0; i < 44; i++) {
Integer newItem = getMappingData().getItemMappings().get(item << 16 | i); Integer newItem = getMappingData().getItemMappings().get(item << 16 | i);
if (newItem != null) { if (newItem != null) {
PacketWrapper packet = wrapper.create(0x18); PacketWrapper packet = wrapper.create(ClientboundPackets1_13.COOLDOWN);
packet.write(Type.VAR_INT, newItem); packet.write(Type.VAR_INT, newItem);
packet.write(Type.VAR_INT, ticks); packet.write(Type.VAR_INT, ticks);
packet.send(Protocol1_13To1_12_2.class); packet.send(Protocol1_13To1_12_2.class);
@ -361,7 +361,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
int newItem = getMappingData().getItemMappings().get(item << 4 | i); int newItem = getMappingData().getItemMappings().get(item << 4 | i);
if (newItem != -1) { if (newItem != -1) {
PacketWrapper packet = wrapper.create(0x18); PacketWrapper packet = wrapper.create(ClientboundPackets1_13.COOLDOWN);
packet.write(Type.VAR_INT, newItem); packet.write(Type.VAR_INT, newItem);
packet.write(Type.VAR_INT, ticks); packet.write(Type.VAR_INT, ticks);
packet.send(Protocol1_13To1_12_2.class); packet.send(Protocol1_13To1_12_2.class);
@ -502,7 +502,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
wrapper.write(Type.STRING_ARRAY, stringIds); wrapper.write(Type.STRING_ARRAY, stringIds);
} }
if (action == 0) { if (action == 0) {
wrapper.create(0x54, new ValueCreator() { // Declare recipes wrapper.create(ClientboundPackets1_13.DECLARE_RECIPES, new ValueCreator() { // Declare recipes
@Override @Override
public void write(PacketWrapper wrapper) throws Exception { public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.VAR_INT, RecipeData.recipes.size()); wrapper.write(Type.VAR_INT, RecipeData.recipes.size());

Datei anzeigen

@ -134,7 +134,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1
equipmentPacket.write(Type.VAR_INT, entityId); equipmentPacket.write(Type.VAR_INT, entityId);
equipmentPacket.write(Type.VAR_INT, 4); equipmentPacket.write(Type.VAR_INT, 4);
equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, armorItem); equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, armorItem);
equipmentPacket.send(Protocol1_14To1_13_2.class); equipmentPacket.scheduleSend(Protocol1_14To1_13_2.class);
} }
} else if (type.is(Entity1_14Types.VILLAGER)) { } else if (type.is(Entity1_14Types.VILLAGER)) {
if (metadata.id() == 15) { if (metadata.id() == 15) {

Datei anzeigen

@ -107,7 +107,7 @@ public class EntityPackets {
velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 0)); velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 0));
velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 1)); velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 1));
velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 2)); velocity.write(Type.SHORT, wrapper.get(Type.SHORT, 2));
velocity.send(Protocol1_14To1_13_2.class); velocity.scheduleSend(Protocol1_14To1_13_2.class);
} }
// Register Type ID // Register Type ID
@ -181,7 +181,7 @@ public class EntityPackets {
int entityId = wrapper.get(Type.VAR_INT, 0); int entityId = wrapper.get(Type.VAR_INT, 0);
tracker.setSleeping(entityId, false); tracker.setSleeping(entityId, false);
PacketWrapper metadataPacket = wrapper.create(0x43); PacketWrapper metadataPacket = wrapper.create(ClientboundPackets1_14.ENTITY_METADATA);
metadataPacket.write(Type.VAR_INT, entityId); metadataPacket.write(Type.VAR_INT, entityId);
List<Metadata> metadataList = new LinkedList<>(); List<Metadata> metadataList = new LinkedList<>();
if (tracker.clientEntityId() != entityId) { if (tracker.clientEntityId() != entityId) {
@ -189,7 +189,7 @@ public class EntityPackets {
} }
metadataList.add(new Metadata(12, MetaType1_14.OptPosition, null)); metadataList.add(new Metadata(12, MetaType1_14.OptPosition, null));
metadataPacket.write(Types1_14.METADATA_LIST, metadataList); metadataPacket.write(Types1_14.METADATA_LIST, metadataList);
metadataPacket.send(Protocol1_14To1_13_2.class); metadataPacket.scheduleSendToServer(Protocol1_14To1_13_2.class);
} }
} }
}); });

Datei anzeigen

@ -327,7 +327,7 @@ public class WorldPackets {
PacketWrapper difficultyPacket = wrapper.create(ClientboundPackets1_14.SERVER_DIFFICULTY); PacketWrapper difficultyPacket = wrapper.create(ClientboundPackets1_14.SERVER_DIFFICULTY);
difficultyPacket.write(Type.UNSIGNED_BYTE, difficulty); difficultyPacket.write(Type.UNSIGNED_BYTE, difficulty);
difficultyPacket.write(Type.BOOLEAN, false); // Unknown value added in 19w11a difficultyPacket.write(Type.BOOLEAN, false); // Unknown value added in 19w11a
difficultyPacket.send(protocol.getClass()); difficultyPacket.scheduleSend(protocol.getClass());
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
wrapper.passthrough(Type.STRING); // Level Type wrapper.passthrough(Type.STRING); // Level Type
@ -383,7 +383,7 @@ public class WorldPackets {
PacketWrapper difficultyPacket = wrapper.create(ClientboundPackets1_14.SERVER_DIFFICULTY); PacketWrapper difficultyPacket = wrapper.create(ClientboundPackets1_14.SERVER_DIFFICULTY);
difficultyPacket.write(Type.UNSIGNED_BYTE, difficulty); difficultyPacket.write(Type.UNSIGNED_BYTE, difficulty);
difficultyPacket.write(Type.BOOLEAN, false); // Unknown value added in 19w11a difficultyPacket.write(Type.BOOLEAN, false); // Unknown value added in 19w11a
difficultyPacket.send(protocol.getClass()); difficultyPacket.scheduleSend(protocol.getClass());
} }
}); });
handler(wrapper -> { handler(wrapper -> {

Datei anzeigen

@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.api.type.types.version.Types1_8;
import com.viaversion.viaversion.api.type.types.version.Types1_9; import com.viaversion.viaversion.api.type.types.version.Types1_9;
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
@ -71,7 +72,7 @@ public class EntityPackets {
wrapper.cancel(); // Don't send current packet wrapper.cancel(); // Don't send current packet
PacketWrapper passengerPacket = wrapper.create(0x40); // Passenger Packet ID PacketWrapper passengerPacket = wrapper.create(ClientboundPackets1_9.SET_PASSENGERS);
if (vehicle == -1) { if (vehicle == -1) {
if (!tracker.getVehicleMap().containsKey(passenger)) if (!tracker.getVehicleMap().containsKey(passenger))
return null; // Cancel return null; // Cancel

Datei anzeigen

@ -63,7 +63,7 @@ public class InventoryPackets {
wrapper.write(Type.SHORT, property); wrapper.write(Type.SHORT, property);
wrapper.write(Type.SHORT, enchantID); wrapper.write(Type.SHORT, enchantID);
} }
}).send(Protocol1_9To1_8.class); }).scheduleSend(Protocol1_9To1_8.class);
wrapper.set(Type.SHORT, 0, (short) (property + 3)); wrapper.set(Type.SHORT, 0, (short) (property + 3));
wrapper.set(Type.SHORT, 1, level); wrapper.set(Type.SHORT, 1, level);
@ -360,7 +360,7 @@ public class InventoryPackets {
wrapper.write(Type.SHORT, slot); wrapper.write(Type.SHORT, slot);
wrapper.write(Type.ITEM, null); wrapper.write(Type.ITEM, null);
} }
}).send(Protocol1_9To1_8.class); }).scheduleSend(Protocol1_9To1_8.class);
// Finally reset to simulate throwing item // Finally reset to simulate throwing item
wrapper.set(Type.BYTE, 0, (byte) 0); // Set button to 0 wrapper.set(Type.BYTE, 0, (byte) 0); // Set button to 0
wrapper.set(Type.BYTE, 1, (byte) 0); // Set mode to 0 wrapper.set(Type.BYTE, 1, (byte) 0); // Set mode to 0

Datei anzeigen

@ -126,7 +126,7 @@ public class SpawnPackets {
wrapper.write(Types1_9.METADATA_LIST, meta); wrapper.write(Types1_9.METADATA_LIST, meta);
} }
}); });
metaPacket.send(Protocol1_9To1_8.class); metaPacket.scheduleSend(Protocol1_9To1_8.class);
} }
} }
}); });

Datei anzeigen

@ -433,7 +433,7 @@ public class WorldPackets {
updateBlockEntity.write(Type.UNSIGNED_BYTE, (short) 2); updateBlockEntity.write(Type.UNSIGNED_BYTE, (short) 2);
updateBlockEntity.write(Type.NBT, tag.get()); updateBlockEntity.write(Type.NBT, tag.get());
updateBlockEntity.send(Protocol1_9To1_8.class); updateBlockEntity.scheduleSend(Protocol1_9To1_8.class);
} }
} }
}); });