Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Minor changes
Dieser Commit ist enthalten in:
Ursprung
57cf1803f3
Commit
eaa58affd1
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -113,49 +113,43 @@ 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) {
|
||||
wrapper.write(Type.VAR_INT, 2); // Size
|
||||
// Write root node
|
||||
wrapper.write(Type.BYTE, (byte) 0); // Mark as command
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{1}); // 1 child at index 1
|
||||
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
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{1}); // 1 child at index 1
|
||||
|
||||
// Write arg node
|
||||
wrapper.write(Type.BYTE, (byte) (0x02 | 0x04 | 0x10)); // Mark as command
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // No children
|
||||
// Extra data
|
||||
wrapper.write(Type.STRING, "args"); // Arg name
|
||||
wrapper.write(Type.STRING, "brigadier:string");
|
||||
wrapper.write(Type.VAR_INT, 2); // Greedy
|
||||
wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server
|
||||
// Write arg node
|
||||
wrapper.write(Type.BYTE, (byte) (0x02 | 0x04 | 0x10)); // Mark as command
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // No children
|
||||
// Extra data
|
||||
wrapper.write(Type.STRING, "args"); // Arg name
|
||||
wrapper.write(Type.STRING, "brigadier:string");
|
||||
wrapper.write(Type.VAR_INT, 2); // Greedy
|
||||
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);
|
||||
|
||||
// Send tags packet
|
||||
w.create(0x55, new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
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());
|
||||
// Needs copy as other protocols may modify it
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MAPPINGS.getItemTags().size()); // item tags
|
||||
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getItemTags().entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
// Needs copy as other protocols may modify it
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MAPPINGS.getFluidTags().size()); // fluid tags
|
||||
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getFluidTags().entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
// Needs copy as other protocols may modify it
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||
}
|
||||
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());
|
||||
// Needs copy as other protocols may modify it
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MAPPINGS.getItemTags().size()); // item tags
|
||||
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getItemTags().entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
// Needs copy as other protocols may modify it
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MAPPINGS.getFluidTags().size()); // fluid tags
|
||||
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getFluidTags().entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
// Needs copy as other protocols may modify it
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||
}
|
||||
}).send(Protocol1_13To1_12_2.class);
|
||||
};
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren