Fix two area effect cloud item particle issues

This commit is contained in:
Nassim Jahnke 2024-10-28 12:09:04 +01:00
parent f914d57678
commit ee16d7af28
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
2 changed files with 23 additions and 3 deletions

View File

@ -17,7 +17,10 @@
*/
package com.viaversion.viaversion.protocols.v1_13_1to1_13_2.rewriter;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types;
@ -30,8 +33,16 @@ public class EntityPacketRewriter1_13_2 {
public static void register(Protocol1_13_1To1_13_2 protocol) {
final PacketHandler dataTypeHandler = wrapper -> {
for (EntityData data : wrapper.get(Types1_13_2.ENTITY_DATA_LIST, 0)) {
data.setDataType(Types1_13_2.ENTITY_DATA_TYPES.byId(data.dataType().typeId()));
for (final EntityData data : wrapper.get(Types1_13_2.ENTITY_DATA_LIST, 0)) {
final EntityDataType dataType = Types1_13_2.ENTITY_DATA_TYPES.byId(data.dataType().typeId());
if (dataType == Types1_13_2.ENTITY_DATA_TYPES.particleType) {
final Particle particle = data.value();
if (particle.id() == 27) {
final Item item = particle.<Item>getArgument(0).getValue();
particle.set(0, Types.ITEM1_13_2, item);
}
}
data.setDataType(dataType);
}
};

View File

@ -18,7 +18,10 @@
package com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.StructuredItem;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.packet.ClientboundPacket1_20_3;
@ -34,8 +37,14 @@ public final class ParticleRewriter1_20_5 extends ParticleRewriter<ClientboundPa
public void rewriteParticle(final UserConnection connection, final Particle particle) {
super.rewriteParticle(connection, particle);
if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) {
final ParticleMappings particleMappings = protocol.getMappingData().getParticleMappings();
if (particle.id() == particleMappings.mappedId("entity_effect")) {
particle.add(Types.INT, 0); // Default color, changed in the area effect handler
} else if (particle.id() == particleMappings.mappedId("item")) {
final Particle.ParticleData<Item> data = particle.getArgument(0);
if (data.getValue().isEmpty()) {
data.setValue(new StructuredItem(1, 1));
}
}
}
}