From 23955e53857fa6965274f18a00e6bd3c1e1868d3 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 18 Apr 2024 19:16:42 +0200 Subject: [PATCH] Update particle format in biome registry data --- .../rewriter/EntityPacketRewriter1_20_5.java | 68 ++++++++++++++++++ .../data/mappings-1.20to1.19.4.nbt | Bin 3696 -> 3726 bytes 2 files changed, 68 insertions(+) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java index 93ca0c7f..97bae05c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_20_3to1_20_5/rewriter/EntityPacketRewriter1_20_5.java @@ -35,8 +35,11 @@ import com.viaversion.viaversion.api.type.types.version.Types1_20_3; import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.data.entity.DimensionDataImpl; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.FloatTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_5; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5; @@ -103,6 +106,21 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter dimensionDataMap = new HashMap<>(entries.length); final String[] keys = new String[entries.length]; @@ -256,6 +274,56 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter colorParts = (ListTag) color; + color = new FloatTag(encodeARGB( + colorParts.get(0).getValue().floatValue(), + colorParts.get(1).getValue().floatValue(), + colorParts.get(2).getValue().floatValue(), + colorParts.get(3).getValue().floatValue() + )); + } + options.put("value", color); + } + } + + private int encodeARGB(final float a, final float r, final float g, final float b) { + final int encodedAlpha = encodeColorPart(a); + final int encodedRed = encodeColorPart(r); + final int encodedGreen = encodeColorPart(g); + final int encodedBlue = encodeColorPart(b); + return encodedAlpha << 24 | encodedRed << 16 | encodedGreen << 8 | encodedBlue; + } + + private int encodeColorPart(final float part) { + return (int) Math.floor(part * 255); + } + + private void moveTag(final CompoundTag compoundTag, final String from, final String to) { + final Tag tag = compoundTag.remove(from); + if (tag != null) { + compoundTag.put(to, tag); + } + } + private void updateDimensionTypeData(final CompoundTag elementTag) { final CompoundTag monsterSpawnLightLevel = elementTag.getCompoundTag("monster_spawn_light_level"); if (monsterSpawnLightLevel != null) { diff --git a/common/src/main/resources/assets/viabackwards/data/mappings-1.20to1.19.4.nbt b/common/src/main/resources/assets/viabackwards/data/mappings-1.20to1.19.4.nbt index 965e792cf4795a5ef10e7d1d82eb0b490b59908c..d7c13c7ec6da5b7da7535151f76eb6b0bcbff9d9 100644 GIT binary patch delta 188 zcmew$(MK zRe|I^u$q5h5qSMK zRe|I^u$q5h5qSC4h9xOBNIyoNkcs&1BHN`)Vz{Pg@F8$lGLI~h2V_D$tfHl a{jFef83)MLlVJ8M4h3eQ{>|E)$*ce}H7%V0