From b6caa30c163ab35b1a96ecbbffb770903c97d88b Mon Sep 17 00:00:00 2001 From: EnZaXD Date: Wed, 17 Jul 2024 19:06:44 +0200 Subject: [PATCH] Add alternative sculk shrieker mapping in 1.19->1.18.2 (#820) --- .../viabackwards/ViaBackwardsConfig.java | 7 +++++++ .../viabackwards/api/ViaBackwardsConfig.java | 7 +++++++ .../data/BackwardsMappingData1_19.java | 18 ++++++++++++++++++ .../resources/assets/viabackwards/config.yml | 4 ++++ 4 files changed, 36 insertions(+) diff --git a/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java b/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java index 71aed29f..9ee39754 100644 --- a/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java +++ b/common/src/main/java/com/viaversion/viabackwards/ViaBackwardsConfig.java @@ -35,6 +35,7 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback private boolean fix1_13FormattedInventoryTitles; private boolean handlePingsAsInvAcknowledgements; private boolean bedrockAtY0; + private boolean sculkShriekersToCryingObsidian; private boolean suppressEmulationWarnings; public ViaBackwardsConfig(File configFile, Logger logger) { @@ -55,6 +56,7 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true); handlePingsAsInvAcknowledgements = getBoolean("handle-pings-as-inv-acknowledgements", false); bedrockAtY0 = getBoolean("bedrock-at-y-0", false); + sculkShriekersToCryingObsidian = getBoolean("sculk-shriekers-to-crying-obsidian", false); suppressEmulationWarnings = getBoolean("suppress-emulation-warnings", false); } @@ -93,6 +95,11 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback return bedrockAtY0; } + @Override + public boolean sculkShriekerToCryingObsidian() { + return sculkShriekersToCryingObsidian; + } + @Override public boolean suppressEmulationWarnings() { return suppressEmulationWarnings; diff --git a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsConfig.java b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsConfig.java index 37554f57..08f0902a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsConfig.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/ViaBackwardsConfig.java @@ -71,6 +71,13 @@ public interface ViaBackwardsConfig extends Config { */ boolean bedrockAtY0(); + /** + * Shows sculk shriekers as crying obsidian for 1.18.2 clients on 1.19+ servers. This fixes collision and block breaking issues. + * + * @return true if enabled + */ + boolean sculkShriekerToCryingObsidian(); + /** * Suppresses warnings of missing emulations for certain features that are not supported (e.g. world height in 1.17+). * diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/data/BackwardsMappingData1_19.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/data/BackwardsMappingData1_19.java index 58a848b0..8f07f870 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/data/BackwardsMappingData1_19.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v1_19to1_18_2/data/BackwardsMappingData1_19.java @@ -17,6 +17,7 @@ */ package com.viaversion.viabackwards.protocol.v1_19to1_18_2.data; +import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.data.BackwardsMappingData; import com.viaversion.viabackwards.api.data.BackwardsMappingDataLoader; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; @@ -29,6 +30,8 @@ import org.checkerframework.checker.nullness.qual.Nullable; public final class BackwardsMappingData1_19 extends BackwardsMappingData { + private final boolean sculkShriekerToCryingObsidian = ViaBackwards.getConfig().sculkShriekerToCryingObsidian(); + private final Int2ObjectMap defaultChatTypes = new Int2ObjectOpenHashMap<>(); public BackwardsMappingData1_19() { @@ -39,6 +42,13 @@ public final class BackwardsMappingData1_19 extends BackwardsMappingData { protected void loadExtras(final CompoundTag data) { super.loadExtras(data); + if (sculkShriekerToCryingObsidian) { + blockMappings.setNewId(850, 750); + for (int i = 18900; i <= 18907; i++) { + blockStateMappings.setNewId(i, 16082); + } + } + final ListTag chatTypes = BackwardsMappingDataLoader.INSTANCE.loadNBT("chat-types-1.19.1.nbt").getListTag("values", CompoundTag.class); for (final CompoundTag chatType : chatTypes) { final NumberTag idTag = chatType.getNumberTag("id"); @@ -46,6 +56,14 @@ public final class BackwardsMappingData1_19 extends BackwardsMappingData { } } + @Override + public int getNewItemId(final int id) { + if (sculkShriekerToCryingObsidian && id == 329) { + return 1065; + } + return super.getNewItemId(id); + } + public @Nullable CompoundTag chatType(final int id) { return defaultChatTypes.get(id); } diff --git a/common/src/main/resources/assets/viabackwards/config.yml b/common/src/main/resources/assets/viabackwards/config.yml index 5d481cf6..f2ff5f37 100644 --- a/common/src/main/resources/assets/viabackwards/config.yml +++ b/common/src/main/resources/assets/viabackwards/config.yml @@ -24,5 +24,9 @@ handle-pings-as-inv-acknowledgements: false # Adds bedrock blocks at y=0 for sub 1.17 clients. This may allow for weird interactions due to sending fake blocks. bedrock-at-y-0: false # +# Shows sculk shriekers as crying obsidian for 1.18.2 clients on 1.19+ servers. This fixes collision and block breaking issues. +# If disabled, the client will see them as end portal frames. +sculk-shriekers-to-crying-obsidian: true +# # Suppresses warnings of missing emulations for certain features that are not supported (e.g. world height in 1.17+). suppress-emulation-warnings: false \ No newline at end of file