Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-16 04:50:08 +01:00
Small cleanup of a few rewriters
Dieser Commit ist enthalten in:
Ursprung
a993a08b8d
Commit
2a71612aea
@ -199,6 +199,10 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T passthroughAndMap(Type<?> type, Type<T> mappedType) throws InformativeException {
|
public <T> T passthroughAndMap(Type<?> type, Type<T> mappedType) throws InformativeException {
|
||||||
|
if (type == mappedType) {
|
||||||
|
return passthrough(mappedType);
|
||||||
|
}
|
||||||
|
|
||||||
final Object value = read(type);
|
final Object value = read(type);
|
||||||
final T mappedValue = attemptTransform(mappedType, value);
|
final T mappedValue = attemptTransform(mappedType, value);
|
||||||
write(mappedType, mappedValue);
|
write(mappedType, mappedValue);
|
||||||
|
@ -68,7 +68,7 @@ public final class Protocol1_16_4To1_17 extends AbstractProtocol<ClientboundPack
|
|||||||
wrapper.write(Types.STRING, type.resourceLocation());
|
wrapper.write(Types.STRING, type.resourceLocation());
|
||||||
|
|
||||||
// Id conversion
|
// Id conversion
|
||||||
tagRewriter.handle(wrapper, tagRewriter.getRewriter(type), tagRewriter.getNewTags(type));
|
tagRewriter.handle(wrapper, type);
|
||||||
|
|
||||||
// Stop iterating after entity types
|
// Stop iterating after entity types
|
||||||
if (type == RegistryType.ENTITY) {
|
if (type == RegistryType.ENTITY) {
|
||||||
|
@ -29,18 +29,11 @@ import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvide
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
|
import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
|
||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.CommandRewriter1_19_4;
|
import com.viaversion.viaversion.protocols.v1_19_3to1_19_4.rewriter.CommandRewriter1_19_4;
|
||||||
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundConfigurationPackets1_20_2;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPacket1_20_2;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPackets1_20_2;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPacket1_20_2;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundConfigurationPackets1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundConfigurationPackets1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPacket1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPacket1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPackets1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPackets1_20_3;
|
||||||
@ -48,6 +41,12 @@ import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ServerboundPac
|
|||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ServerboundPackets1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ServerboundPackets1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.BlockItemPacketRewriter1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.BlockItemPacketRewriter1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.EntityPacketRewriter1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.EntityPacketRewriter1_20_3;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundConfigurationPackets1_20_2;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPacket1_20_2;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ClientboundPackets1_20_2;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundConfigurationPackets1_20_2;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPacket1_20_2;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20to1_20_2.packet.ServerboundPackets1_20_2;
|
||||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
@ -306,7 +305,7 @@ public final class Protocol1_20_2To1_20_3 extends AbstractProtocol<ClientboundPa
|
|||||||
|
|
||||||
registerServerbound(ServerboundConfigurationPackets1_20_2.RESOURCE_PACK, resourcePackStatusHandler());
|
registerServerbound(ServerboundConfigurationPackets1_20_2.RESOURCE_PACK, resourcePackStatusHandler());
|
||||||
registerClientbound(ClientboundConfigurationPackets1_20_2.RESOURCE_PACK, ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_PUSH, resourcePackHandler(ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_POP));
|
registerClientbound(ClientboundConfigurationPackets1_20_2.RESOURCE_PACK, ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_PUSH, resourcePackHandler(ClientboundConfigurationPackets1_20_3.RESOURCE_PACK_POP));
|
||||||
registerClientbound(ClientboundConfigurationPackets1_20_2.UPDATE_TAGS, tagRewriter.getGenericHandler());
|
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_2.UPDATE_TAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PacketHandler resourcePackStatusHandler() {
|
private PacketHandler resourcePackStatusHandler() {
|
||||||
|
@ -304,8 +304,10 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
wrapper.passthrough(Types.FLOAT); // Knockback Z
|
wrapper.passthrough(Types.FLOAT); // Knockback Z
|
||||||
wrapper.passthrough(Types.VAR_INT); // Block interaction type
|
wrapper.passthrough(Types.VAR_INT); // Block interaction type
|
||||||
|
|
||||||
protocol.getEntityRewriter().rewriteParticle(wrapper, Types1_20_3.PARTICLE, Types1_20_5.PARTICLE); // Small explosion particle
|
final Particle smallExplosionParticle = wrapper.passthroughAndMap(Types1_20_3.PARTICLE, Types1_20_5.PARTICLE);
|
||||||
protocol.getEntityRewriter().rewriteParticle(wrapper, Types1_20_3.PARTICLE, Types1_20_5.PARTICLE); // Large explosion particle
|
final Particle largeExplosionParticle = wrapper.passthroughAndMap(Types1_20_3.PARTICLE, Types1_20_5.PARTICLE);
|
||||||
|
rewriteParticle(wrapper.user(), smallExplosionParticle);
|
||||||
|
rewriteParticle(wrapper.user(), largeExplosionParticle);
|
||||||
|
|
||||||
final String sound = wrapper.read(Types.STRING);
|
final String sound = wrapper.read(Types.STRING);
|
||||||
final Float range = wrapper.read(Types.OPTIONAL_FLOAT);
|
final Float range = wrapper.read(Types.OPTIONAL_FLOAT);
|
||||||
|
@ -116,12 +116,12 @@ public final class Protocol1_20To1_20_2 extends AbstractProtocol<ClientboundPack
|
|||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_19_4.UPDATE_TAGS, wrapper -> {
|
registerClientbound(ClientboundPackets1_19_4.UPDATE_TAGS, wrapper -> {
|
||||||
tagRewriter.getGenericHandler().handle(wrapper);
|
tagRewriter.handleGeneric(wrapper);
|
||||||
wrapper.resetReader();
|
wrapper.resetReader();
|
||||||
wrapper.user().put(new LastTags(wrapper));
|
wrapper.user().put(new LastTags(wrapper));
|
||||||
});
|
});
|
||||||
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.UPDATE_TAGS.getId(), ClientboundConfigurationPackets1_20_2.UPDATE_TAGS.getId(), wrapper -> {
|
registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.UPDATE_TAGS.getId(), ClientboundConfigurationPackets1_20_2.UPDATE_TAGS.getId(), wrapper -> {
|
||||||
tagRewriter.getGenericHandler().handle(wrapper);
|
tagRewriter.handleGeneric(wrapper);
|
||||||
wrapper.resetReader();
|
wrapper.resetReader();
|
||||||
wrapper.user().put(new LastTags(wrapper));
|
wrapper.user().put(new LastTags(wrapper));
|
||||||
});
|
});
|
||||||
|
@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.v1_20to1_20_2.storage;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.protocols.v1_20to1_20_2.Protocol1_20To1_20_2;
|
import com.viaversion.viaversion.protocols.v1_20to1_20_2.Protocol1_20To1_20_2;
|
||||||
@ -34,15 +35,14 @@ public class LastTags implements StorableObject {
|
|||||||
public LastTags(final PacketWrapper wrapper) {
|
public LastTags(final PacketWrapper wrapper) {
|
||||||
final int length = wrapper.passthrough(Types.VAR_INT);
|
final int length = wrapper.passthrough(Types.VAR_INT);
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
final List<Tag> tags = new ArrayList<>();
|
final List<TagData> tags = new ArrayList<>();
|
||||||
final String registryKey = wrapper.passthrough(Types.STRING);
|
final String registryKey = wrapper.passthrough(Types.STRING);
|
||||||
final int tagsSize = wrapper.passthrough(Types.VAR_INT);
|
final int tagsSize = wrapper.passthrough(Types.VAR_INT);
|
||||||
for (int j = 0; j < tagsSize; j++) {
|
for (int j = 0; j < tagsSize; j++) {
|
||||||
final String key = wrapper.passthrough(Types.STRING);
|
final String key = wrapper.passthrough(Types.STRING);
|
||||||
final int[] ids = wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE);
|
final int[] ids = wrapper.passthrough(Types.VAR_INT_ARRAY_PRIMITIVE);
|
||||||
tags.add(new Tag(key, ids));
|
tags.add(new TagData(key, ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.registryTags.add(new RegistryTags(registryKey, tags));
|
this.registryTags.add(new RegistryTags(registryKey, tags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,17 +57,14 @@ public class LastTags implements StorableObject {
|
|||||||
for (final RegistryTags registryTag : registryTags) {
|
for (final RegistryTags registryTag : registryTags) {
|
||||||
packet.write(Types.STRING, registryTag.registryKey);
|
packet.write(Types.STRING, registryTag.registryKey);
|
||||||
packet.write(Types.VAR_INT, registryTag.tags.size());
|
packet.write(Types.VAR_INT, registryTag.tags.size());
|
||||||
for (final Tag tag : registryTag.tags) {
|
for (final TagData tag : registryTag.tags) {
|
||||||
packet.write(Types.STRING, tag.key);
|
packet.write(Types.STRING, tag.identifier());
|
||||||
packet.write(Types.VAR_INT_ARRAY_PRIMITIVE, Arrays.copyOf(tag.ids, tag.ids.length));
|
packet.write(Types.VAR_INT_ARRAY_PRIMITIVE, Arrays.copyOf(tag.entries(), tag.entries().length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packet.send(Protocol1_20To1_20_2.class);
|
packet.send(Protocol1_20To1_20_2.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private record RegistryTags(String registryKey, List<Tag> tags) {
|
private record RegistryTags(String registryKey, List<TagData> tags) {
|
||||||
}
|
|
||||||
|
|
||||||
private record Tag(String key, int[] ids) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||||
@ -602,12 +601,6 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
particle.setId(protocol.getMappingData().getNewParticleId(id));
|
particle.setId(protocol.getMappingData().getNewParticleId(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rewriteParticle(PacketWrapper wrapper, Type<Particle> from, Type<Particle> to) {
|
|
||||||
final Particle particle = wrapper.read(from);
|
|
||||||
rewriteParticle(wrapper.user(), particle);
|
|
||||||
wrapper.write(to, particle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void logException(Exception e, @Nullable EntityType type, List<EntityData> entityDataList, EntityData entityData) {
|
private void logException(Exception e, @Nullable EntityType type, List<EntityData> entityDataList, EntityData entityData) {
|
||||||
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
|
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
|
||||||
protocol.getLogger().severe("An error occurred in entity data handler " + this.getClass().getSimpleName()
|
protocol.getLogger().severe("An error occurred in entity data handler " + this.getClass().getSimpleName()
|
||||||
|
@ -95,20 +95,14 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerSetContent(C packetType) {
|
public void registerSetContent(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
protocol.registerClientbound(packetType, wrapper -> {
|
||||||
@Override
|
wrapper.passthrough(Types.UNSIGNED_BYTE); // Container id
|
||||||
public void register() {
|
Item[] items = wrapper.passthroughAndMap(itemArrayType, mappedItemArrayType);
|
||||||
map(Types.UNSIGNED_BYTE); // Window id
|
|
||||||
handler(wrapper -> {
|
|
||||||
Item[] items = wrapper.read(itemArrayType);
|
|
||||||
wrapper.write(mappedItemArrayType, items);
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
items[i] = handleItemToClient(wrapper.user(), items[i]);
|
items[i] = handleItemToClient(wrapper.user(), items[i]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerSetContent1_17_1(C packetType) {
|
public void registerSetContent1_17_1(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@ -117,8 +111,7 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
map(Types.UNSIGNED_BYTE); // Window id
|
map(Types.UNSIGNED_BYTE); // Window id
|
||||||
map(Types.VAR_INT); // State id
|
map(Types.VAR_INT); // State id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
Item[] items = wrapper.read(itemArrayType);
|
Item[] items = wrapper.passthroughAndMap(itemArrayType, mappedItemArrayType);
|
||||||
wrapper.write(mappedItemArrayType, items);
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
items[i] = handleItemToClient(wrapper.user(), items[i]);
|
items[i] = handleItemToClient(wrapper.user(), items[i]);
|
||||||
}
|
}
|
||||||
@ -522,9 +515,8 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
map(Types.FLOAT); // Particle Data
|
map(Types.FLOAT); // Particle Data
|
||||||
map(Types.INT); // Particle Count
|
map(Types.INT); // Particle Count
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final Particle particle = wrapper.read(particleType);
|
final Particle particle = wrapper.passthroughAndMap(particleType, mappedParticleType);
|
||||||
rewriteParticle(wrapper.user(), particle);
|
rewriteParticle(wrapper.user(), particle);
|
||||||
wrapper.write(mappedParticleType, particle);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -548,10 +540,8 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
|||||||
wrapper.passthrough(Types.FLOAT); // Knockback Z
|
wrapper.passthrough(Types.FLOAT); // Knockback Z
|
||||||
wrapper.passthrough(Types.VAR_INT); // Block interaction type
|
wrapper.passthrough(Types.VAR_INT); // Block interaction type
|
||||||
|
|
||||||
final Particle smallExplosionParticle = wrapper.read(particleType);
|
final Particle smallExplosionParticle = wrapper.passthroughAndMap(particleType, mappedParticleType);
|
||||||
final Particle largeExplosionParticle = wrapper.read(particleType);
|
final Particle largeExplosionParticle = wrapper.passthroughAndMap(particleType, mappedParticleType);
|
||||||
wrapper.write(mappedParticleType, smallExplosionParticle);
|
|
||||||
wrapper.write(mappedParticleType, largeExplosionParticle);
|
|
||||||
rewriteParticle(wrapper.user(), smallExplosionParticle);
|
rewriteParticle(wrapper.user(), smallExplosionParticle);
|
||||||
rewriteParticle(wrapper.user(), largeExplosionParticle);
|
rewriteParticle(wrapper.user(), largeExplosionParticle);
|
||||||
|
|
||||||
|
@ -158,8 +158,7 @@ public class RecipeRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void handleIngredient(final PacketWrapper wrapper) {
|
protected void handleIngredient(final PacketWrapper wrapper) {
|
||||||
final Item[] items = wrapper.read(itemArrayType());
|
final Item[] items = wrapper.passthroughAndMap(itemArrayType(), mappedItemArrayType());
|
||||||
wrapper.write(mappedItemArrayType(), items);
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
Item item = items[i];
|
Item item = items[i];
|
||||||
items[i] = rewrite(wrapper.user(), item);
|
items[i] = rewrite(wrapper.user(), item);
|
||||||
|
@ -125,13 +125,13 @@ public class TagRewriter<C extends ClientboundPacketType> implements com.viavers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerGeneric(C packetType) {
|
public void registerGeneric(C packetType) {
|
||||||
protocol.registerClientbound(packetType, getGenericHandler());
|
protocol.registerClientbound(packetType, this::handleGeneric);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketHandler getHandler(@Nullable RegistryType readUntilType) {
|
public PacketHandler getHandler(@Nullable RegistryType readUntilType) {
|
||||||
return wrapper -> {
|
return wrapper -> {
|
||||||
for (RegistryType type : RegistryType.getValues()) {
|
for (RegistryType type : RegistryType.getValues()) {
|
||||||
handle(wrapper, getRewriter(type), getNewTags(type), toRename.get(type), toRemove.get(type));
|
handle(wrapper, type);
|
||||||
|
|
||||||
// Stop iterating
|
// Stop iterating
|
||||||
if (type == readUntilType) {
|
if (type == readUntilType) {
|
||||||
@ -141,15 +141,14 @@ public class TagRewriter<C extends ClientboundPacketType> implements com.viavers
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketHandler getGenericHandler() {
|
public void handleGeneric(final PacketWrapper wrapper) {
|
||||||
return wrapper -> {
|
|
||||||
final int length = wrapper.passthrough(Types.VAR_INT);
|
final int length = wrapper.passthrough(Types.VAR_INT);
|
||||||
int editedLength = length;
|
int editedLength = length;
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
String registryKey = wrapper.read(Types.STRING);
|
final String registryKey = wrapper.read(Types.STRING);
|
||||||
if (toRemoveRegistries.contains(Key.stripMinecraftNamespace(registryKey))) {
|
if (toRemoveRegistries.contains(Key.stripMinecraftNamespace(registryKey))) {
|
||||||
wrapper.set(Types.VAR_INT, 0, --editedLength);
|
wrapper.set(Types.VAR_INT, 0, --editedLength);
|
||||||
int tagsSize = wrapper.read(Types.VAR_INT);
|
final int tagsSize = wrapper.read(Types.VAR_INT);
|
||||||
for (int j = 0; j < tagsSize; j++) {
|
for (int j = 0; j < tagsSize; j++) {
|
||||||
wrapper.read(Types.STRING);
|
wrapper.read(Types.STRING);
|
||||||
wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE);
|
wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE);
|
||||||
@ -158,23 +157,30 @@ public class TagRewriter<C extends ClientboundPacketType> implements com.viavers
|
|||||||
}
|
}
|
||||||
|
|
||||||
wrapper.write(Types.STRING, registryKey);
|
wrapper.write(Types.STRING, registryKey);
|
||||||
registryKey = Key.stripMinecraftNamespace(registryKey);
|
handle(wrapper, Key.stripMinecraftNamespace(registryKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RegistryType type = RegistryType.getByKey(registryKey);
|
public void handle(final PacketWrapper wrapper, final String registryKey) {
|
||||||
|
final RegistryType type = RegistryType.getByKey(registryKey);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
handle(wrapper, getRewriter(type), getNewTags(type), toRename.get(type), toRemove.get(type));
|
handle(wrapper, type);
|
||||||
} else {
|
} else {
|
||||||
handle(wrapper, null, null, null, null);
|
handle(wrapper, null, null, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
public void handle(PacketWrapper wrapper, RegistryType registryType) {
|
||||||
|
handle(wrapper, getRewriter(registryType), getNewTags(registryType), toRename.get(registryType), toRemove.get(registryType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketWrapper wrapper, @Nullable IdRewriteFunction rewriteFunction, @Nullable List<TagData> newTags) {
|
protected void handle(
|
||||||
handle(wrapper, rewriteFunction, newTags, null, null);
|
PacketWrapper wrapper,
|
||||||
}
|
@Nullable IdRewriteFunction rewriteFunction,
|
||||||
|
@Nullable List<TagData> newTags,
|
||||||
public void handle(PacketWrapper wrapper, @Nullable IdRewriteFunction rewriteFunction, @Nullable List<TagData> newTags, @Nullable Map<String, String> tagsToRename, @Nullable Set<String> tagsToRemove) {
|
@Nullable Map<String, String> tagsToRename,
|
||||||
|
@Nullable Set<String> tagsToRemove
|
||||||
|
) {
|
||||||
final int tagsSize = wrapper.read(Types.VAR_INT);
|
final int tagsSize = wrapper.read(Types.VAR_INT);
|
||||||
final List<TagData> tags = new ArrayList<>(newTags != null ? tagsSize + newTags.size() : tagsSize);
|
final List<TagData> tags = new ArrayList<>(newTags != null ? tagsSize + newTags.size() : tagsSize);
|
||||||
final Set<String> currentTags = new HashSet<>(tagsSize);
|
final Set<String> currentTags = new HashSet<>(tagsSize);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren