From f2628097ce1c402497ab2c471a3f61064697c49b Mon Sep 17 00:00:00 2001 From: KennyTV <28825609+KennyTV@users.noreply.github.com> Date: Sun, 21 Apr 2019 20:03:07 +0200 Subject: [PATCH] Remap areaeffectcloud particles --- .../MetadataRewriter.java | 51 +++++++++++-------- .../packets/WorldPackets.java | 19 +------ 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java index f04cae655..5bfdae0bf 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/MetadataRewriter.java @@ -9,8 +9,8 @@ import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14; import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.InventoryPackets; -import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker; import java.util.ArrayList; import java.util.List; @@ -22,8 +22,6 @@ public class MetadataRewriter { try { metadata.setMetaType(MetaType1_14.byId(metadata.getMetaType().getTypeID())); - EntityTracker tracker = connection.get(EntityTracker.class); - if (metadata.getMetaType() == MetaType1_14.Slot) { InventoryPackets.toClient((Item) metadata.getValue()); } else if (metadata.getMetaType() == MetaType1_14.BlockID) { @@ -50,9 +48,7 @@ public class MetadataRewriter { int data = (int) metadata.getValue(); metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data)); } - } - - if (type.is(Entity1_14Types.EntityType.HORSE)) { + } else if (type.is(Entity1_14Types.EntityType.HORSE)) { if (metadata.getId() == 18) { metadatas.remove(metadata); @@ -72,9 +68,7 @@ public class MetadataRewriter { equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, armorItem); equipmentPacket.send(Protocol1_14To1_13_2.class); } - } - - if (type.is(Entity1_14Types.EntityType.VILLAGER)) { + } else if (type.is(Entity1_14Types.EntityType.VILLAGER)) { if (metadata.getId() == 15) { // plains metadata.setValue(new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0)); @@ -86,33 +80,30 @@ public class MetadataRewriter { metadata.setValue(new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0)); metadata.setMetaType(MetaType1_14.VillagerData); } - } - - if (type.isOrHasParent(Entity1_14Types.EntityType.ARROW)) { + } else if (type.isOrHasParent(Entity1_14Types.EntityType.ARROW)) { if (metadata.getId() >= 9) { metadata.setId(metadata.getId() + 1); } - } - - if (type.is(Entity1_14Types.EntityType.FIREWORKS_ROCKET)) { + } else if (type.is(Entity1_14Types.EntityType.FIREWORKS_ROCKET)) { if (metadata.getId() == 8) { if (metadata.getValue().equals(0)) metadata.setValue(null); // https://bugs.mojang.com/browse/MC-111480 metadata.setMetaType(MetaType1_14.OptVarInt); } - } - - if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_SKELETON)) { + } else if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_SKELETON)) { if (metadata.getId() == 12) { metadatas.remove(metadata); // TODO "Is swinging arms", maybe moved to pos / entity status } - } - - if (type.isOrHasParent(Entity1_14Types.EntityType.ZOMBIE)) { + } else if (type.isOrHasParent(Entity1_14Types.EntityType.ZOMBIE)) { if (metadata.getId() == 16) { metadatas.remove(metadata); // TODO "Are hands held up", maybe moved to pos / entity status } else if (metadata.getId() > 16) { metadata.setId(metadata.getId() - 1); } + } else if (type.is(Entity1_14Types.EntityType.AREA_EFFECT_CLOUD)) { + if (metadata.getId() == 10) { + Particle particle = (Particle) metadata.getValue(); + particle.setId(getNewParticleId(particle.getId())); + } } if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_ILLAGER_BASE)) { @@ -158,4 +149,22 @@ public class MetadataRewriter { } } + public static int getNewParticleId(int id) { + if (id >= 10) { + id += 2; // new lava drips 10, 11 + } + if (id >= 13) { + id += 1; // new water drip 11 -> 13 + } + if (id >= 27) { + id += 1; // new 24 -> 27 + } + if (id >= 29) { + id += 1; // skip new short happy villager + } + if (id >= 44) { + id += 1; // new 39 -> 44 + } + return id; + } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java index 83f8e0ae6..960f23211 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/packets/WorldPackets.java @@ -15,6 +15,7 @@ import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; +import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.MetadataRewriter; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker; @@ -248,23 +249,7 @@ public class WorldPackets { InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); } - int newId = id; - if (newId >= 10) { - newId += 2; // new lava drips 10, 11 - } - if (newId >= 13) { - newId += 1; // new water drip 11 -> 13 - } - if (newId >= 27) { - newId += 1; // new 24 -> 27 - } - if (newId >= 29) { - newId += 1; // skip new short happy villager - } - if (newId >= 44) { - newId += 1; // new 39 -> 44 - } - + int newId = MetadataRewriter.getNewParticleId(id); if (newId != id) { wrapper.set(Type.INT, 0, newId); }