diff options
Diffstat (limited to 'src/main')
12 files changed, 457 insertions, 367 deletions
diff --git a/src/main/java/net/glease/ggfab/ComponentRecipeLoader.java b/src/main/java/net/glease/ggfab/ComponentRecipeLoader.java index 088ad86025..916fa92a50 100644 --- a/src/main/java/net/glease/ggfab/ComponentRecipeLoader.java +++ b/src/main/java/net/glease/ggfab/ComponentRecipeLoader.java @@ -19,28 +19,27 @@ class ComponentRecipeLoader implements Runnable { @Override public void run() { Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null - ? FluidRegistry.getFluid("molten.indalloy140") - : FluidRegistry.getFluid("molten.solderingalloy"); + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); RA.addAssemblylineRecipe( - ItemList.Machine_Multi_Assemblyline.get(1L), - 96000, - new Object[] { ItemList.Machine_Multi_Assemblyline.get(1L), - new Object[] { OrePrefixes.circuit.get(Materials.Master), 2 }, - new Object[] { OrePrefixes.circuit.get(Materials.Elite), 4 }, - new Object[] { OrePrefixes.circuit.get(Materials.Data), 8 }, - ItemList.Automation_ChestBuffer_LuV.get(1L), }, - new FluidStack[] { new FluidStack(solderIndalloy, 1296), Materials.Lubricant.getFluid(2000) }, - GGItemList.AdvAssLine.get(1L), - 1200, - 6000); + ItemList.Machine_Multi_Assemblyline.get(1L), + 96000, + new Object[] { ItemList.Machine_Multi_Assemblyline.get(1L), + new Object[] { OrePrefixes.circuit.get(Materials.Master), 2 }, + new Object[] { OrePrefixes.circuit.get(Materials.Elite), 4 }, + new Object[] { OrePrefixes.circuit.get(Materials.Data), 8 }, + ItemList.Automation_ChestBuffer_LuV.get(1L), }, + new FluidStack[] { new FluidStack(solderIndalloy, 1296), Materials.Lubricant.getFluid(2000) }, + GGItemList.AdvAssLine.get(1L), + 1200, + 6000); RA.addAssemblerRecipe( - new ItemStack[] { ItemList.Hatch_Input_Bus_IV.get(1L), ItemList.Emitter_IV.get(1L), - ItemList.Sensor_IV.get(1L), - GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Enderium, 1L), - GT_Utility.getIntegratedCircuit(12), }, - Materials.Polybenzimidazole.getMolten(144L), - GGItemList.LinkedInputBus.get(1L), - 600, - (int) GT_Values.VP[5]); + new ItemStack[] { ItemList.Hatch_Input_Bus_IV.get(1L), ItemList.Emitter_IV.get(1L), + ItemList.Sensor_IV.get(1L), GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Enderium, 1L), + GT_Utility.getIntegratedCircuit(12), }, + Materials.Polybenzimidazole.getMolten(144L), + GGItemList.LinkedInputBus.get(1L), + 600, + (int) GT_Values.VP[5]); } } diff --git a/src/main/java/net/glease/ggfab/ConfigurationHandler.java b/src/main/java/net/glease/ggfab/ConfigurationHandler.java index 249bb16da8..5364b00941 100644 --- a/src/main/java/net/glease/ggfab/ConfigurationHandler.java +++ b/src/main/java/net/glease/ggfab/ConfigurationHandler.java @@ -25,19 +25,20 @@ public enum ConfigurationHandler { ConfigCategory category = config.getCategory(categoryName); category.setLanguageKey("ggfab.config." + categoryName); for (Map.Entry<String, Property> entry : category.entrySet()) { - entry.getValue().setLanguageKey(String.format("%s.%s", category.getLanguagekey(), entry.getKey())); + entry.getValue() + .setLanguageKey(String.format("%s.%s", category.getLanguagekey(), entry.getKey())); } } } private void loadConfig() { laserOCPenaltyFactor = config.getFloat( - "advasslinePenaltyFactor", - "common.balancing", - 0.3f, - 0f, - 10f, - "Laser overclock penalty factor. This will incredibly change the game balance. Even a small step from 0.2 to 0.3 can have very significant impact. Tweak with caution!"); + "advasslinePenaltyFactor", + "common.balancing", + 0.3f, + 0f, + 10f, + "Laser overclock penalty factor. This will incredibly change the game balance. Even a small step from 0.2 to 0.3 can have very significant impact. Tweak with caution!"); config.save(); } diff --git a/src/main/java/net/glease/ggfab/GGConstants.java b/src/main/java/net/glease/ggfab/GGConstants.java index 5a07a3f6c2..8547dfc857 100644 --- a/src/main/java/net/glease/ggfab/GGConstants.java +++ b/src/main/java/net/glease/ggfab/GGConstants.java @@ -1,8 +1,9 @@ package net.glease.ggfab; -import gregtech.GT_Version; import net.minecraft.util.EnumChatFormatting; +import gregtech.GT_Version; + public class GGConstants { public static final String MODID = "ggfab"; diff --git a/src/main/java/net/glease/ggfab/GigaGramFab.java b/src/main/java/net/glease/ggfab/GigaGramFab.java index 52fd51a13a..e03c1eacc5 100644 --- a/src/main/java/net/glease/ggfab/GigaGramFab.java +++ b/src/main/java/net/glease/ggfab/GigaGramFab.java @@ -23,11 +23,11 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.util.GT_ProcessingArray_Manager; @Mod( - modid = GGConstants.MODID, - version = GGConstants.VERSION, - name = GGConstants.MODNAME, - acceptedMinecraftVersions = "[1.7.10]", - dependencies = "required-after:IC2;required-before:gregtech") + modid = GGConstants.MODID, + version = GGConstants.VERSION, + name = GGConstants.MODNAME, + acceptedMinecraftVersions = "[1.7.10]", + dependencies = "required-after:IC2;required-before:gregtech") public class GigaGramFab { public GigaGramFab() { @@ -39,80 +39,79 @@ public class GigaGramFab { @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { GregTech_API.sAfterGTPreload.add(() -> { - GGItemList.AdvAssLine.set( - new MTE_AdvAssLine(13532, "ggfab.machine.adv_assline", "Advanced Assembly Line").getStackForm(1)); + GGItemList.AdvAssLine + .set(new MTE_AdvAssLine(13532, "ggfab.machine.adv_assline", "Advanced Assembly Line").getStackForm(1)); GGItemList.LinkedInputBus.set( - new MTE_LinkedInputBus(13533, "ggfab.machine.linked_input_bus", "Linked Input Bus", 5) - .getStackForm(1)); + 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, - 32000, - 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)); + new GT_MetaTileEntity_BasicMachine_GT_Recipe( + 13534, + "ggfab.toolcast.tier.mv", + "Basic Tool Casting Machine", + 2, + "Cheap Crafting Tool for you!", + toolCastRecipes, + 1, + 4, + 32000, + 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, - 64000, - 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)); + new GT_MetaTileEntity_BasicMachine_GT_Recipe( + 13535, + "ggfab.toolcast.tier.hv", + "Advanced Tool Casting Machine", + 3, + "Cheap Crafting Tool for you!", + toolCastRecipes, + 1, + 4, + 64000, + 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, - 128000, - 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)); + new GT_MetaTileEntity_BasicMachine_GT_Recipe( + 13536, + "ggfab.toolcast.tier.ev", + "Master Tool Casting Machine", + 4, + "Cheap Crafting Tool for you!", + toolCastRecipes, + 1, + 4, + 128000, + 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; + 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); + 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); @@ -141,23 +140,33 @@ public class GigaGramFab { 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)) { + 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) - + ")", + "Tool Casting Mold (" + GGUtils.processSentence( + i.name() + .substring(prefix2.length()), + ' ', + true, + true) + ")", null, i); - } + } if (stack != null) { i.set(stack); } diff --git a/src/main/java/net/glease/ggfab/SingleUseToolRecipeLoader.java b/src/main/java/net/glease/ggfab/SingleUseToolRecipeLoader.java index 8fc78b7486..bc01c8f633 100644 --- a/src/main/java/net/glease/ggfab/SingleUseToolRecipeLoader.java +++ b/src/main/java/net/glease/ggfab/SingleUseToolRecipeLoader.java @@ -20,7 +20,7 @@ class SingleUseToolRecipeLoader implements Runnable { @Override public void run() { ToolDictNames[] hardTools = new ToolDictNames[] { craftingToolHardHammer, craftingToolScrewdriver, - craftingToolWrench, craftingToolCrowbar, craftingToolWireCutter, craftingToolFile }; + craftingToolWrench, craftingToolCrowbar, craftingToolWireCutter, craftingToolFile }; ToolDictNames[] softTools = new ToolDictNames[] { craftingToolSoftHammer }; addSingleUseToolRecipe(Materials.Steel, hardTools); addSingleUseToolRecipe(Materials.Silver, 5000, hardTools); @@ -33,13 +33,15 @@ class SingleUseToolRecipeLoader implements Runnable { String prefix = "Shape_One_Use_"; for (GGItemList value : GGItemList.values()) { - if (!value.name().startsWith(prefix)) { + 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 }); + 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 }); } } @@ -67,10 +69,10 @@ class SingleUseToolRecipeLoader implements Runnable { } long fluids = cost * GT_Values.L / GT_Values.M, duration = 6 * SECONDS; long count = (long) (material.mDurability * stats.getMaxDurabilityMultiplier() - * outputModifier - * 100 - / stats.getToolDamagePerContainerCraft() - / 10000); + * outputModifier + * 100 + / stats.getToolDamagePerContainerCraft() + / 10000); if (count > 64 * 4) { long niceFactor = findNiceFactor(fluids, count); if (niceFactor < 0) { @@ -89,11 +91,13 @@ class SingleUseToolRecipeLoader implements Runnable { 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); + 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 index 088e9a7782..039b9d2b58 100644 --- a/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java +++ b/src/main/java/net/glease/ggfab/api/GGFabRecipeMaps.java @@ -22,34 +22,43 @@ import gregtech.api.util.GT_Recipe; public class GGFabRecipeMaps { public static final RecipeMetadataKey<ToolDictNames> OUTPUT_TYPE = SimpleRecipeMetadataKey - .create(ToolDictNames.class, "output_type"); + .create(ToolDictNames.class, "output_type"); public static final RecipeMetadataKey<Integer> OUTPUT_COUNT = SimpleRecipeMetadataKey - .create(Integer.class, "output_count"); + .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(); + .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 index 7797d037c3..6b35b26486 100644 --- a/src/main/java/net/glease/ggfab/api/GigaGramFabAPI.java +++ b/src/main/java/net/glease/ggfab/api/GigaGramFabAPI.java @@ -16,11 +16,11 @@ public class 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); + .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); + .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) diff --git a/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java b/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java index de2071329d..be0446c8ad 100644 --- a/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java +++ b/src/main/java/net/glease/ggfab/mte/MTE_AdvAssLine.java @@ -106,7 +106,7 @@ import mcp.mobius.waila.api.IWailaDataAccessor; * Dev note: 1. This multi will be an assline but with greater throughput. it will take one input every 2. */ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase<MTE_AdvAssLine> - implements ISurvivalConstructable { + implements ISurvivalConstructable { private static final ItemStack NOT_CHECKED = new ItemStack(Blocks.dirt); private static final String STRUCTURE_PIECE_FIRST = "first"; @@ -115,8 +115,8 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas public static final String TAG_KEY_CURRENT_STICK = "mCurrentStick"; public static final String TAG_KEY_PROGRESS_TIMES = "mProgressTimeArray"; private static final IStructureDefinition<MTE_AdvAssLine> STRUCTURE_DEFINITION = StructureDefinition - .<MTE_AdvAssLine>builder() - // @formatter:off + .<MTE_AdvAssLine>builder() + // @formatter:off .addShape( STRUCTURE_PIECE_FIRST, transpose(new String[][] { @@ -142,44 +142,52 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas { "o", "i", "b" }, })) // @formatter:on - .addElement('G', ofBlock(GregTech_API.sBlockCasings3, 10)) // grate machine casing - .addElement('l', ofBlock(GregTech_API.sBlockCasings2, 9)) // assembler machine casing - .addElement('m', ofBlock(GregTech_API.sBlockCasings2, 5)) // assembling line casing - .addElement( - 'g', - ofChain( - ofBlockUnlocalizedName("IC2", "blockAlloyGlass", 0, true), - ofBlockUnlocalizedName("bartworks", "BW_GlasBlocks", 0, true), - // warded glass - ofBlockUnlocalizedName("Thaumcraft", "blockCosmeticOpaque", 2, false))) - .addElement( - 'e', - ofChain( - Energy.or(ExoticEnergy) - .newAny(16, 1, ForgeDirection.UP, ForgeDirection.NORTH, ForgeDirection.SOUTH), - ofBlock(GregTech_API.sBlockCasings2, 0))) - .addElement( - 'd', - buildHatchAdder(MTE_AdvAssLine.class).atLeast(DataHatchElement.DataAccess).dot(2).casingIndex(42) - .allowOnly(ForgeDirection.NORTH).buildAndChain(GregTech_API.sBlockCasings3, 10)) - .addElement( - 'b', - buildHatchAdder(MTE_AdvAssLine.class) - .atLeast(InputHatch, InputHatch, InputHatch, InputHatch, Maintenance).casingIndex(16).dot(3) - .allowOnly(ForgeDirection.DOWN).buildAndChain( - ofBlock(GregTech_API.sBlockCasings2, 0), - ofHatchAdder(MTE_AdvAssLine::addOutputToMachineList, 16, 4))) - .addElement( - 'I', - ofChain( - // all blocks nearby use solid steel casing, so let's use the texture of that - InputBus.newAny(16, 5, ForgeDirection.DOWN), - ofHatchAdder(MTE_AdvAssLine::addOutputToMachineList, 16, 4))) - .addElement('i', InputBus.newAny(16, 5, ForgeDirection.DOWN)) - .addElement('o', OutputBus.newAny(16, 4, ForgeDirection.DOWN)).build(); + .addElement('G', ofBlock(GregTech_API.sBlockCasings3, 10)) // grate machine casing + .addElement('l', ofBlock(GregTech_API.sBlockCasings2, 9)) // assembler machine casing + .addElement('m', ofBlock(GregTech_API.sBlockCasings2, 5)) // assembling line casing + .addElement( + 'g', + ofChain( + ofBlockUnlocalizedName("IC2", "blockAlloyGlass", 0, true), + ofBlockUnlocalizedName("bartworks", "BW_GlasBlocks", 0, true), + // warded glass + ofBlockUnlocalizedName("Thaumcraft", "blockCosmeticOpaque", 2, false))) + .addElement( + 'e', + ofChain( + Energy.or(ExoticEnergy) + .newAny(16, 1, ForgeDirection.UP, ForgeDirection.NORTH, ForgeDirection.SOUTH), + ofBlock(GregTech_API.sBlockCasings2, 0))) + .addElement( + 'd', + buildHatchAdder(MTE_AdvAssLine.class).atLeast(DataHatchElement.DataAccess) + .dot(2) + .casingIndex(42) + .allowOnly(ForgeDirection.NORTH) + .buildAndChain(GregTech_API.sBlockCasings3, 10)) + .addElement( + 'b', + buildHatchAdder(MTE_AdvAssLine.class).atLeast(InputHatch, InputHatch, InputHatch, InputHatch, Maintenance) + .casingIndex(16) + .dot(3) + .allowOnly(ForgeDirection.DOWN) + .buildAndChain( + ofBlock(GregTech_API.sBlockCasings2, 0), + ofHatchAdder(MTE_AdvAssLine::addOutputToMachineList, 16, 4))) + .addElement( + 'I', + ofChain( + // all blocks nearby use solid steel casing, so let's use the texture of that + InputBus.newAny(16, 5, ForgeDirection.DOWN), + ofHatchAdder(MTE_AdvAssLine::addOutputToMachineList, 16, 4))) + .addElement('i', InputBus.newAny(16, 5, ForgeDirection.DOWN)) + .addElement('o', OutputBus.newAny(16, 4, ForgeDirection.DOWN)) + .build(); private ItemStack currentStick; private GT_Recipe.GT_Recipe_AssemblyLine currentRecipe; - private final Slice[] slices = IntStream.range(0, 16).mapToObj(Slice::new).toArray(Slice[]::new); + private final Slice[] slices = IntStream.range(0, 16) + .mapToObj(Slice::new) + .toArray(Slice[]::new); private boolean processing; private long inputVoltage; // surely no one is using more EUt than this, no? @@ -232,7 +240,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas if (!checkPiece(STRUCTURE_PIECE_LATER, leftToRight ? -i : i, 1, 0)) return false; if (!mOutputBusses.isEmpty()) return (!mEnergyHatches.isEmpty() || !mExoticEnergyHatches.isEmpty()) && mMaintenanceHatches.size() == 1 - && mDataAccessHatches.size() <= 1; + && mDataAccessHatches.size() <= 1; } return false; } @@ -273,7 +281,8 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas @SuppressWarnings("unchecked") List<EntityPlayerMP> l = server.getConfigurationManager().playerEntityList; for (EntityPlayerMP p : l) { - if (p.getUniqueID().equals(ownerUuid)) { + if (p.getUniqueID() + .equals(ownerUuid)) { for (int i = 0; i < 9; i++) { // switch is stupid, but I have no better idea Object[] args; @@ -283,8 +292,8 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas break; case 8: args = new Object[] { (int) (factor * 100) + 400, - (int) ((4 + factor) * (4 + factor + factor) * 100), 4 + factor, - 4 + factor + factor }; + (int) ((4 + factor) * (4 + factor + factor) * 100), 4 + factor, + 4 + factor + factor }; break; default: args = new Object[0]; @@ -298,21 +307,37 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, - int colorIndex, boolean aActive, boolean aRedstone) { + int colorIndex, boolean aActive, boolean aRedstone) { if (side == facing) { if (stuck) { - return new ITexture[] { casingTexturePages[0][16], - TextureFactory.builder().addIcon(OVERLAY_FRONT_ADV_ASSLINE_STUCK).extFacing().build(), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ADV_ASSLINE_STUCK_GLOW).extFacing().glow() - .build() }; + return new ITexture[] { casingTexturePages[0][16], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ADV_ASSLINE_STUCK) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ADV_ASSLINE_STUCK_GLOW) + .extFacing() + .glow() + .build() }; } - if (aActive) return new ITexture[] { casingTexturePages[0][16], - TextureFactory.builder().addIcon(OVERLAY_FRONT_ADV_ASSLINE_ACTIVE).extFacing().build(), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ADV_ASSLINE_ACTIVE_GLOW).extFacing().glow() - .build() }; - return new ITexture[] { casingTexturePages[0][16], - TextureFactory.builder().addIcon(OVERLAY_FRONT_ADV_ASSLINE).extFacing().build(), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ADV_ASSLINE_GLOW).extFacing().glow().build() }; + if (aActive) return new ITexture[] { casingTexturePages[0][16], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ADV_ASSLINE_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ADV_ASSLINE_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[0][16], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ADV_ASSLINE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ADV_ASSLINE_GLOW) + .extFacing() + .glow() + .build() }; } return new ITexture[] { casingTexturePages[0][16] }; } @@ -320,27 +345,32 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Assembling Line").addInfo("Controller block for the Advanced Assembling Line") - .addInfo("Built exactly the same as standard Assembling Line") - .addInfo("Place in world to get more info. It will be a lengthy read.") - .addInfo("Assembling Line with item pipelining").addInfo("All fluids are however consumed at start") - .addInfo("Use voltage of worst energy hatch for overclocking") - .addInfo("EU/t is (number of slices working) * (overclocked EU/t)").addSeparator() - .beginVariableStructureBlock(5, 16, 4, 4, 3, 3, false) - .addStructureInfo("From Bottom to Top, Left to Right") - .addStructureInfo( - "Layer 1 - Solid Steel Machine Casing, Input Bus (last can be Output Bus), Solid Steel Machine Casing") - .addStructureInfo( - "Layer 2 - Borosilicate Glass(any)/Warded Glass/Reinforced Glass, Assembling Line Casing, Reinforced Glass") - .addStructureInfo("Layer 3 - Grate Machine Casing, Assembler Machine Casing, Grate Machine Casing") - .addStructureInfo("Layer 4 - Empty, Solid Steel Machine Casing, Empty") - .addStructureInfo("Up to 16 repeating slices, each one allows for 1 more item in recipes") - .addController("Either Grate on layer 3 of the first slice").addEnergyHatch("Any layer 4 casing", 1) - .addMaintenanceHatch("Any layer 1 casing", 3).addInputBus("As specified on layer 1", 4, 5) - .addInputHatch("Any layer 1 casing", 3) - .addOutputBus("Replaces Input Bus on final slice or on any solid steel casing on layer 1", 4) - .addOtherStructurePart("Data Access Hatch", "Optional, next to controller", 2) - .toolTipFinisher(GGConstants.GGMARK); + tt.addMachineType("Assembling Line") + .addInfo("Controller block for the Advanced Assembling Line") + .addInfo("Built exactly the same as standard Assembling Line") + .addInfo("Place in world to get more info. It will be a lengthy read.") + .addInfo("Assembling Line with item pipelining") + .addInfo("All fluids are however consumed at start") + .addInfo("Use voltage of worst energy hatch for overclocking") + .addInfo("EU/t is (number of slices working) * (overclocked EU/t)") + .addSeparator() + .beginVariableStructureBlock(5, 16, 4, 4, 3, 3, false) + .addStructureInfo("From Bottom to Top, Left to Right") + .addStructureInfo( + "Layer 1 - Solid Steel Machine Casing, Input Bus (last can be Output Bus), Solid Steel Machine Casing") + .addStructureInfo( + "Layer 2 - Borosilicate Glass(any)/Warded Glass/Reinforced Glass, Assembling Line Casing, Reinforced Glass") + .addStructureInfo("Layer 3 - Grate Machine Casing, Assembler Machine Casing, Grate Machine Casing") + .addStructureInfo("Layer 4 - Empty, Solid Steel Machine Casing, Empty") + .addStructureInfo("Up to 16 repeating slices, each one allows for 1 more item in recipes") + .addController("Either Grate on layer 3 of the first slice") + .addEnergyHatch("Any layer 4 casing", 1) + .addMaintenanceHatch("Any layer 1 casing", 3) + .addInputBus("As specified on layer 1", 4, 5) + .addInputHatch("Any layer 1 casing", 3) + .addOutputBus("Replaces Input Bus on final slice or on any solid steel casing on layer 1", 4) + .addOtherStructurePart("Data Access Hatch", "Optional, next to controller", 2) + .toolTipFinisher(GGConstants.GGMARK); return tt; } @@ -376,8 +406,11 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas aNBT.setTag(TAG_KEY_CURRENT_STICK, currentStick.writeToNBT(new NBTTagCompound())); aNBT.setInteger("mRecipeHash", currentRecipe.getPersistentHash()); aNBT.setIntArray( - TAG_KEY_PROGRESS_TIMES, - Arrays.stream(slices).limit(currentInputLength).mapToInt(s -> s.progress).toArray()); + TAG_KEY_PROGRESS_TIMES, + Arrays.stream(slices) + .limit(currentInputLength) + .mapToInt(s -> s.progress) + .toArray()); aNBT.setBoolean("stuck", stuck); aNBT.setLong("inputV", inputVoltage); aNBT.setLong("inputEU", inputEUt); @@ -406,7 +439,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas if (aNBT.hasKey(TAG_KEY_CURRENT_STICK, Constants.NBT.TAG_COMPOUND)) { loadedStack = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag(TAG_KEY_CURRENT_STICK)); GT_AssemblyLineUtils.LookupResult lookupResult = GT_AssemblyLineUtils - .findAssemblyLineRecipeFromDataStick(loadedStack, false); + .findAssemblyLineRecipeFromDataStick(loadedStack, false); switch (lookupResult.getType()) { case VALID_STACK_AND_VALID_HASH: recipe = lookupResult.getRecipe(); @@ -526,19 +559,20 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas * l -> { currentInputLength = l; for (SliceStatusWidget w : arr) { w.updateText(); } })); */ screenElements.widget( - new TextWidget(Text.localised("ggfab.gui.advassline.shutdown")) - .setEnabled(this::hasAbnormalStopReason)); + new TextWidget(Text.localised("ggfab.gui.advassline.shutdown")).setEnabled(this::hasAbnormalStopReason)); screenElements.widget( - new TextWidget().setTextSupplier(() -> Text.localised(lastStopReason)) - .attachSyncer( - new FakeSyncWidget.StringSyncer(() -> lastStopReason, r -> this.lastStopReason = r), - screenElements) - .setEnabled(this::hasAbnormalStopReason)); + new TextWidget().setTextSupplier(() -> Text.localised(lastStopReason)) + .attachSyncer( + new FakeSyncWidget.StringSyncer(() -> lastStopReason, r -> this.lastStopReason = r), + screenElements) + .setEnabled(this::hasAbnormalStopReason)); screenElements.widget( - new ClickableTextWidget( - Text.localised("ggfab.gui.advassline.shutdown_clear").alignment(Alignment.CenterLeft)) - .setMarginInLines(0).setOnClick((d, w) -> lastStopReason = "").setSize(36, 20) - .setEnabled(this::hasAbnormalStopReason)); + new ClickableTextWidget( + Text.localised("ggfab.gui.advassline.shutdown_clear") + .alignment(Alignment.CenterLeft)).setMarginInLines(0) + .setOnClick((d, w) -> lastStopReason = "") + .setSize(36, 20) + .setEnabled(this::hasAbnormalStopReason)); } private Boolean hasAbnormalStopReason(Widget w) { @@ -578,8 +612,8 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas if (getBaseMetaTileEntity().isAllowedToWork() && slices[0].progress < 0) { startRecipeProcessing(); if (hasAllItems(currentRecipe, this.currentRecipeParallel) - && hasAllFluids(currentRecipe, this.currentRecipeParallel) - && slices[0].start()) { + && hasAllFluids(currentRecipe, this.currentRecipeParallel) + && slices[0].start()) { drainAllFluids(currentRecipe, this.currentRecipeParallel); mProgresstime = 0; } @@ -648,7 +682,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas private GT_Recipe.GT_Recipe_AssemblyLine findRecipe(ItemStack tDataStick) { GT_AssemblyLineUtils.LookupResult tLookupResult = GT_AssemblyLineUtils - .findAssemblyLineRecipeFromDataStick(tDataStick, false); + .findAssemblyLineRecipeFromDataStick(tDataStick, false); if (tLookupResult.getType() == GT_AssemblyLineUtils.LookupResultType.INVALID_STICK) return null; @@ -690,18 +724,15 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas return false; } int maxParallel = (int) GT_Recipe.GT_Recipe_AssemblyLine - .maxParallelCalculatedByInputItems(mInputBusses, parallel, itemConsumptions, curBatchItemsFromME); + .maxParallelCalculatedByInputItems(mInputBusses, parallel, itemConsumptions, curBatchItemsFromME); return maxParallel >= parallel; } private boolean hasAllFluids(GT_Recipe.GT_Recipe_AssemblyLine tRecipe, int parallel) { int aFluidCount = tRecipe.mFluidInputs.length; if (mInputHatches.size() < aFluidCount) return false; - int maxParallel = (int) GT_Recipe.GT_Recipe_AssemblyLine.maxParallelCalculatedByInputFluids( - mInputHatches, - parallel, - tRecipe.mFluidInputs, - curBatchFluidsFromME); + int maxParallel = (int) GT_Recipe.GT_Recipe_AssemblyLine + .maxParallelCalculatedByInputFluids(mInputHatches, parallel, tRecipe.mFluidInputs, curBatchFluidsFromME); return maxParallel >= parallel; } @@ -724,10 +755,16 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas } for (GT_MetaTileEntity_Hatch_DataAccess tHatch : mDataAccessHatches) { if (tHatch.isValid()) { - for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null - && isCorrectDataItem(tHatch.getBaseMetaTileEntity().getStackInSlot(i), state)) - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + for (int i = 0; i < tHatch.getBaseMetaTileEntity() + .getSizeInventory(); i++) { + if (tHatch.getBaseMetaTileEntity() + .getStackInSlot(i) != null && isCorrectDataItem( + tHatch.getBaseMetaTileEntity() + .getStackInSlot(i), + state)) + rList.add( + tHatch.getBaseMetaTileEntity() + .getStackInSlot(i)); } } } @@ -772,18 +809,19 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas // calculateOverclockedNessMulti from super class has a mysterious 5% cable loss thing at the moment // of writing GT_OverclockCalculator ocCalc = new GT_OverclockCalculator().setRecipeEUt(currentRecipe.mEUt) - .setDuration(Math.max(recipe.mDuration / recipe.mInputs.length, 1)).setEUt(inputVoltage) - .calculate(); + .setDuration(Math.max(recipe.mDuration / recipe.mInputs.length, 1)) + .setEUt(inputVoltage) + .calculate(); // since we already checked mEUt <= inputVoltage, no need to check if recipe is too OP lEUt = ocCalc.getConsumption(); mMaxProgresstime = ocCalc.getDuration(); // then laser overclock if needed if (!mExoticEnergyHatches.isEmpty()) { OverclockHelper.OverclockOutput laserOverclock = OverclockHelper.laserOverclock( - lEUt, - mMaxProgresstime, - inputEUt / recipe.mInputs.length, - ConfigurationHandler.INSTANCE.getLaserOCPenaltyFactor()); + lEUt, + mMaxProgresstime, + inputEUt / recipe.mInputs.length, + ConfigurationHandler.INSTANCE.getLaserOCPenaltyFactor()); if (laserOverclock != null) { lEUt = laserOverclock.getEUt(); mMaxProgresstime = laserOverclock.getDuration(); @@ -896,13 +934,13 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas @Override public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor, - IWailaConfigHandler config) { + IWailaConfigHandler config) { super.getWailaBody(itemStack, currentTip, accessor, config); NBTTagCompound tag = accessor.getNBTData(); String machineProgressString = GT_Waila.getMachineProgressString( - tag.getBoolean("isActive"), - tag.getInteger("maxProgress"), - tag.getInteger("progress")); + tag.getBoolean("isActive"), + tag.getInteger("maxProgress"), + tag.getInteger("progress")); currentTip.remove(machineProgressString); int duration = tag.getInteger("mDuration"); @@ -919,14 +957,10 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas currentTip.add(I18n.format("ggfab.waila.advassline.slice.idle", i + 1)); } else if (duration > 40) { currentTip.add( - I18n.format( - "ggfab.waila.advassline.slice", - i + 1, - (duration - progress) / 20, - duration / 20)); + I18n.format("ggfab.waila.advassline.slice", i + 1, (duration - progress) / 20, duration / 20)); } else { - currentTip.add( - I18n.format("ggfab.waila.advassline.slice.small", i + 1, duration - progress, duration)); + currentTip + .add(I18n.format("ggfab.waila.advassline.slice.small", i + 1, duration - progress, duration)); } } } @@ -934,7 +968,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas @Override public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, - int z) { + int z) { super.getWailaNBTData(player, tile, tag, world, x, y, z); if (currentRecipe == null || !getBaseMetaTileEntity().isActive()) return; NBTTagList l = new NBTTagList(); @@ -951,7 +985,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas */ private void drainAllFluids(GT_Recipe.GT_Recipe_AssemblyLine recipe, int parallel) { GT_Recipe.GT_Recipe_AssemblyLine - .consumeInputFluids(mInputHatches, parallel, recipe.mFluidInputs, curBatchFluidsFromME); + .consumeInputFluids(mInputHatches, parallel, recipe.mFluidInputs, curBatchFluidsFromME); for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) tHatch.updateSlots(); } @@ -968,7 +1002,7 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas @Override public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { batchMode = !batchMode; if (batchMode) { @@ -1073,11 +1107,12 @@ public class MTE_AdvAssLine extends GT_MetaTileEntity_ExtendedPowerMultiBlockBas ItemStack stack = getInputBusContent(id); if (stack == null) return false; int size = GT_Recipe.GT_Recipe_AssemblyLine - .getMatchedIngredientAmount(stack, currentRecipe.mInputs[id], currentRecipe.mOreDictAlt[id]); + .getMatchedIngredientAmount(stack, currentRecipe.mInputs[id], currentRecipe.mOreDictAlt[id]); if (size < 0 || stack.stackSize < size * currentRecipeParallel) return false; progress = mMaxProgresstime / currentInputLength; stack.stackSize -= size * currentRecipeParallel; - mInputBusses.get(id).updateSlots(); + mInputBusses.get(id) + .updateSlots(); return true; } diff --git a/src/main/java/net/glease/ggfab/mte/MTE_LinkedInputBus.java b/src/main/java/net/glease/ggfab/mte/MTE_LinkedInputBus.java index da0f10c2bb..ea39716c1a 100644 --- a/src/main/java/net/glease/ggfab/mte/MTE_LinkedInputBus.java +++ b/src/main/java/net/glease/ggfab/mte/MTE_LinkedInputBus.java @@ -59,14 +59,14 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme public MTE_LinkedInputBus(int id, String name, String nameRegional, int tier) { super( - id, - name, - nameRegional, - tier, - 1, - new String[] { SIZE_INVENTORY + " slot input bus linked together wirelessly", - "Link does not cross world boundary", - "Left/right click with data stick to copy/paste configuration", GGConstants.GGMARK_TOOLTIP, }); + id, + name, + nameRegional, + tier, + 1, + new String[] { SIZE_INVENTORY + " slot input bus linked together wirelessly", + "Link does not cross world boundary", "Left/right click with data stick to copy/paste configuration", + GGConstants.GGMARK_TOOLTIP, }); } public MTE_LinkedInputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { @@ -86,36 +86,49 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { builder.widget( - new TextFieldWidget().setSynced(true, true).setGetter(() -> mChannel == null ? "" : mChannel) - .setSetter(this::setChannel).setTextColor(Color.WHITE.dark(1)) - .setTextAlignment(Alignment.CenterLeft).setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD) - .setGTTooltip(() -> mTooltipCache.getData("ggfab.tooltip.linked_input_bus.change_freq_warn")) - .setSize(60, 18).setPos(48, 3)) - .widget( - new CycleButtonWidget().setToggle(this::isPrivate, this::setPrivate) - .setTextureGetter( - i -> i == 1 ? GT_UITextures.OVERLAY_BUTTON_CHECKMARK - : GT_UITextures.OVERLAY_BUTTON_CROSS) - .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE).setSynced(true, true) - .setGTTooltip(() -> mTooltipCache.getData("ggfab.tooltip.linked_input_bus.private")) - .setSize(18, 18).setPos(150, 3)) - .widget( - SlotGroup.ofItemHandler(handler, 9).startFromSlot(0).endAtSlot(SIZE_INVENTORY - 1) - .background(getGUITextureSet().getItemSlot()) - .slotCreator(i -> new BaseSlot(handler, i, false) { - - @Override - public ItemStack getStack() { - return isEnabled() ? super.getStack() : null; - } - - @Override - public boolean isEnabled() { - return mChannel != null; - } - }).build().setPos(7, 24)) - .widget(new TextWidget(new Text("Private")).setPos(110, 3).setSize(43, 20)) - .widget(new TextWidget(new Text("Channel")).setPos(5, 3).setSize(43, 20)); + new TextFieldWidget().setSynced(true, true) + .setGetter(() -> mChannel == null ? "" : mChannel) + .setSetter(this::setChannel) + .setTextColor(Color.WHITE.dark(1)) + .setTextAlignment(Alignment.CenterLeft) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD) + .setGTTooltip(() -> mTooltipCache.getData("ggfab.tooltip.linked_input_bus.change_freq_warn")) + .setSize(60, 18) + .setPos(48, 3)) + .widget( + new CycleButtonWidget().setToggle(this::isPrivate, this::setPrivate) + .setTextureGetter( + i -> i == 1 ? GT_UITextures.OVERLAY_BUTTON_CHECKMARK : GT_UITextures.OVERLAY_BUTTON_CROSS) + .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE) + .setSynced(true, true) + .setGTTooltip(() -> mTooltipCache.getData("ggfab.tooltip.linked_input_bus.private")) + .setSize(18, 18) + .setPos(150, 3)) + .widget( + SlotGroup.ofItemHandler(handler, 9) + .startFromSlot(0) + .endAtSlot(SIZE_INVENTORY - 1) + .background(getGUITextureSet().getItemSlot()) + .slotCreator(i -> new BaseSlot(handler, i, false) { + + @Override + public ItemStack getStack() { + return isEnabled() ? super.getStack() : null; + } + + @Override + public boolean isEnabled() { + return mChannel != null; + } + }) + .build() + .setPos(7, 24)) + .widget( + new TextWidget(new Text("Private")).setPos(110, 3) + .setSize(43, 20)) + .widget( + new TextWidget(new Text("Channel")).setPos(5, 3) + .setSize(43, 20)); } @Override @@ -158,21 +171,21 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) { return isValidSlot(aIndex) && aStack != null - && mChannel != null - && mRealInventory != null - && aIndex > getCircuitSlot() - && aIndex < SIZE_INVENTORY + 1 - && (mRealInventory.stacks[aIndex - 1] == null - || GT_Utility.areStacksEqual(aStack, mRealInventory.stacks[aIndex - 1])) - && allowPutStack(getBaseMetaTileEntity(), aIndex, ForgeDirection.getOrientation(ordinalSide), aStack); + && mChannel != null + && mRealInventory != null + && aIndex > getCircuitSlot() + && aIndex < SIZE_INVENTORY + 1 + && (mRealInventory.stacks[aIndex - 1] == null + || GT_Utility.areStacksEqual(aStack, mRealInventory.stacks[aIndex - 1])) + && allowPutStack(getBaseMetaTileEntity(), aIndex, ForgeDirection.getOrientation(ordinalSide), aStack); } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { + ItemStack aStack) { return side == getBaseMetaTileEntity().getFrontFacing() && aIndex != getCircuitSlot() - && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack)) - && (mRealInventory.disableLimited || limitedAllowPutStack(aIndex, aStack)); + && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack)) + && (mRealInventory.disableLimited || limitedAllowPutStack(aIndex, aStack)); } @Override @@ -220,7 +233,7 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme if (mChannel == null || mRealInventory == null) return; for (int i = 0; i < mRealInventory.stacks.length; i++) { if (mRealInventory.stacks[i] != null - && (mRealInventory.stacks[i].getItem() == null || mRealInventory.stacks[i].stackSize <= 0)) + && (mRealInventory.stacks[i].getItem() == null || mRealInventory.stacks[i].stackSize <= 0)) mRealInventory.stacks[i] = null; } if (!mRealInventory.disableSort) fillStacksIntoFirstSlots(); @@ -253,7 +266,8 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme if (toSet == 0) continue; int slot = validSlots.get(slotindex); slotindex++; - mRealInventory.stacks[slot] = stacks.get(sID).copy(); + mRealInventory.stacks[slot] = stacks.get(sID) + .copy(); toSet = Math.min(toSet, mRealInventory.stacks[slot].getMaxStackSize()); mRealInventory.stacks[slot].stackSize = toSet; slots.merge(sID, toSet, (a, b) -> a - b); @@ -264,13 +278,14 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme for (ItemStack stack : aStacks) { if (!GT_Utility.isStackValid(stack)) continue; EntityItem ei = new EntityItem( - getBaseMetaTileEntity().getWorld(), - getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5, - getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5, - getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5, - stack); + getBaseMetaTileEntity().getWorld(), + getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5, + getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5, + getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5, + stack); ei.motionX = ei.motionY = ei.motionZ = 0; - getBaseMetaTileEntity().getWorld().spawnEntityInWorld(ei); + getBaseMetaTileEntity().getWorld() + .spawnEntityInWorld(ei); } } @@ -320,7 +335,8 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme @Override public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(side).isGUIClickable( + if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(side) + .isGUIClickable( side, getBaseMetaTileEntity().getCoverIDAtSide(side), getBaseMetaTileEntity().getComplexCoverDataAtSide(side), @@ -342,21 +358,20 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme } } GT_Utility.sendChatToPlayer( - aPlayer, - StatCollector.translateToLocal("GT5U.hatch.disableSort." + mRealInventory.disableSort) + " " - + StatCollector - .translateToLocal("GT5U.hatch.disableLimited." + mRealInventory.disableLimited)); + aPlayer, + StatCollector.translateToLocal("GT5U.hatch.disableSort." + mRealInventory.disableSort) + " " + + StatCollector.translateToLocal("GT5U.hatch.disableLimited." + mRealInventory.disableLimited)); } else { this.disableFilter = !this.disableFilter; GT_Utility.sendChatToPlayer( - aPlayer, - StatCollector.translateToLocal("GT5U.hatch.disableFilter." + this.disableFilter)); + aPlayer, + StatCollector.translateToLocal("GT5U.hatch.disableFilter." + this.disableFilter)); } } @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, - float aX, float aY, float aZ) { + float aX, float aY, float aZ) { if (!(aPlayer instanceof EntityPlayerMP)) return super.onRightclick(aBaseMetaTileEntity, aPlayer, side, aX, aY, aZ); ItemStack stick = aPlayer.inventory.getCurrentItem(); @@ -372,13 +387,14 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme if ("".equals(channel)) { aPlayer.addChatMessage(new ChatComponentTranslation("ggfab.info.linked_input_bus.no_data")); return true; - } else if (circuit != null && getConfigurationCircuits().stream().noneMatch(circuit::isItemEqual)) { - aPlayer.addChatMessage(new ChatComponentTranslation("ggfab.info.linked_input_bus.invalid_circuit")); - return true; - } + } else if (circuit != null && getConfigurationCircuits().stream() + .noneMatch(circuit::isItemEqual)) { + aPlayer.addChatMessage(new ChatComponentTranslation("ggfab.info.linked_input_bus.invalid_circuit")); + return true; + } UUID owner = stick.stackTagCompound.hasKey("owner1") - ? new UUID(stick.stackTagCompound.getLong("owner1"), stick.stackTagCompound.getLong("owner2")) - : null; + ? new UUID(stick.stackTagCompound.getLong("owner1"), stick.stackTagCompound.getLong("owner2")) + : null; if (owner != null && !owner.equals(getBaseMetaTileEntity().getOwnerUuid())) { aPlayer.addChatMessage(new ChatComponentTranslation("ggfab.info.linked_input_bus.not_owned")); return true; @@ -404,8 +420,14 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme tag.setString("channel", getChannel()); tag.setTag("circuit", GT_Utility.saveItem(getStackInSlot(getCircuitSlot()))); if (isPrivate()) { - tag.setLong("owner1", getBaseMetaTileEntity().getOwnerUuid().getMostSignificantBits()); - tag.setLong("owner2", getBaseMetaTileEntity().getOwnerUuid().getLeastSignificantBits()); + tag.setLong( + "owner1", + getBaseMetaTileEntity().getOwnerUuid() + .getMostSignificantBits()); + tag.setLong( + "owner2", + getBaseMetaTileEntity().getOwnerUuid() + .getLeastSignificantBits()); } aPlayer.addChatMessage(new ChatComponentTranslation("ggfab.info.linked_input_bus.data_copied", getChannel())); stick.stackTagCompound = tag; @@ -479,10 +501,11 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme private WorldSave getWorldSave() { if (save == null) { WorldSave save = (WorldSave) getBaseMetaTileEntity().getWorld() - .loadItemData(WorldSave.class, "LinkedInputBusses"); + .loadItemData(WorldSave.class, "LinkedInputBusses"); if (save == null) { save = new WorldSave("LinkedInputBusses"); - getBaseMetaTileEntity().getWorld().setItemData(save.mapName, save); + getBaseMetaTileEntity().getWorld() + .setItemData(save.mapName, save); } this.save = save; } @@ -562,7 +585,10 @@ public class MTE_LinkedInputBus extends GT_MetaTileEntity_Hatch_InputBus impleme @Override public void writeToNBT(NBTTagCompound tag) { for (Map.Entry<String, SharedInventory> e : data.entrySet()) { - if (e.getValue().ref > 0) tag.setTag(e.getKey(), e.getValue().save()); + if (e.getValue().ref > 0) tag.setTag( + e.getKey(), + e.getValue() + .save()); } } diff --git a/src/main/java/net/glease/ggfab/mui/ClickableTextWidget.java b/src/main/java/net/glease/ggfab/mui/ClickableTextWidget.java index 34287c2237..679f32da37 100644 --- a/src/main/java/net/glease/ggfab/mui/ClickableTextWidget.java +++ b/src/main/java/net/glease/ggfab/mui/ClickableTextWidget.java @@ -49,7 +49,10 @@ public class ClickableTextWidget extends ButtonWidget { protected @NotNull Size determineSize(int maxWidth, int maxHeight) { if (caption == null) return super.determineSize(maxWidth, maxHeight); return new Size( - Math.min(maxWidth, TextRenderer.getFontRenderer().getStringWidth(caption.getFormatted())), - (maxLines + marginInLines) * TextRenderer.getFontRenderer().FONT_HEIGHT); + Math.min( + maxWidth, + TextRenderer.getFontRenderer() + .getStringWidth(caption.getFormatted())), + (maxLines + marginInLines) * TextRenderer.getFontRenderer().FONT_HEIGHT); } } diff --git a/src/main/java/net/glease/ggfab/util/GGUtils.java b/src/main/java/net/glease/ggfab/util/GGUtils.java index 59dbf482ec..20181f9ba8 100644 --- a/src/main/java/net/glease/ggfab/util/GGUtils.java +++ b/src/main/java/net/glease/ggfab/util/GGUtils.java @@ -12,21 +12,24 @@ public class GGUtils { public static boolean isValidTile(IGregTechTileEntity tile) { return tile != null && !tile.isDead() - && tile.getMetaTileEntity() != null - && tile.getMetaTileEntity().getBaseMetaTileEntity() == tile; + && tile.getMetaTileEntity() != null + && tile.getMetaTileEntity() + .getBaseMetaTileEntity() == tile; } public static boolean isValidTile(IMetaTileEntity mte) { return mte != null && mte.getBaseMetaTileEntity() != null - && mte.getBaseMetaTileEntity().getMetaTileEntity() == mte - && !mte.getBaseMetaTileEntity().isDead(); + && mte.getBaseMetaTileEntity() + .getMetaTileEntity() == mte + && !mte.getBaseMetaTileEntity() + .isDead(); } public static ChunkCoordinates translate(ChunkCoordinates origin, ForgeDirection direction) { return new ChunkCoordinates( - origin.posX + direction.offsetX, - origin.posY + direction.offsetY, - origin.posZ + direction.offsetZ); + origin.posX + direction.offsetX, + origin.posY + direction.offsetY, + origin.posZ + direction.offsetZ); } public static String formatTileInfo(String prefix, IMetaTileEntity mte, String delimiter, String suffix) { diff --git a/src/main/java/net/glease/ggfab/util/OverclockHelper.java b/src/main/java/net/glease/ggfab/util/OverclockHelper.java index bd75a02269..c47103f253 100644 --- a/src/main/java/net/glease/ggfab/util/OverclockHelper.java +++ b/src/main/java/net/glease/ggfab/util/OverclockHelper.java @@ -18,7 +18,7 @@ public class OverclockHelper { } public static OverclockOutput laserOverclock(long recipeEUt, int duration, long inputEUt, - float penaltyIncreaseFactor) { + float penaltyIncreaseFactor) { if (recipeEUt > inputEUt) return null; float currentPenalty = 4 + penaltyIncreaseFactor; // 2/(n+k) overclock until energy hatch is crying |