Skip to content

Commit

Permalink
Implement TCon material blacklist tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Sep 14, 2023
1 parent 5d920c1 commit bd2030a
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}

Expand Down
16 changes: 13 additions & 3 deletions src/main/java/mod/acgaming/universaltweaks/config/UTConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Material> 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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion src/main/resources/mixins.mods.tconstruct.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}

0 comments on commit bd2030a

Please sign in to comment.