3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Rewrite area effect cloud data

Fixes #2082
Dieser Commit ist enthalten in:
KennyTV 2020-09-21 11:12:32 +02:00
Ursprung 52f542774f
Commit b8c204b306
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
6 geänderte Dateien mit 30 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.ParticleMappings;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.EntityType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@ -13,6 +14,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.storage.EntityTracker;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;
import java.util.ArrayList;
import java.util.List;
@ -50,6 +52,20 @@ public abstract class MetadataRewriter {
}
}
protected void rewriteParticle(Particle particle) {
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
int id = particle.getId();
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
Particle.ParticleData data = particle.getArguments().get(0);
data.setValue(protocol.getMappingData().getNewBlockStateId(data.get()));
} else if (id == mappings.getItemId()) {
Particle.ParticleData data = particle.getArguments().get(0);
data.setValue(protocol.getMappingData().getNewItemId(data.get()));
}
particle.setId(protocol.getMappingData().getNewParticleId(id));
}
//TODO add respawn/join once they stop changing too much
public void registerTracker(ClientboundPacketType packetType) {

Datei anzeigen

@ -50,6 +50,10 @@ public class Particle {
return value;
}
public <T> T get() {
return (T) value;
}
public void setValue(Object value) {
this.value = value;
}

Datei anzeigen

@ -148,8 +148,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
}
} else if (type.is(Entity1_14Types.EntityType.AREA_EFFECT_CLOUD)) {
if (metadata.getId() == 10) {
Particle particle = (Particle) metadata.getValue();
particle.setId(protocol.getMappingData().getNewParticleId(particle.getId()));
rewriteParticle((Particle) metadata.getValue());
}
}

Datei anzeigen

@ -7,6 +7,7 @@ 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.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.InventoryPackets;
@ -47,6 +48,8 @@ public class MetadataRewriter1_15To1_14_4 extends MetadataRewriter {
} else if (metadata.getId() > 18) {
metadata.setId(metadata.getId() - 1);
}
} else if (type == Entity1_15Types.EntityType.AREA_EFFECT_CLOUD && metadata.getId() == 10) {
rewriteParticle((Particle) metadata.getValue());
}
}

Datei anzeigen

@ -8,6 +8,7 @@ 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.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.storage.EntityTracker1_16_2;
@ -38,6 +39,10 @@ public class MetadataRewriter1_16_2To1_16_1 extends MetadataRewriter {
} else if (metadata.getId() == 16) {
metadata.setId(15);
}
} else if (type.is(Entity1_16_2Types.EntityType.AREA_EFFECT_CLOUD)) {
if (metadata.getId() == 10) {
rewriteParticle((Particle) metadata.getValue());
}
}
}

Datei anzeigen

@ -36,8 +36,7 @@ public class MetadataRewriter1_16To1_15_2 extends MetadataRewriter {
if (type == Entity1_16Types.EntityType.AREA_EFFECT_CLOUD) {
if (metadata.getId() == 10) {
Particle particle = (Particle) metadata.getValue();
particle.setId(protocol.getMappingData().getNewParticleId(particle.getId()));
rewriteParticle((Particle) metadata.getValue());
}
} else if (type.isOrHasParent(Entity1_16Types.EntityType.ABSTRACT_ARROW)) {
if (metadata.getId() == 8) {