diff options
Diffstat (limited to 'src/Java')
8 files changed, 728 insertions, 265 deletions
diff --git a/src/Java/gregtech/api/util/GTPP_Recipe.java b/src/Java/gregtech/api/util/GTPP_Recipe.java index bcbbb93007..24459aca92 100644 --- a/src/Java/gregtech/api/util/GTPP_Recipe.java +++ b/src/Java/gregtech/api/util/GTPP_Recipe.java @@ -341,8 +341,7 @@ public class GTPP_Recipe extends GT_Recipe implements IComparableRecipe { public static final GTPP_Recipe_Map_Internal sSteamTurbineFuels = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10), "gtpp.recipe.steamturbinefuel", "GeoThermal Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); //LFTR recipes - public static final GTPP_Recipe_Map_Internal sLiquidFluorineThoriumReactorRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(50), "gtpp.recipe.lftr", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); - public static final GTPP_Recipe_Map_Internal sLiquidFluorineThoriumReactorRecipesEx = new GTPP_Recipe_Map_Internal(new NoConflictGTRecipeMap(), "gtpp.recipe.lftr.2", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/LFTR", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, true); + public static final GTPP_Recipe_Map_Internal sLiquidFluorineThoriumReactorRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(50), "gtpp.recipe.lftr", "Liquid Fluoride Thorium Reactor", null, RES_PATH_GUI + "basicmachines/FissionFuel", 0, 0, 0, 2, 0, "Power: ", 1, " EU/t per Dynamo", true, true); // Ore Milling Map public static final GTPP_Recipe_Map_Internal sOreMillRecipes = new GTPP_Recipe_Map_Internal(new HashSet<GT_Recipe>(10000), "gtpp.recipe.oremill", "Milling", null, RES_PATH_GUI + "basicmachines/LFTR", 3, 4, 1, 0, 1, E, 1, E, true, false); diff --git a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java index c9cdc41424..334f647b44 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java +++ b/src/Java/gtPlusPlus/core/commands/CommandEnableDebugWhileRunning.java @@ -133,15 +133,21 @@ public class CommandEnableDebugWhileRunning implements ICommand } } - String aFluidContainerData = ""; + AutoMap<String> aFluidContainerData = new AutoMap<String>(); FluidStack aHeldItemFluid = FluidContainerRegistry.getFluidForFilledItem(aHeldItem); if (aHeldItemFluid != null) { - aFluidContainerData = "["+aHeldItemFluid.getUnlocalizedName()+"]["+aHeldItemFluid.getLocalizedName()+"]"; + aFluidContainerData.put("FluidStack Unlocal Name: "+aHeldItemFluid.getUnlocalizedName()); + aFluidContainerData.put("FluidStack Local Name: "+aHeldItemFluid.getLocalizedName()); + aFluidContainerData.put("Fluid Unlocal Name: "+aHeldItemFluid.getFluid().getUnlocalizedName()); + aFluidContainerData.put("Fluid Local Name: "+aHeldItemFluid.getFluid().getLocalizedName()); + aFluidContainerData.put("Fluid Name: "+aHeldItemFluid.getFluid().getName()); } PlayerUtils.messagePlayer(P, "["+aItemUnlocalName+"]"+"["+aItemDisplayName+"] "); - if (aFluidContainerData.length() > 0) { - PlayerUtils.messagePlayer(P, ""+aFluidContainerData); + if (aFluidContainerData.size() > 0) { + for (String s : aFluidContainerData) { + PlayerUtils.messagePlayer(P, ""+s); + } } if (!aOreDictNames.isEmpty()) { PlayerUtils.messagePlayer(P, ""+aOreDictData); diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_LFTR.java b/src/Java/gtPlusPlus/nei/GT_NEI_LFTR.java new file mode 100644 index 0000000000..0638630201 --- /dev/null +++ b/src/Java/gtPlusPlus/nei/GT_NEI_LFTR.java @@ -0,0 +1,457 @@ +package gtPlusPlus.nei; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.lwjgl.opengl.GL11; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.guihook.IContainerInputHandler; +import codechicken.nei.guihook.IContainerTooltipHandler; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.GT_GUIContainer_BasicMachine; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map_Internal; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_NEI_LFTR +extends TemplateRecipeHandler { + public static final int sOffsetX = 5; + public static final int sOffsetY = 11; + + static { + GuiContainerManager.addInputHandler(new GT_RectHandler()); + GuiContainerManager.addTooltipHandler(new GT_RectHandler()); + } + + protected GTPP_Recipe_Map_Internal mRecipeMap; + + public GT_NEI_LFTR() { + this.mRecipeMap = GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes; + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getRecipeMapName(), new Object[0])); + if (!NEI_GT_Config.sIsAdded) { + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtechplusplus@" + this.getRecipeName() + "@" + this.getRecipeMapName()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + public List<GTPP_Recipe> getSortedRecipes() { + List<GTPP_Recipe> result = new ArrayList(this.mRecipeMap.mRecipeList); + Collections.sort(result); + return result; + } + + public static void drawText(final int aX, final int aY, final String aString, final int aColor) { + Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); + } + + @Override + public TemplateRecipeHandler newInstance() { + return new GT_NEI_LFTR(); + } + + @Override + public void loadCraftingRecipes(final String outputId, final Object... results) { + if (outputId.equals(getRecipeMapName())) { + for (GTPP_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(final ItemStack aResult) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); + + ArrayList<ItemStack> tResults = new ArrayList<ItemStack>(); + tResults.add(aResult); + tResults.add(GT_OreDictUnificator.get(true, aResult)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aResult, true); + if (tFluid != null) { + tResults.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tResults.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (GTPP_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tResults) { + if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public void loadUsageRecipes(ItemStack aInput) { + ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); + + ArrayList<ItemStack> tInputs = new ArrayList<ItemStack>(); + tInputs.add(aInput); + tInputs.add(GT_OreDictUnificator.get(false, aInput)); + if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { + tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); + } + } + FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true); + if (tFluid != null) { + tInputs.add(GT_Utility.getFluidDisplayStack(tFluid, false)); + for (FluidContainerRegistry.FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (tData.fluid.isFluidEqual(tFluid)) { + tInputs.add(GT_Utility.copy(new Object[]{tData.filledContainer})); + } + } + } + for (GTPP_Recipe tRecipe : getSortedRecipes()) { + if (!tRecipe.mHidden) { + CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); + for (ItemStack tStack : tInputs) { + if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { + this.arecipes.add(tNEIRecipe); + break; + } + } + } + } + //CachedDefaultRecipe tNEIRecipe; + } + + public String getRecipeMapName() { + return this.mRecipeMap.mNEIName; + } + + @Override + public String getOverlayIdentifier() { + return this.mRecipeMap.mNEIName; + } + + @Override + public void drawBackground(final int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(this.getGuiTexture()); + GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public String getRecipeName() { + return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + } + + @Override + public String getGuiTexture() { + return this.mRecipeMap.mNEIGUIPath; + } + + @Override + public List<String> handleItemTooltip(final GuiRecipe gui, final ItemStack aStack, final List<String> currenttip, final int aRecipeIndex) { + final TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); + if ((tObject instanceof CachedDefaultRecipe)) { + final CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; + for (final PositionedStack tStack : tRecipe.mOutputs) { + if (aStack == tStack.item) { + if (ItemList.Display_Fluid.isStackEqual(tStack.item, true, true) && ((FixedPositionedStack) tStack).mChance < 10000) { + currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + //currenttip.add("Chance: " + (((FixedPositionedStack) tStack).mChance / 100) + "." + ((((FixedPositionedStack) tStack).mChance % 100) < 10 ? "0" + (((FixedPositionedStack) tStack).mChance % 100) : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + break; + } + } + for (final PositionedStack tStack : tRecipe.mInputs) { + if (GT_Utility.areStacksEqual(aStack, tStack.item)) { + if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || + (tStack.item.stackSize != 0)) { + break; + } + if (ItemUtils.isControlCircuit(aStack)) { + currenttip.add("Does not get consumed in the process"); + } + break; + } + } + } + return currenttip; + } + + @Override + public void drawExtras(final int aRecipeIndex) { + final long tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + final int tDuration = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + drawText(10, 83, "Time: " + (tDuration < 20 ? "< 1" : Integer.valueOf(tDuration / 20)) + " secs", -16777216); + drawText(10, 93, this.mRecipeMap.mNEISpecialValuePre + (((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue * this.mRecipeMap.mNEISpecialValueMultiplier) + this.mRecipeMap.mNEISpecialValuePost, -16777216); + drawText(10, 103, "Dynamo: " + (long) (tDuration * tEUt) + " EU", -16777216); + drawText(10, 113, "Total: " + (long) (tDuration * tEUt * 4) + " EU", -16777216); + } + + public static class GT_RectHandler + implements IContainerInputHandler, IContainerTooltipHandler { + @Override + public boolean mouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + if (this.canHandle(gui)) { + if (button == 0) { + return this.transferRect(gui, false); + } + if (button == 1) { + return this.transferRect(gui, true); + } + } + return false; + } + + @Override + public boolean lastKeyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + public boolean canHandle(final GuiContainer gui) { + return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) /*|| ((gui instanceof GT_GUIContainer_FusionReactor)) && (GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI))*/); + } + + @Override + public List<String> handleTooltip(final GuiContainer gui, final int mousex, final int mousey, final List<String> currenttip) { + if ((this.canHandle(gui)) && (currenttip.isEmpty())) { + if ((gui instanceof GT_GUIContainer_BasicMachine) && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + currenttip.add("Recipes"); + }*/ + + } + return currenttip; + } + + private boolean transferRect(final GuiContainer gui, final boolean usage) { + if (gui instanceof GT_GUIContainer_BasicMachine) { + return (this.canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI, new Object[0])); + } /*else if (gui instanceof GT_GUIContainer_FusionReactor) { + return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0]) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI, new Object[0])); + }*/ + return false; + } + + @Override + public List<String> handleItemDisplayName(final GuiContainer gui, final ItemStack itemstack, final List<String> currenttip) { + return currenttip; + } + + @Override + public List<String> handleItemTooltip(final GuiContainer gui, final ItemStack itemstack, final int mousex, final int mousey, final List<String> currenttip) { + return currenttip; + } + + @Override + public boolean keyTyped(final GuiContainer gui, final char keyChar, final int keyCode) { + return false; + } + + @Override + public void onKeyTyped(final GuiContainer gui, final char keyChar, final int keyID) { + } + + @Override + public void onMouseClicked(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public void onMouseUp(final GuiContainer gui, final int mousex, final int mousey, final int button) { + } + + @Override + public boolean mouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + return false; + } + + @Override + public void onMouseScrolled(final GuiContainer gui, final int mousex, final int mousey, final int scrolled) { + } + + @Override + public void onMouseDragged(final GuiContainer gui, final int mousex, final int mousey, final int button, final long heldTime) { + } + } + + public class FixedPositionedStack + extends PositionedStack { + public final int mChance; + public boolean permutated = false; + + public FixedPositionedStack(final Object object, final int x, final int y) { + this(object, x, y, 0); + } + + public FixedPositionedStack(final Object object, final int x, final int y, final int aChance) { + super(object, x, y, true); + this.mChance = aChance; + } + + @Override + public void generatePermutations() { + if (this.permutated) { + return; + } + final ArrayList<ItemStack> tDisplayStacks = new ArrayList<ItemStack>(); + for (final ItemStack tStack : this.items) { + if (GT_Utility.isStackValid(tStack)) { + if (tStack.getItemDamage() == 32767) { + final List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + if (!permutations.isEmpty()) { + ItemStack stack; + for (final Iterator<ItemStack> i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, new Object[]{stack}))) { + stack = i$.next(); + } + } else { + final ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); + base.stackTagCompound = tStack.stackTagCompound; + tDisplayStacks.add(base); + } + } else { + tDisplayStacks.add(GT_Utility.copy(new Object[]{tStack})); + } + } + } + this.items = (tDisplayStacks.toArray(new ItemStack[0])); + if (this.items.length == 0) { + this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + } + this.permutated = true; + this.setPermutationToRender(0); + } + } + + public class CachedDefaultRecipe + extends TemplateRecipeHandler.CachedRecipe { + public final GT_Recipe mRecipe; + public final List<PositionedStack> mOutputs = new ArrayList<PositionedStack>(); + public final List<PositionedStack> mInputs = new ArrayList<PositionedStack>(); + + public CachedDefaultRecipe(final GT_Recipe aRecipe) { + super(); + this.mRecipe = aRecipe; + + int tStartIndex = 0; + if (aRecipe.mFluidInputs.length > 0) { + if ((aRecipe.mFluidInputs[0] != null) && (aRecipe.mFluidInputs[0].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[0], true), 12, 5)); + } + if ((aRecipe.mFluidInputs.length > 1) && (aRecipe.mFluidInputs[1] != null) && (aRecipe.mFluidInputs[1].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[1], true), 30, 5)); + } + if ((aRecipe.mFluidInputs.length > 2) && (aRecipe.mFluidInputs[2] != null) && (aRecipe.mFluidInputs[2].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[2], true), 48, 5)); + } + if ((aRecipe.mFluidInputs.length > 3) && (aRecipe.mFluidInputs[3] != null) && (aRecipe.mFluidInputs[3].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[3], true), 12, 23)); + } + if ((aRecipe.mFluidInputs.length > 4) && (aRecipe.mFluidInputs[4] != null) && (aRecipe.mFluidInputs[4].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[4], true), 30, 23)); + } + if ((aRecipe.mFluidInputs.length > 5) && (aRecipe.mFluidInputs[5] != null) && (aRecipe.mFluidInputs[5].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[5], true), 48, 23)); + } + if ((aRecipe.mFluidInputs.length > 6) && (aRecipe.mFluidInputs[6] != null) && (aRecipe.mFluidInputs[6].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[6], true), 12, 41)); + } + if ((aRecipe.mFluidInputs.length > 7) && (aRecipe.mFluidInputs[7] != null) && (aRecipe.mFluidInputs[7].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[7], true), 30, 41)); + } + if ((aRecipe.mFluidInputs.length > 8) && (aRecipe.mFluidInputs[8] != null) && (aRecipe.mFluidInputs[8].getFluid() != null)) { + this.mInputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidInputs[8], true), 48, 41)); + } + } + + tStartIndex = 0; + if (aRecipe.mFluidOutputs.length > 0) { + if ((aRecipe.mFluidOutputs[0] != null) && (aRecipe.mFluidOutputs[0].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[0], true), 102, 5, aRecipe.getOutputChance(tStartIndex++))); + } + if ((aRecipe.mFluidOutputs.length > 1) && (aRecipe.mFluidOutputs[1] != null) && (aRecipe.mFluidOutputs[1].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[1], true), 120, 5, aRecipe.getOutputChance(tStartIndex++))); + } + if ((aRecipe.mFluidOutputs.length > 2) && (aRecipe.mFluidOutputs[2] != null) && (aRecipe.mFluidOutputs[2].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[2], true), 138, 5, aRecipe.getOutputChance(tStartIndex++))); + } + if ((aRecipe.mFluidOutputs.length > 3) && (aRecipe.mFluidOutputs[3] != null) && (aRecipe.mFluidOutputs[3].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[3], true), 102, 23, aRecipe.getOutputChance(tStartIndex++))); + } + if ((aRecipe.mFluidOutputs.length > 4) && (aRecipe.mFluidOutputs[4] != null) && (aRecipe.mFluidOutputs[4].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[4], true), 120, 23, aRecipe.getOutputChance(tStartIndex++))); + } + if ((aRecipe.mFluidOutputs.length > 5) && (aRecipe.mFluidOutputs[5] != null) && (aRecipe.mFluidOutputs[5].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[5], true), 138, 23, aRecipe.getOutputChance(tStartIndex++))); + } + if ((aRecipe.mFluidOutputs.length > 6) && (aRecipe.mFluidOutputs[6] != null) && (aRecipe.mFluidOutputs[6].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[6], true), 102, 41, aRecipe.getOutputChance(tStartIndex++))); + } + if ((aRecipe.mFluidOutputs.length > 7) && (aRecipe.mFluidOutputs[7] != null) && (aRecipe.mFluidOutputs[7].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[7], true), 120, 41, aRecipe.getOutputChance(tStartIndex++))); + } + if ((aRecipe.mFluidOutputs.length > 8) && (aRecipe.mFluidOutputs[8] != null) && (aRecipe.mFluidOutputs[8].getFluid() != null)) { + this.mOutputs.add(new FixedPositionedStack(GT_Utility.getFluidDisplayStack(aRecipe.mFluidOutputs[8], true), 138, 41, aRecipe.getOutputChance(tStartIndex++))); + } + Logger.INFO("Outputs: "+aRecipe.mFluidOutputs.length); + } + } + + @Override + public List<PositionedStack> getIngredients() { + return this.getCycledIngredients(GT_NEI_LFTR.this.cycleticks / 10, this.mInputs); + } + + @Override + public PositionedStack getResult() { + return null; + } + + @Override + public List<PositionedStack> getOtherStacks() { + return this.mOutputs; + } + } +} diff --git a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java index 07bd7ef46c..ce95074a64 100644 --- a/src/Java/gtPlusPlus/nei/NEI_GT_Config.java +++ b/src/Java/gtPlusPlus/nei/NEI_GT_Config.java @@ -19,6 +19,7 @@ implements IConfigureNEI { public synchronized void loadConfig() { mUniqueRecipeMapHandling.add(GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing.mUnlocalizedName); + mUniqueRecipeMapHandling.add(GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sChemicalPlantRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sOreMillRecipes.mUnlocalizedName); mUniqueRecipeMapHandling.add(GTPP_Recipe_Map.sFlotationCellRecipes.mUnlocalizedName); @@ -72,6 +73,8 @@ implements IConfigureNEI { new GT_NEI_VacFurnace(); Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sFissionFuelProcessing.mNEIName); new GT_NEI_RFPP(); + Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.mNEIName); + new GT_NEI_LFTR(); Logger.INFO("NEI Registration: Registering NEI handler for "+GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT.mNEIName); new GT_NEI_multiCentriElectroFreezer(GTPP_Recipe.GTPP_Recipe_Map.sAdvFreezerRecipes_GT); diff --git a/src/Java/gtPlusPlus/nei/NEI_IMC_Sender.java b/src/Java/gtPlusPlus/nei/NEI_IMC_Sender.java index 461678dd7a..16a8f9b677 100644 --- a/src/Java/gtPlusPlus/nei/NEI_IMC_Sender.java +++ b/src/Java/gtPlusPlus/nei/NEI_IMC_Sender.java @@ -20,7 +20,6 @@ public class NEI_IMC_Sender { setNBTInfoAndSendIt("gtpp.recipe.fissionfuel", "gregtech:gt.blockmachines:835"); setNBTInfoAndSendIt("gtpp.recipe.geothermalfuel", "gregtech:gt.blockmachines:830"); setNBTInfoAndSendIt("gtpp.recipe.lftr", "gregtech:gt.blockmachines:751"); - setNBTInfoAndSendIt("gtpp.recipe.lftr.2", "gregtech:gt.blockmachines:751"); setNBTInfoAndSendIt("gtpp.recipe.matterfab2", "gregtech:gt.blockmachines:799"); setNBTInfoAndSendIt("gtpp.recipe.multicentrifuge", "gregtech:gt.blockmachines:790"); setNBTInfoAndSendIt("gtpp.recipe.multielectro", "gregtech:gt.blockmachines:796"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index f623fe7405..a258c1ab4e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -55,6 +55,7 @@ import gtPlusPlus.xmod.gregtech.loaders.ProcessingElectricSnips; import gtPlusPlus.xmod.gregtech.loaders.ProcessingToolHeadChoocher; import gtPlusPlus.xmod.gregtech.loaders.misc.AddCustomMachineToPA; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; +import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_LFTR; import gtPlusPlus.xmod.gregtech.recipes.RecipesToRemove; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechNitroDieselFix; @@ -153,6 +154,7 @@ public class HANDLER_GT { convertPyroToCokeOven(); Meta_GT_Proxy.fixIC2FluidNames(); RecipeLoader_AlgaeFarm.generateRecipes(); + RecipeLoader_LFTR.generate(); } public static void addNewOrePrefixes() { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java index 61c2288321..3038fb4330 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java @@ -1,10 +1,17 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + import java.util.ArrayList; import java.util.Collection; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; + import gregtech.api.enums.Materials; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; @@ -12,34 +19,35 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GTPP_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.nuclear.FLUORIDES; -import gtPlusPlus.core.material.nuclear.NUCLIDE; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; - public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { - protected int fuelConsumption = 0; - protected int fuelValue = 0; + private static Fluid mHelium; + private static Fluid mFluorine; protected int fuelRemaining = 0; - protected boolean boostEu = false; - protected boolean heliumSparging = false; + private int mCasing; private IStructureDefinition<GregtechMTE_NuclearReactor> STRUCTURE_DEFINITION = null; @@ -63,30 +71,35 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { } @Override + public GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes; + } + + @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType(getMachineType()) - .addInfo("Controller Block for the Liquid Fluoride Thorium Reactor.") - .addInfo("Produces Heat & Energy from Radioactive Beta Decay.") - .addInfo("Outputs U233 every 10 seconds, on average") - .addInfo("Input Fluorine and Helium for bonus byproducts") - .addInfo("Input Li2BeF4 and a molten salt as fuel.") - .addInfo("LiFBeF2ThF4UF4, LiFBeF2ZrF4UF4 or LiFBeF2ZrF4U235") - .addPollutionAmount(getPollutionPerTick(null) * 20) - .addSeparator() - .beginStructureBlock(7, 4, 7, true) - .addController("Bottom Center") - .addCasingInfo("Hastelloy-N Reactor Casing", 27) - .addCasingInfo("Zeron-100 Reactor Shielding", 26) - .addInputHatch("Top or bottom layer edges", 1) - .addOutputHatch("Top or bottom layer edges", 1) - .addDynamoHatch("Top or bottom layer edges", 1) - .addMaintenanceHatch("Top or bottom layer edges", 1) - .addMufflerHatch("Top 3x3", 2) - .addStructureInfo("All hatches must have IV+ tier.") - .addStructureInfo("10+ Output Hatches, 4+ Input Hatches, 4x Dynamo Hatches") - .addStructureInfo("2x Maintenance Hatches, 4x Mufflers") - .toolTipFinisher("GT++"); + .addInfo("Controller Block for the Liquid Fluoride Thorium Reactor.") + .addInfo("Produces Heat & Energy from Radioactive Beta Decay.") + .addInfo("Outputs U233 every 10 seconds, on average") + .addInfo("Input Fluorine and Helium for bonus byproducts") + .addInfo("Input Li2BeF4 and a molten salt as fuel.") + .addInfo("LiFBeF2ThF4UF4, LiFBeF2ZrF4UF4 or LiFBeF2ZrF4U235") + .addPollutionAmount(getPollutionPerTick(null) * 20) + .addSeparator() + .beginStructureBlock(7, 4, 7, true) + .addController("Bottom Center") + .addCasingInfo("Hastelloy-N Reactor Casing", 27) + .addCasingInfo("Zeron-100 Reactor Shielding", 26) + .addInputHatch("Top or bottom layer edges", 1) + .addOutputHatch("Top or bottom layer edges", 1) + .addDynamoHatch("Top or bottom layer edges", 1) + .addMaintenanceHatch("Top or bottom layer edges", 1) + .addMufflerHatch("Top 3x3", 2) + .addStructureInfo("All hatches must have IV+ tier.") + .addStructureInfo("14+ Output Hatches, 4+ Input Hatches, 4x Dynamo Hatches") + .addStructureInfo("2x Maintenance Hatches, 4x Mufflers") + .toolTipFinisher("GT++"); return tt; } @@ -100,14 +113,10 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { tRunning, tMaintainance, "Current Output: "+this.mEUt+" EU/t", - "Fuel Consumption: "+this.fuelConsumption+"L/t", - "Fuel Value: "+this.fuelValue+" EU/L", "Fuel Remaining: "+this.fuelRemaining+" Litres", "Current Efficiency: "+(this.mEfficiency/5)+"%", "Current Efficiency (Raw): "+(this.mEfficiency), - "Boosted Output: "+this.boostEu+".", - "Boosted Output gives 4x EU/t for double fuel usage.", - "It requires you to have 100% Efficiency."}; + "It requires you to have 100% Efficiency."}; } @Override @@ -132,7 +141,7 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(13))}; } return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.GTPP_INDEX(12))}; - + } @Override @@ -185,52 +194,52 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { if (STRUCTURE_DEFINITION == null) { STRUCTURE_DEFINITION = StructureDefinition.<GregtechMTE_NuclearReactor>builder() .addShape(mName, transpose(new String[][]{ - {"CCCCCCC", "COOOOOC", "COXXXOC", "COXXXOC", "COXXXOC", "COOOOOC", "CCCCCCC"}, - {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, - {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, - {"CCC~CCC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "CCCCCCC"}, + {"CCCCCCC", "COOOOOC", "COXXXOC", "COXXXOC", "COXXXOC", "COOOOOC", "CCCCCCC"}, + {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, + {"GGGGGGG", "G-----G", "G-----G", "G-----G", "G-----G", "G-----G", "GGGGGGG"}, + {"CCC~CCC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "COOOOOC", "CCCCCCC"}, })) .addElement( 'C', ofChain( ofHatchAdder( GregtechMTE_NuclearReactor::addNuclearReactorEdgeList, TAE.GTPP_INDEX(12), 1 - ), + ), onElementPass( x -> ++x.mCasing, ofBlock( ModBlocks.blockCasingsMisc, 12 + ) ) ) ) - ) .addElement( 'X', ofChain( ofHatchAdder( GregtechMTE_NuclearReactor::addNuclearReactorTopList, TAE.GTPP_INDEX(12), 2 - ), + ), onElementPass( x -> ++x.mCasing, ofBlock( ModBlocks.blockCasingsMisc, 12 + ) ) ) - ) - ) + ) .addElement( 'O', ofBlock( ModBlocks.blockCasingsMisc, 12 + ) ) - ) .addElement( 'G', ofBlock( ModBlocks.blockCasingsMisc, 13 + ) ) - ) .build(); } return STRUCTURE_DEFINITION; @@ -245,23 +254,23 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasing = 0; if (checkPiece(mName, 3, 3, 0) && mCasing >= 27) { - if (mOutputHatches.size() >= 10 && mInputHatches.size() >= 4 && mDynamoHatches.size() == 4 && + if (mOutputHatches.size() >= 14 && mInputHatches.size() >= 4 && mDynamoHatches.size() == 4 && mMufflerHatches.size() == 4 && mMaintenanceHatches.size() == 2) { - this.mWrench = true; - this.mScrewdriver = true; - this.mSoftHammer = true; - this.mHardHammer = true; - this.mSolderingTool = true; - this.mCrowbar = true; - this.turnCasingActive(false); - return true; + this.mWrench = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mHardHammer = true; + this.mSolderingTool = true; + this.mCrowbar = true; + this.turnCasingActive(false); + return true; } } return false; } - // Alk's Life Lessons from Greg. - /* + // Alk's Life Lessons from Greg. + /* [23:41:15] <GregoriusTechneticies> xdir and zdir are x2 and not x3 [23:41:26] <GregoriusTechneticies> thats you issue [23:44:33] <Alkalus> mmm? @@ -276,7 +285,7 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { [23:45:51] <Alkalus> Ahh [23:45:57] <GregoriusTechneticies> and not 2 [23:46:06] <Alkalus> Noted, thanks :D - */ + */ @Override public boolean isCorrectMachinePart(final ItemStack aStack) { @@ -285,12 +294,12 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { @Override public int getMaxEfficiency(final ItemStack aStack) { - return this.boostEu ? 30000 : 10000; + return 10000; } @Override public int getPollutionPerTick(final ItemStack aStack) { - return this.boostEu ? 8 : 4; + return 10; } @Override @@ -308,10 +317,6 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { return new GregtechMTE_NuclearReactor(this.mName); } - public static int overclock(final int mStartEnergy) { - return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; - } - public boolean turnCasingActive(final boolean status) { //TODO if (this.mDynamoHatches != null) { @@ -342,155 +347,149 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { return true; } + public FluidStack[] getStoredFluidsAsArray() { + final ArrayList<FluidStack> tFluids = this.getStoredFluids(); + FluidStack[] aStored = new FluidStack[tFluids.size()]; + for (int i = 0; i < aStored.length; i++) { + aStored[i] = tFluids.get(i); + } + return aStored; + } + + public int getStoredFuel(GT_Recipe aRecipe) { + int aFuelStored = 0; + FluidStack aFuelFluid = null; + for (FluidStack aFluidInput : aRecipe.mFluidInputs) { + if (!aFluidInput.getFluid().equals(ModItems.fluidFLiBeSalt)) { + aFuelFluid = aFluidInput; + break; + } + } + if (aFuelFluid != null) { + for (GT_MetaTileEntity_Hatch_Input aInputHatch : this.mInputHatches) { + if (aInputHatch.getFluid() != null && aInputHatch.getFluidAmount() > 0) { + if (aInputHatch.getFluid().isFluidEqual(aFuelFluid)) { + aFuelStored += aInputHatch.getFluidAmount(); + } + } + } + } + return aFuelStored; + } + @Override public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<FluidStack> tFluids = this.getStoredFluids(); - final Collection<GT_Recipe> tRecipeList = GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.mRecipeList; - if((tFluids.size() > 0) && (tRecipeList != null)) { //Does input hatch have a LFTR fuel? - Logger.WARNING("Found more than one input fluid and a list of valid recipes."); + // Warm up for 4~ minutes + Logger.INFO("Checking LFTR recipes."); + if (mEfficiency < this.getMaxEfficiency(null)) { + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 20; + Logger.INFO("Warming Up! "+this.mEfficiency+"/"+this.getMaxEfficiency(null)); + return true; + } + Logger.INFO("Warmed up, checking LFTR recipes."); + if (mHelium == null) { + mHelium = Materials.Helium.getGas(1).getFluid(); + Logger.INFO("Set Helium."); + } + if (mFluorine == null) { + Logger.INFO("Set Fluorine."); + mFluorine = Materials.Fluorine.getGas(1).getFluid(); + } + final FluidStack[] tFluids = getStoredFluidsAsArray(); + final Collection<GT_Recipe> tRecipeList = getRecipeMap().mRecipeList; + if(tFluids.length > 0 && tRecipeList != null && tRecipeList.size() > 0) { //Does input hatch have a LFTR fuel? + Logger.INFO("Found more than one input fluid and a list of valid recipes."); + boolean foundLi2bef4 = false; + FluidStack aHeliumSparge = null; + FluidStack aFluorineSparge = null; + // Find a valid recipe + GT_Recipe aFuelProcessing = this.findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, 0, tFluids, new ItemStack[] {}); + if (aFuelProcessing == null) { + Logger.INFO("Did not find valid recipe for given inputs."); + return false; + } + else { + Logger.INFO("Found recipe? "+(aFuelProcessing != null ? "true" : "false")); + for (FluidStack aFluidInput : aFuelProcessing.mFluidInputs) { + Logger.INFO("Using "+aFluidInput.getLocalizedName()); + } + } + // Find li2bef4, Helium & Fluorine for (final FluidStack hatchFluid1 : tFluids) { //Loops through hatches - Logger.WARNING("Looping through Input hatches - Found "+hatchFluid1.getLocalizedName()); - for(final GT_Recipe aFuel : tRecipeList) { //Loops through LFTR fuel recipes - Logger.WARNING("Looping through Recipes. "+aFuel.mSpecialValue); - FluidStack tLiquid; - final FluidStack testStack = aFuel.mFluidInputs[1]; - if ((tLiquid = testStack) != null) { //Create fluidstack from current recipe - Logger.WARNING("Creating a fluidstack from the current recipe. "+testStack.getLocalizedName()); - if (hatchFluid1.isFluidEqual(tLiquid)) { //Has a LFTR fluid - this.fuelConsumption = this.boostEu ? (aFuel.mSpecialValue/4096) : (aFuel.mSpecialValue/2048); //Calc fuel consumption - - this.mMaxProgresstime = 500; - - if(tFluids.contains(NUCLIDE.LiFBeF2ThF4UF4.getFluid(1)) || - tFluids.contains(NUCLIDE.LiFBeF2ZrF4UF4.getFluid(2)) || - tFluids.contains(NUCLIDE.LiFBeF2ZrF4U235.getFluid(10))) { //Has a Primary fuel salt? - //Deplete Primary Salt. 1000L should = 1 hour of runtime (if baseEU = 2048) && using 1l each time - if(((this.mRuntime % 72) == 0) || (this.mRuntime == 0)){ - //U235 fuel is 10x less efficient than UF4 with Thorium, UF4 with Zirconium is only 2x less efficient than UF4 with Thorium. - //Most Efficient - if(tFluids.contains(NUCLIDE.LiFBeF2ThF4UF4.getFluid(2))){ - - FluidStack depletionStack = FluidUtils.getFluidStack(tLiquid, (this.boostEu ? (aFuel.mSpecialValue/4096) : (aFuel.mSpecialValue/2048))); - Logger.WARNING("Input hatch contains some FLiBe Fuel, using "+this.fuelConsumption+" | "+aFuel.mSpecialValue+" | "+depletionStack.amount); - if(this.depleteInput(depletionStack)) { //Deplete that amount - Logger.WARNING("Depleted some FLiBe fluid"); - } - - this.depleteInput(NUCLIDE.LiFBeF2ThF4UF4.getFluid(this.boostEu ? 2 : 1)); - Logger.WARNING("Depleted "+(this.boostEu ? 2 : 1)+"L of LiFBeF2ThF4UF4 fluid"); - } - //1/2 as Efficient - if (tFluids.contains(NUCLIDE.LiFBeF2ZrF4UF4.getFluid(4))){ - - FluidStack depletionStack = FluidUtils.getFluidStack(tLiquid, (this.boostEu ? (aFuel.mSpecialValue/4096) : (aFuel.mSpecialValue/2048))); - Logger.WARNING("Input hatch contains some FLiBe Fuel, using "+this.fuelConsumption+" | "+aFuel.mSpecialValue+" | "+depletionStack.amount); - if(this.depleteInput(depletionStack)) { //Deplete that amount - Logger.WARNING("Depleted some FLiBe fluid"); - } - - this.depleteInput(NUCLIDE.LiFBeF2ZrF4UF4.getFluid(this.boostEu ? 4 : 2)); - Logger.WARNING("Depleted "+(this.boostEu ? 4 : 2)+"L of LiFBeF2ZrF4UF4 fluid"); - } - //10x less Efficient. - if (tFluids.contains(NUCLIDE.LiFBeF2ZrF4U235.getFluid(20))) { - - FluidStack depletionStack = FluidUtils.getFluidStack(tLiquid, (this.boostEu ? (aFuel.mSpecialValue/4096) : (aFuel.mSpecialValue/2048))); - Logger.WARNING("Input hatch contains some FLiBe Fuel, using "+this.fuelConsumption+" | "+aFuel.mSpecialValue+" | "+depletionStack.amount); - if(this.depleteInput(depletionStack)) { //Deplete that amount - Logger.WARNING("Depleted some FLiBe fluid"); - } - - this.depleteInput(NUCLIDE.LiFBeF2ZrF4U235.getFluid(this.boostEu ? 20 : 10)); - Logger.WARNING("Depleted "+(this.boostEu ? 20 : 10)+"L of LiFBeF2ZrF4U235 fluid"); - } - } - } else { - return false; - } - - - if (this.getBaseMetaTileEntity().getWorld().getTotalWorldTime() % 100 == 0) { - //Try Sparge Noble Gases - if (this.heliumSparging){ - if (this.depleteInput(Materials.Helium.getGas(1000L))){ - //Make an empty fluid stack for possible sparging output - FluidStack[] spargeOutput = new FluidStack[]{}; - Logger.WARNING("Doing a Sparge with Helium - "+this.heliumSparging); - this.heliumSparging = false; - spargeOutput = this.getByproductsOfSparge(Materials.Helium.getGas(1000L)); - - //If Sparging occurred, try add the outputs to the output hatches. - try { - if (spargeOutput.length >= 1){ - for (final FluidStack F : spargeOutput){ - Logger.WARNING("Adding Sparge Output - "+F.getLocalizedName()); - this.addOutput(F); - } - } - } catch (final Throwable T){} - } - } - //Try Sparge Fluorides - else { - if (this.depleteInput(Materials.Fluorine.getGas(100L))){ - //Make an empty fluid stack for possible sparging output - FluidStack[] spargeOutput = new FluidStack[]{}; - Logger.WARNING("Doing a Sparge with Fluorine"); - spargeOutput = this.getByproductsOfSparge(Materials.Fluorine.getGas(100L)); - this.heliumSparging = true; - //If Sparging occurred, try add the outputs to the output hatches. - if (spargeOutput.length > 0){ - for (final FluidStack F : spargeOutput){ - Logger.WARNING("Adding Sparge Output - "+F.getLocalizedName()); - this.addOutput(F); - } - } - } - } - } - - - if (aFuel != null){ - //Utils.LOG_WARNING("Saving previous Recipe."); - //this.mLastRecipe = aFuel; - } - - this.fuelValue = aFuel.mSpecialValue; - this.fuelRemaining = hatchFluid1.amount; //Record available fuel - - if (this.mEfficiency < 500){ - this.mEfficiency++; - this.mMaxProgresstime = 500; - } - else if (this.mEfficiency == 500) { - this.mMaxProgresstime = 300; - } - else if (this.mEfficiency > 500){ - this.mEfficiency = 500; - } - Logger.WARNING("Efficiency == "+this.mEfficiency); - - this.mEUt = (this.mEfficiency < 500 ? 2048 : (8196)); //Output 0 if startup is less than 20% - Logger.WARNING("Generating "+this.mEUt+"EU/t @ an efficiency level of "+this.mEfficiency); - - this.mProgresstime = 1; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 15; - - //Best output some Fluids - //this.mOutputFluids = this.mLastRecipe.mFluidOutputs; - - return true; - } - } + if (hatchFluid1 != null) { + if (hatchFluid1.getFluid().equals(ModItems.fluidFLiBeSalt)){ + foundLi2bef4 = true; + Logger.INFO("Found "+hatchFluid1.getLocalizedName()); + continue; + } + else if (hatchFluid1.getFluid().equals(mHelium) && hatchFluid1.amount >= 1000){ + aHeliumSparge = hatchFluid1; + Logger.INFO("Found "+hatchFluid1.getLocalizedName()); + continue; } - } + else if (hatchFluid1.getFluid().equals(mFluorine) && hatchFluid1.amount >= 100){ + aFluorineSparge = hatchFluid1; + Logger.INFO("Found "+hatchFluid1.getLocalizedName()); + continue; + } + } + } + if (!foundLi2bef4) { + Logger.INFO("Did not find "+ModItems.fluidFLiBeSalt.getLocalizedName()); + return false; + } + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + this.mLastRecipe = aFuelProcessing; + boolean aValidOutputSpace = this.canBufferOutputs(aFuelProcessing, 1) > 0; + if (!aValidOutputSpace) { + Logger.INFO("Not enough space to output fluids."); + return false; + } + // Deplete Inputs + if (aFuelProcessing.mFluidInputs.length > 0) { + for (FluidStack aInputToConsume : aFuelProcessing.mFluidInputs) { + Logger.INFO("Depleting "+aInputToConsume.getLocalizedName()+" - "+aInputToConsume.amount+"L"); + this.depleteInput(aInputToConsume); + } + } + // -- Try not to fail after this point - inputs have already been consumed! -- + this.mMaxProgresstime = (int)(aFuelProcessing.mDuration); + this.mEUt = aFuelProcessing.mSpecialValue * 4; + Logger.INFO("Outputting "+this.mEUt+"eu/t"); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + Logger.INFO("Recipe time: "+this.mMaxProgresstime); + fuelRemaining = getStoredFuel(aFuelProcessing); //Record available fuel + if (aHeliumSparge != null) { + Logger.INFO("Sparging Helium."); + FluidStack[] aSpargeOutputs = getByproductsOfSparge(aHeliumSparge); + for (FluidStack aSparge : aSpargeOutputs) { + this.addOutput(aSparge); + } + } + if (aFluorineSparge != null) { + Logger.INFO("Sparging Fluorine."); + FluidStack[] aSpargeOutputs = getByproductsOfSparge(aFluorineSparge); + for (FluidStack aSparge : aSpargeOutputs) { + this.addOutput(aSparge); + } + } + Logger.INFO("Recipe Good!"); + return true; } this.mEUt = 0; this.mEfficiency = 0; + Logger.INFO("Recipe Bad!"); return false; } - + @Override public int getMaxParallelRecipes() { return 1; @@ -547,9 +546,12 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { protected FluidStack[] getByproductsOfSparge(final FluidStack spargeGas){ + FluidStack depletionStack = spargeGas.copy(); FluidStack[] outputArrayOfGases = new FluidStack[]{}; if (spargeGas != null){ - if (spargeGas.isFluidEqual(Materials.Helium.getGas(1000))){ + if (spargeGas.getFluid().equals(mHelium)){ + depletionStack.amount = 1000; + this.depleteInput(depletionStack); final int outputChances[] = { MathUtils.roundToClosestInt(MathUtils.randInt(10, 1000)/10), MathUtils.roundToClosestInt(MathUtils.randInt(10, 600)/10), @@ -558,7 +560,7 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { MathUtils.roundToClosestInt(MathUtils.randInt(10, 100)/10) }; final int heliumContent = (1000-outputChances[0]-outputChances[1]-outputChances[2]-outputChances[3]-outputChances[4]); - Logger.WARNING("Helium remaining: "+heliumContent); + Logger.INFO("Helium remaining: "+heliumContent); outputArrayOfGases = new FluidStack[]{ ELEMENT.getInstance().XENON.getFluid(outputChances[0]), ELEMENT.getInstance().NEON.getFluid(outputChances[1]), @@ -568,7 +570,9 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { Materials.Helium.getGas(heliumContent) }; } - else if (spargeGas.isFluidEqual(Materials.Fluorine.getGas(100))){ + else if (spargeGas.getFluid().equals(mFluorine)){ + depletionStack.amount = 100; + this.depleteInput(depletionStack); final int outputChances[] = { MathUtils.roundToClosestInt(MathUtils.randDouble(10, 100)), MathUtils.roundToClosestInt(MathUtils.randDouble(1, 50)/10), @@ -576,7 +580,7 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { MathUtils.roundToClosestInt(MathUtils.randDouble(1, 50)/10) }; final int fluorineContent = (100-outputChances[0]-outputChances[1]-outputChances[2]-outputChances[3]); - Logger.WARNING("Fluorine remaining: "+fluorineContent); + Logger.INFO("Fluorine remaining: "+fluorineContent); outputArrayOfGases = new FluidStack[]{ FLUORIDES.LITHIUM_FLUORIDE.getFluid(outputChances[0]), FLUORIDES.NEPTUNIUM_HEXAFLUORIDE.getFluid(outputChances[1]), @@ -593,33 +597,30 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase { public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { //Add Power if active if (aBaseMetaTileEntity.isActive()){ - //this.getBaseMetaTileEntity().increaseStoredEnergyUnits(this.mEUt, false); - - if (this.mEfficiency >= 500){ - this.boostEu = true; + if (this.mEfficiency == this.getMaxEfficiency(null)){ this.turnCasingActive(true); } else { - this.boostEu = false; this.turnCasingActive(false); } - + if (MathUtils.randInt(1, 200) == 1){ - //Utils.LOG_INFO("Adding U233"); this.addOutput(ELEMENT.getInstance().URANIUM233.getFluid(MathUtils.randInt(1, 10))); } - - if (this.mDynamoHatches != null) { + + /*if (this.mDynamoHatches != null) { + int hatchNo = 0; for (GT_MetaTileEntity_Hatch_Dynamo tHatch : this.mDynamoHatches) { if (tHatch.mTier >= 5){ + hatchNo++; if (isValidMetaTileEntity(tHatch)){ tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(this.mEUt, false); - //Utils.LOG_WARNING("Adding "+this.mEUt+"eu to internal storage of dynamo "+hatchNo+"."); + Logger.INFO("Adding "+this.mEUt+"eu to internal storage of dynamo "+hatchNo+"."); } } } - } - + }*/ + } else { this.turnCasingActive(false); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_LFTR.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_LFTR.java index 424c2ecce5..af692c8bbf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_LFTR.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/recipe/RecipeLoader_LFTR.java @@ -1,25 +1,16 @@ package gtPlusPlus.xmod.gregtech.loaders.recipe; -import java.util.Collection; - -import net.minecraft.item.ItemStack; - -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GTPP_Recipe; - -import gtPlusPlus.api.objects.minecraft.NoConflictGTRecipeMap; -import gtPlusPlus.core.recipe.common.CI; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.chemistry.NuclearChem; +import gtPlusPlus.core.material.nuclear.NUCLIDE; import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -public class RecipeLoader_LFTR { - - - protected final static NoConflictGTRecipeMap mRecipesLFTR = new NoConflictGTRecipeMap(); - - public static Collection<GT_Recipe> getRecipes(){ - return mRecipesLFTR.getRecipeMap(); - } +public class RecipeLoader_LFTR { public static void generate() { // Fli2BeF4 + Thorium TetraFluoride = Uranium233 @@ -28,70 +19,75 @@ public class RecipeLoader_LFTR { //1l/40t = 1000l/10hr (Probably better) LiFBeF2ThF4UF4 //1l/20t= 1000l/2.5hr LiFBeF2ZrF4UF4 //1l/10t= 1000l/2.5hr LiFBeF2ZrF4U235 + + FluidStack Li2BeF4 = new FluidStack(ModItems.fluidFLiBeSalt, 34); //LiFBeF2ThF4UF4 GT_Recipe LFTR1 = new GTPP_Recipe( true, - new ItemStack[] {CI.getNumberedCircuit(1)}, new ItemStack[] {}, - null, new int[] {5000, 2500}, + new ItemStack[] {}, + null, new int[] {10000, 5000, 2500}, new FluidStack[] { - FluidUtils.getFluidStack("molten.li2bef4", 34), - FluidUtils.getFluidStack("molten.LiFBeF2ThF4UF4".toLowerCase(), 17) + NUCLIDE.LiFBeF2ThF4UF4.getFluid(17), + Li2BeF4 }, new FluidStack[] { + new FluidStack(NuclearChem.Burnt_LiFBeF2ThF4UF4, 17), FluidUtils.getFluidStack("molten.uraniumhexafluoride", 10), FluidUtils.getFluidStack("molten.uraniumhexafluoride", 5) }, 12000,//time 0,//cost - 4096//fuel value + 8192//fuel value ); //LiFBeF2ZrF4UF4 GT_Recipe LFTR2 = new GTPP_Recipe( true, - new ItemStack[] {CI.getNumberedCircuit(2)}, new ItemStack[] {}, - null, new int[] {2500, 1250}, + new ItemStack[] {}, + null, new int[] {10000, 2500, 1250}, new FluidStack[] { - FluidUtils.getFluidStack("molten.li2bef4", 34), - FluidUtils.getFluidStack("molten.LiFBeF2ZrF4UF4".toLowerCase(), 17) + NUCLIDE.LiFBeF2ZrF4UF4.getFluid(17), + Li2BeF4 }, new FluidStack[] { + new FluidStack(NuclearChem.Burnt_LiFBeF2ZrF4UF4, 17), FluidUtils.getFluidStack("molten.uraniumhexafluoride", 4), FluidUtils.getFluidStack("molten.uraniumhexafluoride", 2) }, 6000,//time 0,//cost - 4096//fuel value + 8192//fuel value ); //LiFBeF2ZrF4U235 GT_Recipe LFTR3 = new GTPP_Recipe( true, - new ItemStack[] {CI.getNumberedCircuit(3)}, new ItemStack[] {}, - null, new int[] {1000, 500}, + new ItemStack[] {}, + null, new int[] {10000, 1000, 500}, new FluidStack[] { - FluidUtils.getFluidStack("molten.li2bef4", 34), - FluidUtils.getFluidStack("molten.LiFBeF2ZrF4U235".toLowerCase(), 17) + NUCLIDE.LiFBeF2ZrF4U235.getFluid(17), + Li2BeF4 }, new FluidStack[] { + new FluidStack(NuclearChem.Burnt_LiFBeF2ZrF4U235, 17), FluidUtils.getFluidStack("molten.uraniumhexafluoride", 2), FluidUtils.getFluidStack("molten.uraniumhexafluoride", 1) }, 3000,//time 0,//cost - 4096//fuel value + 8192//fuel value ); /*mRecipesLFTR.add(LFTR1); mRecipesLFTR.add(LFTR2); mRecipesLFTR.add(LFTR3);*/ - GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipesEx.add(LFTR1); - GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipesEx.add(LFTR2); - GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipesEx.add(LFTR3); + GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.add(LFTR1); + GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.add(LFTR2); + GTPP_Recipe.GTPP_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.add(LFTR3); } |