From bd2030a6f916b1a8bc07dd5e7e7dcedc9ecabe9a Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Thu, 14 Sep 2023 21:05:12 +0200 Subject: [PATCH] Implement TCon material blacklist tweak --- README.md | 1 + .../universaltweaks/UniversalTweaks.java | 2 ++ .../universaltweaks/config/UTConfig.java | 16 +++++++++--- .../tconstruct/UTTConstructMaterials.java | 25 +++++++++++++++++++ .../tconstruct/mixin/MaterialAccessor.java | 12 +++++++++ .../resources/mixins.mods.tconstruct.json | 2 +- 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/UTTConstructMaterials.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/MaterialAccessor.java diff --git a/README.md b/README.md index 01b91f5a..b9bad871 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,7 @@ All changes are toggleable via the config file. * **Tinkers' Construct** * **Duplication Fixes:** Fixes various duplication exploits * **Gaseous Fluids:** Excludes gaseous fluids from being transferable via faucets + * **Material Blacklist:** Hides tool/bow materials in the 'Materials and You' book * **Offhand Shuriken:** Suppresses special abilities of long swords and rapiers when shurikens are wielded in the offhand * **Ore Dictionary Cache:** Caches all ore dictionary smelting recipes to speed up game loading * **Projectile Despawning:** Despawns unbreakable projectiles faster to improve framerates diff --git a/src/main/java/mod/acgaming/universaltweaks/UniversalTweaks.java b/src/main/java/mod/acgaming/universaltweaks/UniversalTweaks.java index 75121c01..55bb7b01 100644 --- a/src/main/java/mod/acgaming/universaltweaks/UniversalTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/UniversalTweaks.java @@ -26,6 +26,7 @@ import mod.acgaming.universaltweaks.mods.simplyjetpacks.UTSimplyJetpacksEvents; import mod.acgaming.universaltweaks.mods.simplyjetpacks.network.message.MessageClientStatesReset; import mod.acgaming.universaltweaks.mods.tconstruct.UTTConstructEvents; +import mod.acgaming.universaltweaks.mods.tconstruct.UTTConstructMaterials; import mod.acgaming.universaltweaks.mods.tconstruct.oredictcache.UTOreDictCache; import mod.acgaming.universaltweaks.mods.thaumcraft.UTThaumcraftEvents; import mod.acgaming.universaltweaks.tweaks.blocks.betterplacement.UTBetterPlacement; @@ -161,6 +162,7 @@ public void postInit(FMLPostInitializationEvent event) if (UTConfig.TWEAKS_ITEMS.utCustomRarities.length > 0) UTCustomRarity.initItemRarityMap(); if (UTConfig.TWEAKS_ITEMS.utCustomUseDurations.length > 0) UTCustomUseDuration.initItemUseMaps(); if (UTConfig.TWEAKS_ITEMS.PARRY.utParryToggle) UTParry.initProjectileList(); + if (Loader.isModLoaded("tconstruct") && UTConfig.MOD_INTEGRATION.TINKERS_CONSTRUCT.utTConMaterialBlacklist.length > 0) UTTConstructMaterials.utHandleBlacklistedMaterials(); LOGGER.info(NAME + " post-initialized"); } diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfig.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfig.java index 2b579dac..810ca018 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfig.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfig.java @@ -2645,9 +2645,14 @@ public static class TinkersConstructCategory public boolean utTConGaseousFluidsToggle = false; @Config.RequiresMcRestart - @Config.Name("Projectile Despawning") - @Config.Comment("Despawns unbreakable projectiles faster to improve framerates") - public boolean utTConProjectileToggle = true; + @Config.Name("Material Blacklist") + @Config.Comment + ({ + "Hides tool/bow materials in the 'Materials and You' book", + "Syntax: material", + "Enabling debug logging prints all materials on opening the book" + }) + public String[] utTConMaterialBlacklist = new String[] {}; @Config.RequiresMcRestart @Config.Name("Offhand Shuriken") @@ -2659,6 +2664,11 @@ public static class TinkersConstructCategory @Config.Comment("Caches all ore dictionary smelting recipes to speed up game loading") public boolean utTConOreDictCacheToggle = true; + @Config.RequiresMcRestart + @Config.Name("Projectile Despawning") + @Config.Comment("Despawns unbreakable projectiles faster to improve framerates") + public boolean utTConProjectileToggle = true; + @Config.RequiresMcRestart @Config.Name("Duplication Fixes") @Config.Comment("Fixes various duplication exploits") diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/UTTConstructMaterials.java b/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/UTTConstructMaterials.java new file mode 100644 index 00000000..8301c683 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/UTTConstructMaterials.java @@ -0,0 +1,25 @@ +package mod.acgaming.universaltweaks.mods.tconstruct; + +import java.util.Arrays; +import java.util.Collection; + +import mod.acgaming.universaltweaks.UniversalTweaks; +import mod.acgaming.universaltweaks.config.UTConfig; +import mod.acgaming.universaltweaks.mods.tconstruct.mixin.MaterialAccessor; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.materials.Material; + +public class UTTConstructMaterials +{ + public static void utHandleBlacklistedMaterials() + { + Collection materialList = TinkerRegistry.getAllMaterials(); + if (UTConfig.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.info("+++ TINKERS' CONSTRUCT MATERIALS +++"); + for (Material material : materialList) + { + if (UTConfig.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.info(material.getIdentifier()); + boolean blacklisted = Arrays.stream(UTConfig.MOD_INTEGRATION.TINKERS_CONSTRUCT.utTConMaterialBlacklist).anyMatch(mat -> mat.equals(material.getIdentifier())); + ((MaterialAccessor) material).setHidden(blacklisted); + } + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/MaterialAccessor.java b/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/MaterialAccessor.java new file mode 100644 index 00000000..996387c6 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/tconstruct/mixin/MaterialAccessor.java @@ -0,0 +1,12 @@ +package mod.acgaming.universaltweaks.mods.tconstruct.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; +import slimeknights.tconstruct.library.materials.Material; + +@Mixin(Material.class) +public interface MaterialAccessor +{ + @Accessor("hidden") + void setHidden(boolean hidden); +} \ No newline at end of file diff --git a/src/main/resources/mixins.mods.tconstruct.json b/src/main/resources/mixins.mods.tconstruct.json index 0b04e7d0..f2c906c9 100644 --- a/src/main/resources/mixins.mods.tconstruct.json +++ b/src/main/resources/mixins.mods.tconstruct.json @@ -3,5 +3,5 @@ "refmap": "universaltweaks.refmap.json", "minVersion": "0.8", "compatibilityLevel": "JAVA_8", - "mixins": ["UTEntityProjectileBaseMixin", "UTFaucetMixin", "UTLongSwordMixin", "UTRapierMixin"] + "mixins": ["MaterialAccessor", "UTEntityProjectileBaseMixin", "UTFaucetMixin", "UTLongSwordMixin", "UTRapierMixin"] } \ No newline at end of file