From eed1eab73b06ae366240b8057c03bde0c15dccd5 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Sat, 13 Jul 2024 21:46:34 +0200 Subject: [PATCH] Implement burning mobs tweaks --- .../config/UTConfigTweaks.java | 10 ++++++-- .../universaltweaks/core/UTLoadingPlugin.java | 2 +- .../mixin/UTBurningBabyZombiesMixin.java | 5 ++-- .../mobs/mixin/UTBurningSkeletonsMixin.java | 24 +++++++++++++++++++ .../mobs/mixin/UTBurningZombiesMixin.java | 18 ++++++++++++++ .../util/compat/UTObsoleteModsHandler.java | 1 + ... mixins.tweaks.entities.burning.mobs.json} | 4 ++-- 7 files changed, 56 insertions(+), 8 deletions(-) rename src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/{zombie => mobs}/mixin/UTBurningBabyZombiesMixin.java (90%) create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningSkeletonsMixin.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningZombiesMixin.java rename src/main/resources/{mixins.tweaks.entities.burning.zombie.json => mixins.tweaks.entities.burning.mobs.json} (60%) diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index b9e5341f..306ad247 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -2,7 +2,6 @@ import java.util.HashMap; import java.util.Map; - import com.cleanroommc.configanytime.ConfigAnytime; import mod.acgaming.universaltweaks.UniversalTweaks; import mod.acgaming.universaltweaks.core.UTLoadingPlugin; @@ -474,11 +473,18 @@ public static class EntitiesCategory @Config.Comment("Sets the acceleration value for controlling boats") public double utBoatSpeed = 0.04D; - @Config.RequiresMcRestart @Config.Name("Burning Baby Zombies") @Config.Comment("Lets baby zombies burn in daylight as in Minecraft 1.13+") public boolean utBurningBabyZombiesToggle = true; + @Config.Name("Burning Skeletons") + @Config.Comment("Lets skeletons burn in daylight") + public boolean utBurningSkeletonsToggle = true; + + @Config.Name("Burning Zombies") + @Config.Comment("Lets zombies burn in daylight") + public boolean utBurningZombiesToggle = true; + @Config.Name("Creeper Charged Spawning Chance") @Config.Comment("Sets the chance for creepers to spawn charged") @Config.RangeDouble(min = 0.0D, max = 1.0D) diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index 0fcb8ddb..d600f208 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -94,7 +94,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader put("mixins.tweaks.entities.ai.wither.json", () -> UTConfigTweaks.ENTITIES.utWitherAIToggle); put("mixins.tweaks.entities.armedarmorstands.json", () -> UTConfigTweaks.ENTITIES.utArmedArmorStandsToggle); put("mixins.tweaks.entities.burning.horse.json", () -> UTConfigTweaks.ENTITIES.UNDEAD_HORSES.utBurningUndeadHorsesToggle); - put("mixins.tweaks.entities.burning.zombie.json", () -> UTConfigTweaks.ENTITIES.utBurningBabyZombiesToggle); + put("mixins.tweaks.entities.burning.mobs.json", () -> UTConfigTweaks.ENTITIES.utBurningBabyZombiesToggle); put("mixins.tweaks.entities.damage.arrow.json", () -> UTConfigTweaks.ENTITIES.utCriticalArrowDamage != -1); put("mixins.tweaks.entities.damage.collision.json", () -> UTConfigTweaks.ENTITIES.COLLISION_DAMAGE.utCollisionDamageToggle); put("mixins.tweaks.entities.damage.falling.json", () -> UTConfigTweaks.ENTITIES.WATER_FALL_DAMAGE.utFallDamageToggle); diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/zombie/mixin/UTBurningBabyZombiesMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningBabyZombiesMixin.java similarity index 90% rename from src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/zombie/mixin/UTBurningBabyZombiesMixin.java rename to src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningBabyZombiesMixin.java index 518b283b..412be39e 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/zombie/mixin/UTBurningBabyZombiesMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningBabyZombiesMixin.java @@ -1,8 +1,7 @@ -package mod.acgaming.universaltweaks.tweaks.entities.burning.zombie.mixin; - -import net.minecraft.entity.monster.EntityZombie; +package mod.acgaming.universaltweaks.tweaks.entities.burning.mobs.mixin; import mod.acgaming.universaltweaks.config.UTConfigTweaks; +import net.minecraft.entity.monster.EntityZombie; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningSkeletonsMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningSkeletonsMixin.java new file mode 100644 index 00000000..2372512f --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningSkeletonsMixin.java @@ -0,0 +1,24 @@ +package mod.acgaming.universaltweaks.tweaks.entities.burning.mobs.mixin; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; +import net.minecraft.entity.monster.AbstractSkeleton; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(AbstractSkeleton.class) +public abstract class UTBurningSkeletonsMixin extends EntityMob +{ + protected UTBurningSkeletonsMixin(World worldIn) + { + super(worldIn); + } + + @Redirect(method = "onLivingUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isDaytime()Z")) + public boolean utBurningSkeletons(World instance) + { + return this.world.isDaytime() && UTConfigTweaks.ENTITIES.utBurningSkeletonsToggle; + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningZombiesMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningZombiesMixin.java new file mode 100644 index 00000000..5a5efb86 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/burning/mobs/mixin/UTBurningZombiesMixin.java @@ -0,0 +1,18 @@ +package mod.acgaming.universaltweaks.tweaks.entities.burning.mobs.mixin; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; +import net.minecraft.entity.monster.EntityZombie; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(EntityZombie.class) +public abstract class UTBurningZombiesMixin +{ + @Inject(method = "shouldBurnInDay", at = @At(value = "HEAD"), cancellable = true) + public void utBurningZombies(CallbackInfoReturnable cir) + { + cir.setReturnValue(UTConfigTweaks.ENTITIES.utBurningZombiesToggle); + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/util/compat/UTObsoleteModsHandler.java b/src/main/java/mod/acgaming/universaltweaks/util/compat/UTObsoleteModsHandler.java index f13ae492..0a74f9ef 100644 --- a/src/main/java/mod/acgaming/universaltweaks/util/compat/UTObsoleteModsHandler.java +++ b/src/main/java/mod/acgaming/universaltweaks/util/compat/UTObsoleteModsHandler.java @@ -90,6 +90,7 @@ public class UTObsoleteModsHandler put("loginhpfix", () -> UTConfigBugfixes.ENTITIES.utMaxHealthToggle); put("maxhealthfixer", () -> UTConfigBugfixes.ENTITIES.utMaxHealthToggle); put("mendingfix", () -> UTConfigTweaks.ITEMS.MENDING.utMendingToggle); + put("mobsunscreen", () -> !UTConfigTweaks.ENTITIES.utBurningSkeletonsToggle || !UTConfigTweaks.ENTITIES.utBurningZombiesToggle); put("movingquickly", () -> UTConfigTweaks.ENTITIES.PLAYER_SPEED.utPlayerSpeedToggle); put("mtqfix", () -> UTConfigTweaks.ENTITIES.PLAYER_SPEED.utPlayerSpeedToggle); put("mup", () -> true); diff --git a/src/main/resources/mixins.tweaks.entities.burning.zombie.json b/src/main/resources/mixins.tweaks.entities.burning.mobs.json similarity index 60% rename from src/main/resources/mixins.tweaks.entities.burning.zombie.json rename to src/main/resources/mixins.tweaks.entities.burning.mobs.json index a8f07bb5..a4826529 100644 --- a/src/main/resources/mixins.tweaks.entities.burning.zombie.json +++ b/src/main/resources/mixins.tweaks.entities.burning.mobs.json @@ -1,7 +1,7 @@ { - "package": "mod.acgaming.universaltweaks.tweaks.entities.burning.zombie.mixin", + "package": "mod.acgaming.universaltweaks.tweaks.entities.burning.mobs.mixin", "refmap": "universaltweaks.refmap.json", "minVersion": "0.8", "compatibilityLevel": "JAVA_8", - "mixins": ["UTBurningBabyZombiesMixin"] + "mixins": ["UTBurningBabyZombiesMixin", "UTBurningSkeletonsMixin", "UTBurningZombiesMixin"] } \ No newline at end of file