Update item type in area effect cloud particles in 1.13.2->1.13.1

This commit is contained in:
Nassim Jahnke 2024-10-28 12:21:57 +01:00
parent a94d06716c
commit 5a576d66b4
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F

View File

@ -18,9 +18,12 @@
package com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.rewriter; package com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.Protocol1_13_2To1_13_1; import com.viaversion.viabackwards.protocol.v1_13_2to1_13_1.Protocol1_13_2To1_13_1;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; 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.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_13; import com.viaversion.viaversion.api.type.types.version.Types1_13;
import com.viaversion.viaversion.api.type.types.version.Types1_13_2; import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
@ -47,11 +50,7 @@ public class EntityPacketRewriter1_13_2 {
map(Types.SHORT); // 11 - Velocity Z map(Types.SHORT); // 11 - Velocity Z
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 12 - Entity data map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 12 - Entity data
handler(wrapper -> { handler(EntityPacketRewriter1_13_2::updateEntityData);
for (EntityData entityData : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
entityData.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(entityData.dataType().typeId()));
}
});
} }
}); });
@ -67,11 +66,7 @@ public class EntityPacketRewriter1_13_2 {
map(Types.BYTE); // 6 - Pitch map(Types.BYTE); // 6 - Pitch
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 7 - Entity data map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 7 - Entity data
handler(wrapper -> { handler(EntityPacketRewriter1_13_2::updateEntityData);
for (EntityData entityData : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
entityData.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(entityData.dataType().typeId()));
}
});
} }
}); });
@ -81,13 +76,23 @@ public class EntityPacketRewriter1_13_2 {
map(Types.VAR_INT); // 0 - Entity ID map(Types.VAR_INT); // 0 - Entity ID
map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 1 - Entity data list map(Types1_13_2.ENTITY_DATA_LIST, Types1_13.ENTITY_DATA_LIST); // 1 - Entity data list
handler(wrapper -> { handler(EntityPacketRewriter1_13_2::updateEntityData);
for (EntityData entityData : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
entityData.setDataType(Types1_13.ENTITY_DATA_TYPES.byId(entityData.dataType().typeId()));
}
});
} }
}); });
} }
private static void updateEntityData(final PacketWrapper wrapper) {
for (final EntityData data : wrapper.get(Types1_13.ENTITY_DATA_LIST, 0)) {
final EntityDataType dataType = Types1_13.ENTITY_DATA_TYPES.byId(data.dataType().typeId());
data.setDataType(dataType);
if (dataType == Types1_13.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, item);
}
}
}
}
} }