Skip to content

Commit

Permalink
Added both minecraft:example and example format of entity type su…
Browse files Browse the repository at this point in the history
…pport for dab blacklist
  • Loading branch information
Dreeam-qwq committed Oct 12, 2024
1 parent 3e45fc8 commit b7a090e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions patches/server/0008-Pufferfish-Dynamic-Activation-of-Brain.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b7a090e

Please sign in to comment.