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;
|
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
|
* @param packetType packet type of the new packet
|
||||||
* @return The newly created packet wrapper
|
* @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
|
* @param packetType packet type of the new packet
|
||||||
* @return The newly created packet wrapper
|
* @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 packetId id of the packet
|
||||||
* @param init A ValueCreator to write to the packet.
|
* @return newly created packet wrapper
|
||||||
* @return The newly created packet wrapper
|
|
||||||
* @throws Exception If it failed to write the values from the ValueCreator.
|
|
||||||
*/
|
*/
|
||||||
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.
|
* 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.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
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.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueCreator;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueCreator;
|
||||||
@ -322,19 +321,14 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketWrapperImpl create(PacketType packetType) {
|
public PacketWrapperImpl create(int packetId) {
|
||||||
return new PacketWrapperImpl(packetType.getId(), null, user());
|
return new PacketWrapperImpl(packetId, null, user());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketWrapperImpl create(int packetID) {
|
public PacketWrapperImpl create(int packetId, ValueCreator valueCreator) throws Exception {
|
||||||
return new PacketWrapperImpl(packetID, null, user());
|
PacketWrapperImpl wrapper = create(packetId);
|
||||||
}
|
valueCreator.write(wrapper);
|
||||||
|
|
||||||
@Override
|
|
||||||
public PacketWrapperImpl create(int packetID, ValueCreator init) throws Exception {
|
|
||||||
PacketWrapperImpl wrapper = create(packetID);
|
|
||||||
init.write(wrapper);
|
|
||||||
return 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 =
|
private static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS =
|
||||||
w -> {
|
w -> {
|
||||||
// Send fake declare commands
|
// Send fake declare commands
|
||||||
w.create(0x11, new ValueCreator() {
|
w.create(ClientboundPackets1_13.DECLARE_COMMANDS, wrapper -> {
|
||||||
@Override
|
wrapper.write(Type.VAR_INT, 2); // Size
|
||||||
public void write(PacketWrapper wrapper) {
|
// Write root node
|
||||||
wrapper.write(Type.VAR_INT, 2); // Size
|
wrapper.write(Type.BYTE, (byte) 0); // Mark as command
|
||||||
// Write root node
|
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{1}); // 1 child at index 1
|
||||||
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
|
// Write arg node
|
||||||
wrapper.write(Type.BYTE, (byte) (0x02 | 0x04 | 0x10)); // Mark as command
|
wrapper.write(Type.BYTE, (byte) (0x02 | 0x04 | 0x10)); // Mark as command
|
||||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // No children
|
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[0]); // No children
|
||||||
// Extra data
|
// Extra data
|
||||||
wrapper.write(Type.STRING, "args"); // Arg name
|
wrapper.write(Type.STRING, "args"); // Arg name
|
||||||
wrapper.write(Type.STRING, "brigadier:string");
|
wrapper.write(Type.STRING, "brigadier:string");
|
||||||
wrapper.write(Type.VAR_INT, 2); // Greedy
|
wrapper.write(Type.VAR_INT, 2); // Greedy
|
||||||
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);
|
}).send(Protocol1_13To1_12_2.class);
|
||||||
|
|
||||||
// Send tags packet
|
// Send tags packet
|
||||||
w.create(0x55, new ValueCreator() {
|
w.create(ClientboundPackets1_13.TAGS, wrapper -> {
|
||||||
@Override
|
wrapper.write(Type.VAR_INT, MAPPINGS.getBlockTags().size()); // block tags
|
||||||
public void write(PacketWrapper wrapper) throws Exception {
|
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getBlockTags().entrySet()) {
|
||||||
wrapper.write(Type.VAR_INT, MAPPINGS.getBlockTags().size()); // block tags
|
wrapper.write(Type.STRING, tag.getKey());
|
||||||
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getBlockTags().entrySet()) {
|
// Needs copy as other protocols may modify it
|
||||||
wrapper.write(Type.STRING, tag.getKey());
|
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||||
// 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.VAR_INT, MAPPINGS.getItemTags().size()); // item tags
|
wrapper.write(Type.STRING, tag.getKey());
|
||||||
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getItemTags().entrySet()) {
|
// Needs copy as other protocols may modify it
|
||||||
wrapper.write(Type.STRING, tag.getKey());
|
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||||
// 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.VAR_INT, MAPPINGS.getFluidTags().size()); // fluid tags
|
wrapper.write(Type.STRING, tag.getKey());
|
||||||
for (Map.Entry<String, Integer[]> tag : MAPPINGS.getFluidTags().entrySet()) {
|
// Needs copy as other protocols may modify it
|
||||||
wrapper.write(Type.STRING, tag.getKey());
|
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
||||||
// Needs copy as other protocols may modify it
|
|
||||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).send(Protocol1_13To1_12_2.class);
|
}).send(Protocol1_13To1_12_2.class);
|
||||||
};
|
};
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren