diff options
Diffstat (limited to 'src/main/java/net/glease/ggfab')
8 files changed, 526 insertions, 2 deletions
diff --git a/src/main/java/net/glease/ggfab/GGConstants.java b/src/main/java/net/glease/ggfab/GGConstants.java index 6e8b4a048f..2e68abd000 100644 --- a/src/main/java/net/glease/ggfab/GGConstants.java +++ b/src/main/java/net/glease/ggfab/GGConstants.java @@ -5,6 +5,7 @@ import net.minecraft.util.EnumChatFormatting; public class GGConstants { public static final String MODID = "ggfab"; + public static final String RES_PATH_ITEM = MODID + ":"; public static final String MODNAME = "GigaGramFab"; public static final String VERSION = "GRADLETOKEN_VERSION"; diff --git a/src/main/java/net/glease/ggfab/GGItemList.java b/src/main/java/net/glease/ggfab/GGItemList.java index 6363f90983..d77d3854e1 100644 --- a/src/main/java/net/glease/ggfab/GGItemList.java +++ b/src/main/java/net/glease/ggfab/GGItemList.java @@ -14,7 +14,30 @@ import gregtech.api.util.GT_Utility; public enum GGItemList implements IItemContainer { LinkedInputBus, - AdvAssLine,; + AdvAssLine, + // region single use tool + ToolCast_MV, + ToolCast_HV, + ToolCast_EV, + // order matters, do not insert randomly like a n00b + One_Use_craftingToolFile, + One_Use_craftingToolWrench, + One_Use_craftingToolCrowbar, + One_Use_craftingToolWireCutter, + One_Use_craftingToolHardHammer, + One_Use_craftingToolSoftHammer, + One_Use_craftingToolScrewdriver, + Shape_One_Use_craftingToolFile, + Shape_One_Use_craftingToolWrench, + Shape_One_Use_craftingToolCrowbar, + Shape_One_Use_craftingToolWireCutter, + Shape_One_Use_craftingToolHardHammer, + Shape_One_Use_craftingToolSoftHammer, + Shape_One_Use_craftingToolScrewdriver, + // ordered section ends + // endregion + // + ; private ItemStack mStack; private boolean mHasNotBeenSet = true; diff --git a/src/main/java/net/glease/ggfab/GigaGramFab.java b/src/main/java/net/glease/ggfab/GigaGramFab.java index af911b9bbd..b30204ac39 100644 --- a/src/main/java/net/glease/ggfab/GigaGramFab.java +++ b/src/main/java/net/glease/ggfab/GigaGramFab.java @@ -1,13 +1,33 @@ package net.glease.ggfab; +import static gregtech.api.enums.ToolDictNames.*; +import static gregtech.common.items.GT_MetaGenerated_Tool_01.*; +import static net.glease.ggfab.api.GGFabRecipeMaps.toolCastRecipes; + +import java.util.stream.IntStream; + +import net.glease.ggfab.api.GigaGramFabAPI; +import net.glease.ggfab.items.GGMetaItem_DumbItems; import net.glease.ggfab.mte.MTE_AdvAssLine; import net.glease.ggfab.mte.MTE_LinkedInputBus; +import net.glease.ggfab.util.GGUtils; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.TierEU; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe; +import gregtech.api.util.GT_ProcessingArray_Manager; +import gregtech.api.util.GT_RecipeConstants; @Mod( modid = GGConstants.MODID, @@ -31,15 +51,133 @@ public class GigaGramFab { GGItemList.LinkedInputBus.set( new MTE_LinkedInputBus(13533, "ggfab.machine.linked_input_bus", "Linked Input Bus", 5) .getStackForm(1)); + GGItemList.ToolCast_MV.set( + new GT_MetaTileEntity_BasicMachine_GT_Recipe( + 13534, + "ggfab.toolcast.tier.mv", + "Basic Tool Casting Machine", + 2, + "Cheap Crafting Tool for you!", + toolCastRecipes, + 1, + 4, + 2400, + SoundResource.NONE, + GT_MetaTileEntity_BasicMachine_GT_Recipe.SpecialEffects.MAIN_RANDOM_SPARKS, + "TOOL_CAST", + new Object[] { "PGP", "WMW", "CBC", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, + 'P', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PUMP, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE, 'G', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.GLASS, 'B', + ItemList.Shape_Empty.get(1L) }).getStackForm(1L)); + GGItemList.ToolCast_HV.set( + new GT_MetaTileEntity_BasicMachine_GT_Recipe( + 13535, + "ggfab.toolcast.tier.hv", + "Advanced Tool Casting Machine", + 3, + "Cheap Crafting Tool for you!", + toolCastRecipes, + 1, + 4, + 3200, + SoundResource.NONE, + GT_MetaTileEntity_BasicMachine_GT_Recipe.SpecialEffects.MAIN_RANDOM_SPARKS, + "TOOL_CAST", + new Object[] { "PGP", "WMW", "CBC", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, + 'P', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PUMP, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE, 'G', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.GLASS, 'B', + ItemList.Shape_Empty.get(1L) }).getStackForm(1L)); + GGItemList.ToolCast_EV.set( + new GT_MetaTileEntity_BasicMachine_GT_Recipe( + 13536, + "ggfab.toolcast.tier.ev", + "Master Tool Casting Machine", + 4, + "Cheap Crafting Tool for you!", + toolCastRecipes, + 1, + 4, + 2400, + SoundResource.NONE, + GT_MetaTileEntity_BasicMachine_GT_Recipe.SpecialEffects.MAIN_RANDOM_SPARKS, + "TOOL_CAST", + new Object[] { "PGP", "WMW", "CBC", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, + 'P', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.PUMP, 'C', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'W', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.WIRE, 'G', + GT_MetaTileEntity_BasicMachine_GT_Recipe.X.GLASS, 'B', + ItemList.Shape_Empty.get(1L) }).getStackForm(1L)); + long plate = OrePrefixes.plate.mMaterialAmount, ingot = OrePrefixes.ingot.mMaterialAmount, + screw = OrePrefixes.screw.mMaterialAmount, rod = OrePrefixes.stick.mMaterialAmount; + GigaGramFabAPI.addSingleUseToolType(craftingToolFile, INSTANCE.mToolStats.get(FILE), 2 * plate); + GigaGramFabAPI.addSingleUseToolType(craftingToolWrench, INSTANCE.mToolStats.get(WRENCH), 6 * ingot); + GigaGramFabAPI.addSingleUseToolType(craftingToolCrowbar, INSTANCE.mToolStats.get(CROWBAR), 3 * rod); + GigaGramFabAPI.addSingleUseToolType( + craftingToolWireCutter, + INSTANCE.mToolStats.get(WIRECUTTER), + 3 * plate + 2 * rod + screw); + GigaGramFabAPI.addSingleUseToolType(craftingToolHardHammer, INSTANCE.mToolStats.get(HARDHAMMER), 6 * ingot); + GigaGramFabAPI.addSingleUseToolType(craftingToolSoftHammer, INSTANCE.mToolStats.get(SOFTMALLET), 6 * ingot); + GigaGramFabAPI.addSingleUseToolType(craftingToolScrewdriver, INSTANCE.mToolStats.get(SCREWDRIVER), 2 * rod); + GT_ProcessingArray_Manager.addRecipeMapToPA("ggfab.toolcast", toolCastRecipes); }); GregTech_API.sBeforeGTPostload.add(new ComponentRecipeLoader()); + GregTech_API.sBeforeGTPostload.add(new SingleUseToolRecipeLoader()); ConfigurationHandler.INSTANCE.init(event.getSuggestedConfigurationFile()); + + initDumbItem1(); } @Mod.EventHandler public void init(FMLInitializationEvent event) {} @Mod.EventHandler - public void postInit(FMLPostInitializationEvent event) {} + public void postInit(FMLPostInitializationEvent event) { + GT_Values.RA.stdBuilder().itemInputs( + IntStream.range(0, 16).mapToObj(ignored -> new ItemStack(Items.diamond)).toArray(ItemStack[]::new)) + .fluidInputs(Materials.SolderingAlloy.getMolten(1)).itemOutputs(ItemList.Pump_EV.get(1L)) + .metadata(GT_RecipeConstants.RESEARCH_ITEM, ItemList.Pump_LV.get(1)) + .metadata(GT_RecipeConstants.RESEARCH_TIME, 1).eut(TierEU.RECIPE_IV).duration(160000) + .addTo(GT_RecipeConstants.AssemblyLine); + } + private void initDumbItem1() { + GGMetaItem_DumbItems i1 = new GGMetaItem_DumbItems("ggfab.d1"); + int id = 0; + { + int idShape = 30; + final int budget = idShape; + String prefix = "One_Use_craftingTool"; + String prefix2 = "Shape_One_Use_craftingTool"; + for (GGItemList i : GGItemList.values()) { + ItemStack stack = null; + if (i.name().startsWith(prefix)) { + stack = i1.addItem( + id++, + "Single Use " + + GGUtils.processSentence(i.name().substring(prefix.length()), ' ', true, true), + null, + i, + i.name().substring("One_Use_".length())); + } else if (i.name().startsWith(prefix2)) { + stack = i1.addItem( + idShape++, + "Tool Casting Mold (" + + GGUtils.processSentence(i.name().substring(prefix2.length()), ' ', true, true) + + ")", + null, + i); + } + if (stack != null) { + i.set(stack); + } + } + if (id >= budget || idShape >= 2 * budget || idShape - id != budget) throw new AssertionError(); + id = budget * 2; + } + } } diff --git a/src/main/java/net/glease/ggfab/SingleUseToolRecipeLoader.java b/src/main/java/net/glease/ggfab/SingleUseToolRecipeLoader.java new file mode 100644 index 0000000000..8fc78b7486 --- /dev/null +++ b/src/main/java/net/glease/ggfab/SingleUseToolRecipeLoader.java @@ -0,0 +1,99 @@ +package net.glease.ggfab; + +import static gregtech.api.enums.ToolDictNames.*; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; + +import net.glease.ggfab.api.GGFabRecipeMaps; +import net.glease.ggfab.api.GigaGramFabAPI; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.enums.ToolDictNames; +import gregtech.api.interfaces.IToolStats; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; + +class SingleUseToolRecipeLoader implements Runnable { + + @Override + public void run() { + ToolDictNames[] hardTools = new ToolDictNames[] { craftingToolHardHammer, craftingToolScrewdriver, + craftingToolWrench, craftingToolCrowbar, craftingToolWireCutter, craftingToolFile }; + ToolDictNames[] softTools = new ToolDictNames[] { craftingToolSoftHammer }; + addSingleUseToolRecipe(Materials.Steel, hardTools); + addSingleUseToolRecipe(Materials.Silver, 5000, hardTools); + addSingleUseToolRecipe(Materials.VanadiumSteel, hardTools); + addSingleUseToolRecipe(Materials.TungstenSteel, hardTools); + addSingleUseToolRecipe(Materials.HSSG, hardTools); + addSingleUseToolRecipe(Materials.Rubber, softTools); + addSingleUseToolRecipe(Materials.StyreneButadieneRubber, softTools); + addSingleUseToolRecipe(Materials.Polybenzimidazole, softTools); + + String prefix = "Shape_One_Use_"; + for (GGItemList value : GGItemList.values()) { + if (!value.name().startsWith(prefix)) { + continue; + } + ToolDictNames type = ToolDictNames.valueOf(value.name().substring(prefix.length())); + GT_ModHandler.addCraftingRecipe( + value.get(1L), + new Object[] { "h", "P", "I", 'P', ItemList.Shape_Empty, 'I', type }); + } + } + + private void addSingleUseToolRecipe(Materials material, ToolDictNames... types) { + addSingleUseToolRecipe(material, 10000, types); + } + + private static long findNiceFactor(long fluids, long count) { + long end = Math.min(fluids, count); + for (long i = count / 256; i < end; i++) { + if (fluids % i == 0 && count % i == 0 && count / i < 256) return i; + } + return -1; + } + + private void addSingleUseToolRecipe(Materials material, int outputModifier, ToolDictNames... types) { + if (material.mStandardMoltenFluid == null) { + throw new IllegalArgumentException("material does not have molten fluid form"); + } + for (ToolDictNames type : types) { + IToolStats stats = GigaGramFabAPI.SINGLE_USE_TOOLS.get(type); + Long cost = GigaGramFabAPI.COST_SINGLE_USE_TOOLS.get(type); + if (stats == null || cost == null) { + throw new IllegalArgumentException(type + " not registered"); + } + long fluids = cost * GT_Values.L / GT_Values.M, duration = 6 * SECONDS; + long count = (long) (material.mDurability * stats.getMaxDurabilityMultiplier() + * outputModifier + * 100 + / stats.getToolDamagePerContainerCraft() + / 10000); + if (count > 64 * 4) { + long niceFactor = findNiceFactor(fluids, count); + if (niceFactor < 0) { + double mod = (double) count / (64 * 4L); + fluids = Math.max((long) (fluids / mod), 1L); + duration = Math.max((long) (duration / mod), 1L); + count = 64 * 4; + } else { + fluids /= niceFactor; + duration = Math.max(duration / niceFactor, 1); + count /= niceFactor; + } + } else if (count < 128) { + long mod = GT_Utility.ceilDiv(128, count); + fluids *= mod; + duration *= mod; + count *= mod; + } + GT_Values.RA.stdBuilder().fluidInputs(material.getMolten(fluids)) // + .metadata(GGFabRecipeMaps.OUTPUT_TYPE, type) // + .metadata(GGFabRecipeMaps.OUTPUT_COUNT, (int) count) // + .eut(TierEU.RECIPE_MV).duration(duration) // + .addTo(GGFabRecipeMaps.toolCastRecipes); + } + } +} diff --git a/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java b/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java new file mode 100644 index 0000000000..088e9a7782 --- /dev/null +++ b/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java @@ -0,0 +1,55 @@ +package net.glease.ggfab.api; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import net.glease.ggfab.GGItemList; +import net.minecraft.item.ItemStack; + +import com.gtnewhorizons.modularui.common.widget.ProgressBar; + +import gregtech.api.enums.ToolDictNames; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.recipe.RecipeMetadataKey; +import gregtech.api.recipe.metadata.SimpleRecipeMetadataKey; +import gregtech.api.util.GT_Recipe; + +public class GGFabRecipeMaps { + + public static final RecipeMetadataKey<ToolDictNames> OUTPUT_TYPE = SimpleRecipeMetadataKey + .create(ToolDictNames.class, "output_type"); + public static final RecipeMetadataKey<Integer> OUTPUT_COUNT = SimpleRecipeMetadataKey + .create(Integer.class, "output_count"); + public static final RecipeMap<RecipeMapBackend> toolCastRecipes = RecipeMapBuilder.of("ggfab.recipe.toolcast") + .maxIO(1, 4, 1, 0).minInputs(1, 1).progressBar(GT_UITextures.PROGRESSBAR_ARROW, ProgressBar.Direction.RIGHT) + .recipeEmitter(b -> { + Optional<GT_Recipe> rr = b.noOptimize().validateNoInput().validateInputFluidCount(0, 1) + .validateNoOutput().validateNoOutputFluid().build(); + if (!rr.isPresent()) return Collections.emptyList(); + ToolDictNames outputType = b.getMetadata(OUTPUT_TYPE); + GT_Recipe r = rr.get(); + int outputSize = b.getMetadataOrDefault(OUTPUT_COUNT, 0); + if (outputSize > 64 * 4 || outputSize <= 0) return Collections.emptyList(); + ItemStack shape, output; + try { + shape = GGItemList.valueOf("Shape_One_Use_" + outputType).get(0L); + output = GGItemList.valueOf("One_Use_" + outputType).get(outputSize); + } catch (IllegalArgumentException ex) { + // this looks like python not java, but I don't have better way around this + return Collections.emptyList(); + } + output.stackSize = outputSize; + List<ItemStack> outputs = new ArrayList<>(); + int maxStackSize = output.getMaxStackSize(); + while (output.stackSize > maxStackSize) outputs.add(output.splitStack(maxStackSize)); + outputs.add(output); + r.mInputs = new ItemStack[] { shape }; + r.mOutputs = outputs.toArray(new ItemStack[0]); + return Collections.singletonList(r); + }).build(); +} diff --git a/src/main/java/net/glease/ggfab/api/GigaGramFabAPI.java b/src/main/java/net/glease/ggfab/api/GigaGramFabAPI.java new file mode 100644 index 0000000000..7797d037c3 --- /dev/null +++ b/src/main/java/net/glease/ggfab/api/GigaGramFabAPI.java @@ -0,0 +1,30 @@ +package net.glease.ggfab.api; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import gregtech.api.enums.ToolDictNames; +import gregtech.api.interfaces.IToolStats; + +public class GigaGramFabAPI { + + private static final Logger apiLogger = LogManager.getLogger("GigaGramFabAPI"); + + private static final Map<ToolDictNames, IToolStats> SINGLE_USE_TOOLS_STORE = new HashMap<>(); + public static final Map<ToolDictNames, IToolStats> SINGLE_USE_TOOLS = Collections + .unmodifiableMap(SINGLE_USE_TOOLS_STORE); + + private static final Map<ToolDictNames, Long> COST_SINGLE_USE_TOOLS_STORE = new HashMap<>(); + public static final Map<ToolDictNames, Long> COST_SINGLE_USE_TOOLS = Collections + .unmodifiableMap(COST_SINGLE_USE_TOOLS_STORE); + + public static void addSingleUseToolType(ToolDictNames type, IToolStats stat, long materialCost) { + if (SINGLE_USE_TOOLS_STORE.put(type, stat) != null) + apiLogger.warn("Replacing stat of single use tool {}", type); + COST_SINGLE_USE_TOOLS_STORE.put(type, materialCost); + } +} diff --git a/src/main/java/net/glease/ggfab/items/GGMetaItem_DumbItems.java b/src/main/java/net/glease/ggfab/items/GGMetaItem_DumbItems.java new file mode 100644 index 0000000000..20a81a5abb --- /dev/null +++ b/src/main/java/net/glease/ggfab/items/GGMetaItem_DumbItems.java @@ -0,0 +1,153 @@ +package net.glease.ggfab.items; + +import static gregtech.api.enums.GT_Values.D1; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.List; + +import net.glease.ggfab.GGConstants; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gnu.trove.map.TIntObjectMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import gregtech.api.GregTech_API; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.interfaces.IItemBehaviour; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +// mostly stolen from gt5 itself. +public class GGMetaItem_DumbItems extends GT_MetaBase_Item { + + public static final int MAX_ID = 32766; + private final BitSet mEnabledItems = new BitSet(); + private final BitSet mVisibleItems = new BitSet(); + private final ArrayList<IIcon> mIconList = new ArrayList<>(); + private final TIntObjectMap<IItemContainer> mIconOverride = new TIntObjectHashMap<>(); + + public GGMetaItem_DumbItems(String aUnlocalized) { + super(aUnlocalized); + } + + /** + * This adds a Custom Item to the ending Range. + * + * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) + * @param aEnglish The Default Localized Name of the created Item + * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip + * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. + * @return An ItemStack containing the newly created Item. + */ + public final ItemStack addItem(int aID, String aEnglish, String aToolTip, Object... aRandomData) { + if (aID < 0 || aID > MAX_ID) return null; + + if (aToolTip == null) aToolTip = ""; + ItemStack rStack = new ItemStack(this, 1, aID); + mEnabledItems.set(aID); + mVisibleItems.set(aID); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(rStack) + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(getUnlocalizedName(rStack) + ".tooltip", aToolTip); + List<TC_Aspects.TC_AspectStack> tAspects = new ArrayList<>(); + // Important Stuff to do first + for (Object tRandomData : aRandomData) if (tRandomData instanceof SubTag) { + if (tRandomData == SubTag.INVISIBLE) { + mVisibleItems.set(aID, false); + continue; + } + if (tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); + } + } + // now check for the rest + for (Object tRandomData : aRandomData) if (tRandomData != null) { + boolean tUseOreDict = true; + if (tRandomData instanceof IItemBehaviour) { + @SuppressWarnings("unchecked") + IItemBehaviour<GT_MetaBase_Item> behavior = (IItemBehaviour<GT_MetaBase_Item>) tRandomData; + addItemBehavior(aID, behavior); + tUseOreDict = false; + } + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + if (tRandomData instanceof SubTag) { + continue; + } + if (tRandomData instanceof IItemContainer) { + mIconOverride.put(aID, (IItemContainer) tRandomData); + } else if (tRandomData instanceof TC_Aspects.TC_AspectStack) { + ((TC_Aspects.TC_AspectStack) tRandomData).addToAspectList(tAspects); + } else if (tRandomData instanceof ItemData) { + if (GT_Utility.isStringValid(tRandomData)) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } else { + GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + } else if (tUseOreDict) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } + } + if (GregTech_API.sThaumcraftCompat != null) + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + return rStack; + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(IIconRegister aIconRegister) { + short j = (short) mEnabledItems.length(); + mIconList.clear(); + mIconList.ensureCapacity(j); + for (short i = 0; i < j; i++) { + if (mEnabledItems.get(i)) { + mIconList.add(aIconRegister.registerIcon(GGConstants.RES_PATH_ITEM + getUnlocalizedName() + "/" + i)); + } else { + mIconList.add(null); + } + } + } + + @Override + public IIcon getIconFromDamage(int aMetaData) { + if (aMetaData < 0 || aMetaData >= mIconList.size() || mIconList.get(aMetaData) == null) + return super.getIconFromDamage(aMetaData); + return mIconList.get(aMetaData); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item aItem, CreativeTabs aCreativeTab, List aList) { + int j = mEnabledItems.length(); + for (int i = 0; i < j; i++) { + if (mVisibleItems.get(i) || (D1 && mEnabledItems.get(i))) { + ItemStack tStack = new ItemStack(this, 1, i); + isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + + @Override + public Long[] getElectricStats(ItemStack aStack) { + return null; + } + + @Override + public Long[] getFluidContainerStats(ItemStack aStack) { + return null; + } +} diff --git a/src/main/java/net/glease/ggfab/util/GGUtils.java b/src/main/java/net/glease/ggfab/util/GGUtils.java index 66ff5d9361..59dbf482ec 100644 --- a/src/main/java/net/glease/ggfab/util/GGUtils.java +++ b/src/main/java/net/glease/ggfab/util/GGUtils.java @@ -47,4 +47,29 @@ public class GGUtils { sj.add(String.valueOf(tile.getZCoord())); return sj.toString(); } + + /** + * convert lowerCamelCase to any of snake case or normal sentence + */ + public static String processSentence(String src, Character separator, boolean capitalize, boolean firstCapitalize) { + if (src == null) throw new IllegalArgumentException(); + if (src.isEmpty()) return ""; + StringBuilder out = new StringBuilder(src.length()); + if (firstCapitalize) out.append(Character.toUpperCase(src.charAt(0))); + else out.append(src.charAt(0)); + for (int i = 1; i < src.length(); i++) { + char ch = src.charAt(i); + if (Character.isUpperCase(ch)) { + if (separator != null) out.append(separator.charValue()); + if (capitalize) { + out.append(ch); + } else { + out.append(Character.toLowerCase(ch)); + } + } else { + out.append(ch); + } + } + return out.toString(); + } } |