Remap areaeffectcloud particles

This commit is contained in:
KennyTV 2019-04-21 20:03:07 +02:00
parent 49e85e2b8a
commit f2628097ce
2 changed files with 32 additions and 38 deletions

View File

@ -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.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
import us.myles.ViaVersion.api.type.Type; 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.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -22,8 +22,6 @@ public class MetadataRewriter {
try { try {
metadata.setMetaType(MetaType1_14.byId(metadata.getMetaType().getTypeID())); metadata.setMetaType(MetaType1_14.byId(metadata.getMetaType().getTypeID()));
EntityTracker tracker = connection.get(EntityTracker.class);
if (metadata.getMetaType() == MetaType1_14.Slot) { if (metadata.getMetaType() == MetaType1_14.Slot) {
InventoryPackets.toClient((Item) metadata.getValue()); InventoryPackets.toClient((Item) metadata.getValue());
} else if (metadata.getMetaType() == MetaType1_14.BlockID) { } else if (metadata.getMetaType() == MetaType1_14.BlockID) {
@ -50,9 +48,7 @@ public class MetadataRewriter {
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data)); metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data));
} }
} } else if (type.is(Entity1_14Types.EntityType.HORSE)) {
if (type.is(Entity1_14Types.EntityType.HORSE)) {
if (metadata.getId() == 18) { if (metadata.getId() == 18) {
metadatas.remove(metadata); metadatas.remove(metadata);
@ -72,9 +68,7 @@ public class MetadataRewriter {
equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, armorItem); equipmentPacket.write(Type.FLAT_VAR_INT_ITEM, armorItem);
equipmentPacket.send(Protocol1_14To1_13_2.class); equipmentPacket.send(Protocol1_14To1_13_2.class);
} }
} } else if (type.is(Entity1_14Types.EntityType.VILLAGER)) {
if (type.is(Entity1_14Types.EntityType.VILLAGER)) {
if (metadata.getId() == 15) { if (metadata.getId() == 15) {
// plains // plains
metadata.setValue(new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0)); 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.setValue(new VillagerData(2, getNewProfessionId((int) metadata.getValue()), 0));
metadata.setMetaType(MetaType1_14.VillagerData); metadata.setMetaType(MetaType1_14.VillagerData);
} }
} } else if (type.isOrHasParent(Entity1_14Types.EntityType.ARROW)) {
if (type.isOrHasParent(Entity1_14Types.EntityType.ARROW)) {
if (metadata.getId() >= 9) { if (metadata.getId() >= 9) {
metadata.setId(metadata.getId() + 1); metadata.setId(metadata.getId() + 1);
} }
} } else if (type.is(Entity1_14Types.EntityType.FIREWORKS_ROCKET)) {
if (type.is(Entity1_14Types.EntityType.FIREWORKS_ROCKET)) {
if (metadata.getId() == 8) { if (metadata.getId() == 8) {
if (metadata.getValue().equals(0)) metadata.setValue(null); // https://bugs.mojang.com/browse/MC-111480 if (metadata.getValue().equals(0)) metadata.setValue(null); // https://bugs.mojang.com/browse/MC-111480
metadata.setMetaType(MetaType1_14.OptVarInt); metadata.setMetaType(MetaType1_14.OptVarInt);
} }
} } else if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_SKELETON)) {
if (type.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_SKELETON)) {
if (metadata.getId() == 12) { if (metadata.getId() == 12) {
metadatas.remove(metadata); // TODO "Is swinging arms", maybe moved to pos / entity status metadatas.remove(metadata); // TODO "Is swinging arms", maybe moved to pos / entity status
} }
} } else if (type.isOrHasParent(Entity1_14Types.EntityType.ZOMBIE)) {
if (type.isOrHasParent(Entity1_14Types.EntityType.ZOMBIE)) {
if (metadata.getId() == 16) { if (metadata.getId() == 16) {
metadatas.remove(metadata); // TODO "Are hands held up", maybe moved to pos / entity status metadatas.remove(metadata); // TODO "Are hands held up", maybe moved to pos / entity status
} else if (metadata.getId() > 16) { } else if (metadata.getId() > 16) {
metadata.setId(metadata.getId() - 1); 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)) { 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;
}
} }

View File

@ -15,6 +15,7 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; 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_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.Protocol1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker; 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)); InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
} }
int newId = id; int newId = MetadataRewriter.getNewParticleId(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
}
if (newId != id) { if (newId != id) {
wrapper.set(Type.INT, 0, newId); wrapper.set(Type.INT, 0, newId);
} }