From 7964f9082218739a7d6f232dc28b7a3091f442df Mon Sep 17 00:00:00 2001 From: tier940 Date: Mon, 6 Apr 2026 22:25:02 +0900 Subject: [PATCH 1/4] =?UTF-8?q?CEu=E3=83=84=E3=83=BC=E3=83=AB=E3=83=9E?= =?UTF-8?q?=E3=83=86=E3=83=AA=E3=82=A2=E3=83=AB=E3=82=92TiC=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildscript.properties | 1 + dependencies.gradle | 8 + .../gtmt/integration/tic/TiCMaterials.java | 216 ++++++++++++++++++ .../gtmt/integration/tic/TiCModule.java | 45 ++++ .../github/gtexpert/gtmt/modules/Modules.java | 1 + 5 files changed, 271 insertions(+) create mode 100644 src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCMaterials.java create mode 100644 src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCModule.java diff --git a/buildscript.properties b/buildscript.properties index a9b124b..935f7b2 100644 --- a/buildscript.properties +++ b/buildscript.properties @@ -33,6 +33,7 @@ minecraftVersion = 1.12.2 debug_all = false debug_chisel = false debug_bbw = false +debug_tic = false # Select a username for testing your mod with breakpoints. You may leave this empty for a random username each time you # restart Minecraft in development. Choose this dependent on your mod: diff --git a/dependencies.gradle b/dependencies.gradle index 3b3d248..5b3069b 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -60,4 +60,12 @@ dependencies { if (project.debug_all.toBoolean() || project.debug_bbw.toBoolean()) { runtimeOnly rfg.deobf("curse.maven:better-builders-wands-238403:2691084") } + + // Debug TiC + compileOnly rfg.deobf("curse.maven:mantle-74924:2713386") + compileOnly rfg.deobf("curse.maven:tinkers-antique-1242239:7339332") + if (project.debug_all.toBoolean() || project.debug_tic.toBoolean()) { + runtimeOnly rfg.deobf("curse.maven:mantle-74924:2713386") + runtimeOnly rfg.deobf("curse.maven:tinkers-antique-1242239:7339332") + } } diff --git a/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCMaterials.java b/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCMaterials.java new file mode 100644 index 0000000..0db5ef5 --- /dev/null +++ b/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCMaterials.java @@ -0,0 +1,216 @@ +package com.github.gtexpert.gtmt.integration.tic; + +import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.util.text.translation.LanguageMap; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.registries.IForgeRegistry; + +import com.google.common.collect.ImmutableSet; + +import gregtech.api.GregTechAPI; +import gregtech.api.unification.material.Material; +import gregtech.api.unification.material.properties.PropertyKey; +import gregtech.api.unification.material.properties.ToolProperty; + +import com.github.gtexpert.gtmt.api.ModValues; + +import slimeknights.tconstruct.library.MaterialIntegration; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.materials.BowMaterialStats; +import slimeknights.tconstruct.library.materials.ExtraMaterialStats; +import slimeknights.tconstruct.library.materials.HandleMaterialStats; +import slimeknights.tconstruct.library.materials.HeadMaterialStats; + +public final class TiCMaterials { + + /** Materials already registered by TiC natively - skip to avoid duplicates */ + private static final Set TIC_NATIVE_MATERIALS = ImmutableSet.of( + // Metals + "iron", "cobalt", "ardite", "manyullyn", "copper", "bronze", + "lead", "silver", "electrum", "steel", "pigiron", "knightslime", + "alubrass", "alumite", + // Natural / Vanilla + "wood", "stone", "flint", "cactus", "bone", "obsidian", + "prismarine", "endstone", "paper", "sponge", "firewood", + "netherrack", + // Gems (vanilla) + "diamond", "emerald"); + + private static final List integrations = new ArrayList<>(); + + private TiCMaterials() {} + + /** + * Called during registerBlocks when GT materials are available. + * Also registers fluid blocks into the block registry. + */ + public static void register(IForgeRegistry blockRegistry) { + for (Material gtMaterial : GregTechAPI.materialManager.getRegisteredMaterials()) { + if (!gtMaterial.hasProperty(PropertyKey.TOOL)) continue; + if (!gtMaterial.hasProperty(PropertyKey.INGOT) && !gtMaterial.hasProperty(PropertyKey.GEM)) continue; + if (TIC_NATIVE_MATERIALS.contains(gtMaterial.getName())) continue; + + registerMaterial(gtMaterial, blockRegistry); + } + } + + /** + * Called during ModelRegistryEvent to register fluid block models. + */ + public static void registerFluidModels() { + for (MaterialIntegration integration : integrations) { + integration.registerFluidModel(); + } + } + + private static void registerMaterial(Material gtMaterial, IForgeRegistry blockRegistry) { + String identifier = ModValues.MODID + "." + gtMaterial.getName(); + int color = gtMaterial.getMaterialRGB(); + ToolProperty toolProp = gtMaterial.getProperty(PropertyKey.TOOL); + + // Create TiC material (hidden until integration activates it) + slimeknights.tconstruct.library.materials.Material ticMaterial = new slimeknights.tconstruct.library.materials.Material( + identifier, color, true); + + // Inject localized name from CEu into TiC's translation system + injectTranslation(identifier, gtMaterial); + + // Register material stats from GT tool properties + int durability = toolProp.getToolDurability(); + float speed = toolProp.getToolSpeed(); + float attack = toolProp.getToolAttackDamage(); + int harvestLevel = mapHarvestLevel(toolProp.getToolHarvestLevel()); + + TinkerRegistry.addMaterialStats(ticMaterial, + new HeadMaterialStats(durability, speed, attack, harvestLevel), + new HandleMaterialStats(calcHandleModifier(toolProp), calcHandleDurability(toolProp)), + new ExtraMaterialStats(calcExtraDurability(durability)), + calcBowStats(toolProp)); + + // Setup item associations + String oreSuffix = toPascalCase(gtMaterial.getName()); + Fluid fluid = getFluid(gtMaterial); + + if (gtMaterial.hasProperty(PropertyKey.INGOT) && oreSuffix != null) { + ticMaterial.addCommonItems(oreSuffix); + } else if (gtMaterial.hasProperty(PropertyKey.GEM) && oreSuffix != null) { + ticMaterial.addItem("gem" + oreSuffix, 1, + slimeknights.tconstruct.library.materials.Material.VALUE_Ingot); + ticMaterial.addItem("block" + oreSuffix, 1, + slimeknights.tconstruct.library.materials.Material.VALUE_Block); + } + + // Register integration + MaterialIntegration integration; + if (fluid != null && oreSuffix != null) { + integration = new MaterialIntegration(ticMaterial, fluid, oreSuffix); + } else if (gtMaterial.hasProperty(PropertyKey.INGOT) && oreSuffix != null) { + integration = new MaterialIntegration("ingot" + oreSuffix, ticMaterial, null, null); + integration.setRepresentativeItem("ingot" + oreSuffix); + } else if (gtMaterial.hasProperty(PropertyKey.GEM) && oreSuffix != null) { + integration = new MaterialIntegration("gem" + oreSuffix, ticMaterial, null, null); + integration.setRepresentativeItem("gem" + oreSuffix); + } else { + integration = new MaterialIntegration(ticMaterial); + } + + // Drive lifecycle: TiC's preInit loop already ran + integration.preInit(); + integration.registerFluidBlock(blockRegistry); + TinkerRegistry.integrate(integration); + integrations.add(integration); + } + + /** + * Inject CEu's localized material name into TiC's translation system. + * TiC looks up "material.<identifier>.name" via the deprecated I18n / LanguageMap. + */ + private static void injectTranslation(String ticIdentifier, Material gtMaterial) { + String key = "material." + ticIdentifier + ".name"; + String localizedName = gtMaterial.getLocalizedName(); + String entry = key + "=" + localizedName + "\n"; + LanguageMap.inject(new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8))); + } + + /** + * Map GT harvest level to TiC harvest level. + * GT: 0=Wood, 1=Stone, 2=Iron, 3=Diamond, 4+=higher + * TiC: 0=Stone, 1=Iron, 2=Diamond, 3=Obsidian, 4=Cobalt + */ + private static int mapHarvestLevel(int gtLevel) { + return switch (gtLevel) { + case 0, 1 -> 0; + case 2 -> 1; + case 3 -> 2; + case 4 -> 3; + default -> 4; + }; + } + + private static float calcHandleModifier(ToolProperty toolProp) { + float modifier = 0.5f + (toolProp.getToolDurability() / 2000.0f); + return Math.max(0.1f, Math.min(modifier, 2.0f)); + } + + private static int calcHandleDurability(ToolProperty toolProp) { + return (int) (toolProp.getToolDurability() * 0.1f); + } + + private static int calcExtraDurability(int durability) { + return (int) (durability * 0.15f); + } + + /** + * Calculate bow stats from GT tool properties. + * Reference values (TiC native): + * iron: drawspeed=0.5, range=1.5, bonus=7 + * steel: drawspeed=0.4, range=2.0, bonus=9 + * copper: drawspeed=0.6, range=1.45, bonus=5 + */ + private static BowMaterialStats calcBowStats(ToolProperty toolProp) { + float speed = toolProp.getToolSpeed(); + float attack = toolProp.getToolAttackDamage(); + + // drawspeed: lighter/faster materials draw faster; clamp 0.2~1.5 + float drawspeed = Math.max(0.2f, Math.min(1.5f, 1.0f / (1.0f + speed * 0.1f))); + // range: scales with speed; clamp 0.4~3.0 + float range = Math.max(0.4f, Math.min(3.0f, 0.5f + speed * 0.15f)); + // bonusDamage: scales with attack; clamp 0~15 + float bonusDamage = Math.max(0f, Math.min(15f, attack * 1.2f)); + + return new BowMaterialStats(drawspeed, range, bonusDamage); + } + + private static Fluid getFluid(Material material) { + if (!material.hasProperty(PropertyKey.FLUID)) return null; + + Fluid fluid = material.getFluid(); + if (fluid != null && FluidRegistry.isFluidRegistered(fluid)) { + return fluid; + } + return null; + } + + private static String toPascalCase(String name) { + if (name == null || name.isEmpty()) return null; + + StringBuilder sb = new StringBuilder(); + boolean capitalizeNext = true; + for (char c : name.toCharArray()) { + if (c == '_') { + capitalizeNext = true; + } else { + sb.append(capitalizeNext ? Character.toUpperCase(c) : c); + capitalizeNext = false; + } + } + return sb.toString(); + } +} diff --git a/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCModule.java b/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCModule.java new file mode 100644 index 0000000..6ed0d58 --- /dev/null +++ b/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCModule.java @@ -0,0 +1,45 @@ +package com.github.gtexpert.gtmt.integration.tic; + +import java.util.Collections; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import org.jetbrains.annotations.NotNull; + +import com.github.gtexpert.gtmt.api.ModValues; +import com.github.gtexpert.gtmt.api.modules.TModule; +import com.github.gtexpert.gtmt.api.util.Mods; +import com.github.gtexpert.gtmt.integration.IntegrationSubmodule; +import com.github.gtexpert.gtmt.modules.Modules; + +@TModule( + moduleID = Modules.MODULE_TIC, + containerID = ModValues.MODID, + modDependencies = Mods.Names.TINKERS_CONSTRUCT, + name = "GTMoreTools Tinkers' Construct Integration", + description = "Tinkers' Construct Integration Module") +public class TiCModule extends IntegrationSubmodule { + + @NotNull + @Override + public List> getEventBusSubscribers() { + return Collections.singletonList(TiCModule.class); + } + + @Override + public void registerBlocks(RegistryEvent.Register event) { + TiCMaterials.register(event.getRegistry()); + } + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public static void onRegisterModels(ModelRegistryEvent event) { + TiCMaterials.registerFluidModels(); + } +} diff --git a/src/main/java/com/github/gtexpert/gtmt/modules/Modules.java b/src/main/java/com/github/gtexpert/gtmt/modules/Modules.java index 9a02524..94f7960 100644 --- a/src/main/java/com/github/gtexpert/gtmt/modules/Modules.java +++ b/src/main/java/com/github/gtexpert/gtmt/modules/Modules.java @@ -22,6 +22,7 @@ public class Modules implements IModuleContainer { public static final String MODULE_AEA = "aeadditions_integration"; public static final String MODULE_NAE2 = "nae2_integration"; public static final String MODULE_BBW = "bbw_integration"; + public static final String MODULE_TIC = "tic_integration"; public static final String MODULE_BINNIES = "binnies_integration"; public static final String MODULE_BOTANY = "botany_integration"; public static final String MODULE_EXBEES = "extrabees_integration"; From ae3ec5225a7b202c06235c4847eb4b1aca5cc12f Mon Sep 17 00:00:00 2001 From: tier940 Date: Mon, 6 Apr 2026 22:35:26 +0900 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c75ce8b..772b5bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# v1.2.0 +## New: Tinkers' Construct Integration +- CEu tool materials are now registered as TiC materials with Head, Handle, Extra, and Bow stats. +- Material names are inherited from CEu's localization. +- Molten fluid and smeltery casting/melting support for CEu materials. +- Known issue: Tool Forge leg coloring for GT blocks is not yet supported (TODO). + +* * * + # v1.1.2 - Fix BBW block preview showing on all GT tools. From 72358666b71a4c963e2d04035760708bcd7cfc97 Mon Sep 17 00:00:00 2001 From: tier940 Date: Mon, 6 Apr 2026 22:42:31 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 - .../github/gtexpert/gtmt/integration/tic/TiCMaterials.java | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 772b5bb..7e7902b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,6 @@ - CEu tool materials are now registered as TiC materials with Head, Handle, Extra, and Bow stats. - Material names are inherited from CEu's localization. - Molten fluid and smeltery casting/melting support for CEu materials. -- Known issue: Tool Forge leg coloring for GT blocks is not yet supported (TODO). * * * diff --git a/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCMaterials.java b/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCMaterials.java index 0db5ef5..c93e0f5 100644 --- a/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCMaterials.java +++ b/src/main/java/com/github/gtexpert/gtmt/integration/tic/TiCMaterials.java @@ -121,10 +121,11 @@ private static void registerMaterial(Material gtMaterial, IForgeRegistry integration = new MaterialIntegration(ticMaterial); } - // Drive lifecycle: TiC's preInit loop already ran + // TiC's preInit loop already ran by this point, so we drive the lifecycle manually. + // preInit() has an internal guard against double execution. + TinkerRegistry.integrate(integration); integration.preInit(); integration.registerFluidBlock(blockRegistry); - TinkerRegistry.integrate(integration); integrations.add(integration); } From 34aff0fce62cb03ba0b5a62c00c8be9cb7d8d6a1 Mon Sep 17 00:00:00 2001 From: tier940 Date: Mon, 6 Apr 2026 22:47:59 +0900 Subject: [PATCH 4/4] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 09c1793..5e39765 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,12 @@ This mod is an add-on for GregTech CEu that provides integration with various mo ### Better Builder's Wands Integration - Adds GT material-based Wand tools +### Tinkers' Construct Integration +- CEu tool materials are automatically registered as Tinkers' Construct materials +- Supports Head, Handle, Extra, and Bow stats derived from GT material properties +- Material names are inherited from CEu's localization +- Molten fluid and smeltery casting/melting support for CEu materials with fluid properties + ## Credits