3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-10-08 11:10:06 +02:00
Dieser Commit ist enthalten in:
KennyTV 2021-06-01 22:52:05 +02:00
Ursprung 57cf1803f3
Commit eaa58affd1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 63 neuen und 61 gelöschten Zeilen

Datei anzeigen

@ -238,30 +238,44 @@ public interface PacketWrapper {
void send() throws Exception;
/**
* Create a new packet for the target of this packet.
* Creates a new packet for the target of this packet.
*
* @param packetType packet type of the new packet
* @return The newly created packet wrapper
*/
PacketWrapper create(PacketType packetType);
default PacketWrapper create(PacketType packetType) {
return create(packetType.getId());
}
/**
* Create a new packet for the target of this packet.
* Creates a new packet with values.
*
* @param packetID The ID of the new packet
* @return The newly created packet wrapper
* @param packetType packet type of the new packet
* @param valueCreator ValueCreator to write to the packet
* @return newly created packet wrapper
* @throws Exception if it failed to write the values from the ValueCreator.
*/
PacketWrapper create(int packetID);
default PacketWrapper create(PacketType packetType, ValueCreator valueCreator) throws Exception {
return create(packetType.getId(), valueCreator);
}
/**
* Create a new packet with values.
* Creates a new packet for the target of this packet.
*
* @param packetID The ID of the new packet
* @param init A ValueCreator to write to the packet.
* @return The newly created packet wrapper
* @throws Exception If it failed to write the values from the ValueCreator.
* @param packetId id of the packet
* @return newly created packet wrapper
*/
PacketWrapper create(int packetID, ValueCreator init) throws Exception;
PacketWrapper create(int packetId);
/**
* Creates a new packet with values.
*
* @param packetId id of the packet
* @param valueCreator ValueCreator to write to the packet.
* @return newly created packet wrapper
* @throws Exception if it failed to write the values from the ValueCreator.
*/
PacketWrapper create(int packetId, ValueCreator valueCreator) throws Exception;
/**
* Applies a pipeline from an index to the wrapper.

Datei anzeigen

@ -22,7 +22,6 @@ import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.Direction;
import com.viaversion.viaversion.api.protocol.packet.PacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.ValueCreator;
@ -322,19 +321,14 @@ public class PacketWrapperImpl implements PacketWrapper {
}
@Override
public PacketWrapperImpl create(PacketType packetType) {
return new PacketWrapperImpl(packetType.getId(), null, user());
public PacketWrapperImpl create(int packetId) {
return new PacketWrapperImpl(packetId, null, user());
}
@Override
public PacketWrapperImpl create(int packetID) {
return new PacketWrapperImpl(packetID, null, user());
}
@Override
public PacketWrapperImpl create(int packetID, ValueCreator init) throws Exception {
PacketWrapperImpl wrapper = create(packetID);
init.write(wrapper);
public PacketWrapperImpl create(int packetId, ValueCreator valueCreator) throws Exception {
PacketWrapperImpl wrapper = create(packetId);
valueCreator.write(wrapper);
return wrapper;
}

Datei anzeigen

@ -113,9 +113,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
private static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS =
w -> {
// Send fake declare commands
w.create(0x11, new ValueCreator() {
@Override
public void write(PacketWrapper wrapper) {
w.create(ClientboundPackets1_13.DECLARE_COMMANDS, wrapper -> {
wrapper.write(Type.VAR_INT, 2); // Size
// Write root node
wrapper.write(Type.BYTE, (byte) 0); // Mark as command
@ -131,13 +129,10 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server
wrapper.write(Type.VAR_INT, 0); // Root node index
}
}).send(Protocol1_13To1_12_2.class);
// Send tags packet
w.create(0x55, new ValueCreator() {
@Override
public void write(PacketWrapper wrapper) throws Exception {
w.create(ClientboundPackets1_13.TAGS, wrapper -> {
wrapper.write(Type.VAR_INT, MAPPINGS.getBlockTags().size()); // block tags
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getBlockTags().entrySet()) {
wrapper.write(Type.STRING, tag.getKey());
@ -156,7 +151,6 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
// Needs copy as other protocols may modify it
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
}
}
}).send(Protocol1_13To1_12_2.class);
};