From 717b711ad876af7c81cc715b4f9fd88675efdef2 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Sat, 13 Jan 2024 06:54:20 +0100 Subject: [PATCH] Updated VV API usage --- .../MetadataRewriter1_16to20w14infinite.java | 47 +++++-------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/main/java/net/raphimc/viaaprilfools/protocols/protocol1_16to20w14infinite/metadata/MetadataRewriter1_16to20w14infinite.java b/src/main/java/net/raphimc/viaaprilfools/protocols/protocol1_16to20w14infinite/metadata/MetadataRewriter1_16to20w14infinite.java index 225fac1..3b61948 100644 --- a/src/main/java/net/raphimc/viaaprilfools/protocols/protocol1_16to20w14infinite/metadata/MetadataRewriter1_16to20w14infinite.java +++ b/src/main/java/net/raphimc/viaaprilfools/protocols/protocol1_16to20w14infinite/metadata/MetadataRewriter1_16to20w14infinite.java @@ -17,18 +17,13 @@ */ package net.raphimc.viaaprilfools.protocols.protocol1_16to20w14infinite.metadata; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16; -import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.types.version.Types1_14; import com.viaversion.viaversion.rewriter.EntityRewriter; import net.raphimc.viaaprilfools.protocols.protocol1_16to20w14infinite.ClientboundPackets20w14infinite; import net.raphimc.viaaprilfools.protocols.protocol1_16to20w14infinite.Protocol1_16to20w14infinite; -import java.util.List; - public class MetadataRewriter1_16to20w14infinite extends EntityRewriter { public MetadataRewriter1_16to20w14infinite(Protocol1_16to20w14infinite protocol) { @@ -37,38 +32,22 @@ public class MetadataRewriter1_16to20w14infinite extends EntityRewriter { + // Convert to new block id + int data = (int) meta.getValue(); + meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); + }); + + filter().type(EntityTypes1_16.ABSTRACT_ARROW).removeIndex(8); + } + @Override public EntityType typeFromId(int type) { return EntityTypes1_16.getTypeFromId(type); } - @Override - public void handleMetadata(int entityId, EntityType type, Metadata metadata, List metadatas, UserConnection connection) { - if (metadata.metaType() == Types1_14.META_TYPES.itemType) { - metadata.setValue(this.protocol.getItemRewriter().handleItemToClient(metadata.value())); - } else if (metadata.metaType() == Types1_14.META_TYPES.blockStateType) { - int data = (int) metadata.getValue(); - metadata.setValue(protocol.getMappingData().getNewBlockStateId(data)); - } else if (metadata.metaType() == Types1_14.META_TYPES.particleType) { - rewriteParticle((Particle) metadata.getValue()); - } - - if (type == null) return; - - if (type.isOrHasParent(EntityTypes1_16.MINECART_ABSTRACT) - && metadata.id() == 10) { - // Convert to new block id - int data = (int) metadata.getValue(); - metadata.setValue(protocol.getMappingData().getNewBlockStateId(data)); - } - - if (type.isOrHasParent(EntityTypes1_16.ABSTRACT_ARROW)) { - if (metadata.id() == 8) { - metadatas.remove(metadata); - } else if (metadata.id() > 8) { - metadata.setId(metadata.id() - 1); - } - } - } - }