From c3662ac76f04e38d1c4b4f678c199cb182a41a37 Mon Sep 17 00:00:00 2001 From: RoccoDev Date: Tue, 22 Sep 2026 02:53:10 +0200 Subject: [PATCH 1/2] Map splash potion IDs in level event --- .../v1_9to1_8/data/PotionIdMappings1_8.java | 26 +++++++++++++++++++ .../rewriter/WorldPacketRewriter1_9.java | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/data/PotionIdMappings1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/data/PotionIdMappings1_8.java index 0d7870a54..97b4e48e8 100644 --- a/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/data/PotionIdMappings1_8.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/data/PotionIdMappings1_8.java @@ -17,6 +17,8 @@ */ package com.viaversion.viarewind.protocol.v1_9to1_8.data; +import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; +import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; import com.viaversion.viaversion.protocols.v1_8to1_9.data.PotionIdMappings1_9; import java.util.HashMap; import java.util.Map; @@ -24,6 +26,7 @@ public class PotionIdMappings1_8 { public static final Map POTION_NAME_INDEX = new HashMap<>(); public static final Map POTION_NAME_TO_ID = new HashMap<>(); + public static final Int2ObjectMap SPLASH_MAPPINGS = new Int2ObjectOpenHashMap<>(); static { POTION_NAME_TO_ID.putAll(PotionIdMappings1_9.POTION_NAME_TO_ID); @@ -75,5 +78,28 @@ public class PotionIdMappings1_8 { POTION_NAME_INDEX.put("luck_lingering", "§rLingering Potion of Luck"); POTION_NAME_INDEX.put("luck", "§rPotion of Luck"); POTION_NAME_INDEX.put("luck_splash", "§rSplash Potion of Luck"); + + SPLASH_MAPPINGS.put(5, "night_vision"); + SPLASH_MAPPINGS.put(7, "invisibility"); + SPLASH_MAPPINGS.put(9, "leaping"); + SPLASH_MAPPINGS.put(12, "fire_resistance"); + SPLASH_MAPPINGS.put(14, "swiftness"); + SPLASH_MAPPINGS.put(17, "slowness"); + SPLASH_MAPPINGS.put(19, "water_breathing"); + SPLASH_MAPPINGS.put(21, "healing"); + SPLASH_MAPPINGS.put(23, "harming"); + SPLASH_MAPPINGS.put(25, "poison"); + SPLASH_MAPPINGS.put(28, "regeneration"); + SPLASH_MAPPINGS.put(31, "strength"); + SPLASH_MAPPINGS.put(34, "weakness"); + SPLASH_MAPPINGS.put(36, "luck"); + } + + public static int getIdForSplash(int id1_9) { + final String key = SPLASH_MAPPINGS.get(id1_9); + if (key == null) { + return -1; + } + return POTION_NAME_TO_ID.getOrDefault(key, -1); } } diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/WorldPacketRewriter1_9.java b/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/WorldPacketRewriter1_9.java index 9a0ce2543..df61b9b11 100644 --- a/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/WorldPacketRewriter1_9.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/WorldPacketRewriter1_9.java @@ -24,6 +24,7 @@ import com.viaversion.viarewind.protocol.v1_9to1_8.Protocol1_9To1_8; import com.viaversion.viarewind.protocol.v1_9to1_8.data.CommandBlockState; import com.viaversion.viarewind.protocol.v1_9to1_8.data.EffectIdMappings1_8; +import com.viaversion.viarewind.protocol.v1_9to1_8.data.PotionIdMappings1_8; import com.viaversion.viarewind.protocol.v1_9to1_8.storage.CommandBlockStateStorage; import com.viaversion.viaversion.api.minecraft.BlockPosition; import com.viaversion.viaversion.api.minecraft.Environment; @@ -237,6 +238,11 @@ public void register() { if (id == 2001) { int replacedBlock = protocol.getItemRewriter().handleBlockId(wrapper.get(Types.INT, 1)); wrapper.set(Types.INT, 1, replacedBlock); + } else if (id == 2002) { + final int mappedSplash = PotionIdMappings1_8.getIdForSplash(wrapper.get(Types.INT, 1)); + if (mappedSplash != -1) { + wrapper.set(Types.INT, 1, mappedSplash); + } } }); } From ab929d22f739f806c88c3695796196c1c4fcba63 Mon Sep 17 00:00:00 2001 From: RoccoDev Date: Mon, 23 Nov 2026 22:25:55 +0100 Subject: [PATCH 2/2] Use VV mappings for splash potion IDs --- .../v1_9to1_8/data/PotionIdMappings1_8.java | 35 +++++++------------ .../rewriter/WorldPacketRewriter1_9.java | 4 +-- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/data/PotionIdMappings1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/data/PotionIdMappings1_8.java index 97b4e48e8..e9bc97769 100644 --- a/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/data/PotionIdMappings1_8.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/data/PotionIdMappings1_8.java @@ -17,16 +17,18 @@ */ package com.viaversion.viarewind.protocol.v1_9to1_8.data; -import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; -import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; +import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap; +import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap; import com.viaversion.viaversion.protocols.v1_8to1_9.data.PotionIdMappings1_9; + import java.util.HashMap; import java.util.Map; public class PotionIdMappings1_8 { public static final Map POTION_NAME_INDEX = new HashMap<>(); public static final Map POTION_NAME_TO_ID = new HashMap<>(); - public static final Int2ObjectMap SPLASH_MAPPINGS = new Int2ObjectOpenHashMap<>(); + public static final Int2IntMap SPLASH_MAPPINGS = new Int2IntOpenHashMap(); + private static final int SPLASH_MASK = 16384; static { POTION_NAME_TO_ID.putAll(PotionIdMappings1_9.POTION_NAME_TO_ID); @@ -79,27 +81,16 @@ public class PotionIdMappings1_8 { POTION_NAME_INDEX.put("luck", "§rPotion of Luck"); POTION_NAME_INDEX.put("luck_splash", "§rSplash Potion of Luck"); - SPLASH_MAPPINGS.put(5, "night_vision"); - SPLASH_MAPPINGS.put(7, "invisibility"); - SPLASH_MAPPINGS.put(9, "leaping"); - SPLASH_MAPPINGS.put(12, "fire_resistance"); - SPLASH_MAPPINGS.put(14, "swiftness"); - SPLASH_MAPPINGS.put(17, "slowness"); - SPLASH_MAPPINGS.put(19, "water_breathing"); - SPLASH_MAPPINGS.put(21, "healing"); - SPLASH_MAPPINGS.put(23, "harming"); - SPLASH_MAPPINGS.put(25, "poison"); - SPLASH_MAPPINGS.put(28, "regeneration"); - SPLASH_MAPPINGS.put(31, "strength"); - SPLASH_MAPPINGS.put(34, "weakness"); - SPLASH_MAPPINGS.put(36, "luck"); + SPLASH_MAPPINGS.defaultReturnValue(SPLASH_MASK); // splash water + for (Int2IntMap.Entry entry : PotionIdMappings1_9.POTION_INDEX.int2IntEntrySet()) { + if (entry.getIntKey() >= 0) { + SPLASH_MAPPINGS.put(entry.getIntValue(), entry.getIntKey() | SPLASH_MASK); + } + } + SPLASH_MAPPINGS.put(36, POTION_NAME_TO_ID.get("luck") | SPLASH_MASK); } public static int getIdForSplash(int id1_9) { - final String key = SPLASH_MAPPINGS.get(id1_9); - if (key == null) { - return -1; - } - return POTION_NAME_TO_ID.getOrDefault(key, -1); + return SPLASH_MAPPINGS.get(id1_9); } } diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/WorldPacketRewriter1_9.java b/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/WorldPacketRewriter1_9.java index df61b9b11..c11caeff3 100644 --- a/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/WorldPacketRewriter1_9.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/v1_9to1_8/rewriter/WorldPacketRewriter1_9.java @@ -240,9 +240,7 @@ public void register() { wrapper.set(Types.INT, 1, replacedBlock); } else if (id == 2002) { final int mappedSplash = PotionIdMappings1_8.getIdForSplash(wrapper.get(Types.INT, 1)); - if (mappedSplash != -1) { - wrapper.set(Types.INT, 1, mappedSplash); - } + wrapper.set(Types.INT, 1, mappedSplash); } }); }