From b7a090e828a0e1782f805a5119be2dedef2031f0 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Sat, 12 Oct 2024 10:38:29 -0400 Subject: [PATCH] Added both `minecraft:example` and `example` format of entity type support for dab blacklist --- ...fferfish-Dynamic-Activation-of-Brain.patch | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/patches/server/0008-Pufferfish-Dynamic-Activation-of-Brain.patch b/patches/server/0008-Pufferfish-Dynamic-Activation-of-Brain.patch index 4a8ed9c85..104787eee 100644 --- a/patches/server/0008-Pufferfish-Dynamic-Activation-of-Brain.patch +++ b/patches/server/0008-Pufferfish-Dynamic-Activation-of-Brain.patch @@ -295,13 +295,14 @@ index 71a3eadd2f1e00fa066dbfe9918d749d43435a18..03513d3b6118ac5d0a58788462dcbc98 } diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java b/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java new file mode 100644 -index 0000000000000000000000000000000000000000..bde8bd5e8288f5cbeaedbbb1450159b019432fe6 +index 0000000000000000000000000000000000000000..ed8496e344284f79ff66c1d216090a218d95c311 --- /dev/null +++ b/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java -@@ -0,0 +1,57 @@ +@@ -0,0 +1,67 @@ +package org.dreeam.leaf.config.modules.opt; + +import net.minecraft.core.registries.BuiltInRegistries; ++import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EntityType; +import org.dreeam.leaf.config.ConfigModules; +import org.dreeam.leaf.config.EnumConfigCategory; @@ -350,10 +351,19 @@ index 0000000000000000000000000000000000000000..bde8bd5e8288f5cbeaedbbb1450159b0 + entityType.dabEnabled = true; // reset all, before setting the ones to true + } + -+ blackedEntities.forEach(name -> EntityType.byString(name).ifPresentOrElse(entityType -> -+ entityType.dabEnabled = false, -+ () -> LeafConfig.LOGGER.warn("Skip unknown entity {}, in {}", name, getBasePath() + ".blacklisted-entities") -+ )); ++ final String DEFAULT_PREFIX = ResourceLocation.DEFAULT_NAMESPACE + ResourceLocation.NAMESPACE_SEPARATOR; ++ ++ for (String name : blackedEntities) { ++ // Be compatible with both `minecraft:example` and `example` syntax ++ // If unknown, show user config value in the logger instead of parsed result ++ String typeId = name.toLowerCase().startsWith(DEFAULT_PREFIX) ? name : DEFAULT_PREFIX + name; ++ ++ EntityType.byString(typeId).ifPresentOrElse(entityType -> ++ entityType.dabEnabled = false, ++ () -> LeafConfig.LOGGER.warn("Skip unknown entity {}, in {}", name, getBasePath() + ".blacklisted-entities") ++ ++ ); ++ } + } +} diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java