From c4a8708085f22365466c7a766e1d02b380b1140c Mon Sep 17 00:00:00 2001 From: MCTian-mi <35869948+MCTian-mi@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:52:13 +0800 Subject: [PATCH] add config to stop skeleton traps from spawning during thunderstorms --- .../config/UTConfigTweaks.java | 5 +++++ .../universaltweaks/core/UTLoadingPlugin.java | 1 + .../mixin/UTSkeletonTrapSpawningMixin.java | 19 +++++++++++++++++++ .../mixins.tweaks.entities.skeletontrap.json | 7 +++++++ 4 files changed, 32 insertions(+) create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/spawning/skeletontrap/mixin/UTSkeletonTrapSpawningMixin.java create mode 100644 src/main/resources/mixins.tweaks.entities.skeletontrap.json diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index 7d843190..7385608c 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -916,6 +916,11 @@ public static class UndeadHorsesCategory @Config.Name("Taming Undead Horses") @Config.Comment("Allows taming of undead horses") public boolean utTamingUndeadHorsesToggle = true; + + @Config.RequiresMcRestart + @Config.Name("No Skeleton Trap Spawning") + @Config.Comment("Prevents skeleton traps spawning during thunderstorms") + public boolean utSkeletonTrapSpawningToggle = false; } public static class WaterFallDamageCategory diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index 81206705..085f87e9 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -122,6 +122,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader put("mixins.tweaks.entities.speed.cobweb.json", () -> UTConfigTweaks.ENTITIES.COBWEB_SLOWNESS.utCobwebSlownessToggle); put("mixins.tweaks.entities.speed.player.json", () -> UTConfigTweaks.ENTITIES.PLAYER_SPEED.utPlayerSpeedToggle); put("mixins.tweaks.entities.taming.horse.json", () -> UTConfigTweaks.ENTITIES.UNDEAD_HORSES.utTamingUndeadHorsesToggle); + put("mixins.tweaks.entities.skeletontrap.json", () -> UTConfigTweaks.ENTITIES.UNDEAD_HORSES.utSkeletonTrapSpawningToggle); put("mixins.tweaks.entities.trading.json", () -> UTConfigTweaks.ENTITIES.utVillagerTradeLevelingToggle || UTConfigTweaks.ENTITIES.utVillagerTradeRestockToggle); put("mixins.tweaks.entities.voidteleport.json", () -> UTConfigTweaks.ENTITIES.VOID_TELEPORT.utVoidTeleportToggle); put("mixins.tweaks.items.attackcooldown.server.json", () -> UTConfigTweaks.ITEMS.ATTACK_COOLDOWN.utAttackCooldownToggle); diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/spawning/skeletontrap/mixin/UTSkeletonTrapSpawningMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/spawning/skeletontrap/mixin/UTSkeletonTrapSpawningMixin.java new file mode 100644 index 00000000..2b5aa276 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/spawning/skeletontrap/mixin/UTSkeletonTrapSpawningMixin.java @@ -0,0 +1,19 @@ +package mod.acgaming.universaltweaks.tweaks.entities.spawning.skeletontrap.mixin; + +import net.minecraft.entity.Entity; +import net.minecraft.world.WorldServer; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(WorldServer.class) +public class UTSkeletonTrapSpawningMixin +{ + @Redirect(method = "updateBlocks()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/WorldServer;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) + private boolean utSkeletonTrapSpawning(WorldServer worldIn, Entity entityIn) + { + return !UTConfigTweaks.ENTITIES.UNDEAD_HORSES.utSkeletonTrapSpawningToggle && worldIn.spawnEntity(entityIn); + } +} diff --git a/src/main/resources/mixins.tweaks.entities.skeletontrap.json b/src/main/resources/mixins.tweaks.entities.skeletontrap.json new file mode 100644 index 00000000..8b231b82 --- /dev/null +++ b/src/main/resources/mixins.tweaks.entities.skeletontrap.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.tweaks.entities.spawning.skeletontrap.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTSkeletonTrapSpawningMixin"] +} \ No newline at end of file