9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-04 15:41:40 +00:00

Added both minecraft:example and example format of entity type support for dab blacklist

This commit is contained in:
Dreeam
2024-10-12 10:38:29 -04:00
parent 3e45fc81a8
commit b7a090e828

View File

@@ -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