diff options
Diffstat (limited to 'src/main/java')
5 files changed, 58 insertions, 43 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java index 477e52d103..12878b6a04 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java @@ -42,7 +42,7 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { * While a logical client don't really need to process fluid cells upon click (it could have just wait * for server side to send the result), doing so would result in every fluid interaction having a * noticeable delay between clicking and changes happening even on single player. - * I'd imagine this delay to get only more severe when playing MP over ethernet, which would have much more latency + * I'd imagine this lag to become only more severe when playing MP over ethernet, which would have much more latency * than a memory connection */ GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); @@ -55,18 +55,6 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - /** - * Expected to be called on client side only. Load fluid stacks from fluid display items as they were not sent - * over the network. - * Override this if you have more than one fluid display stack. This implementation will set drainable stack according to items - * in slot indexed 2. - * - */ - protected void syncFluidFromFluidDisplayItems() { - GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); - tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(tTank.getStackInSlot(2))); - } - protected static ItemStack handleFluidSlotClick(IFluidAccess aFluidAccess, EntityPlayer aPlayer, boolean aProcessFullStack, boolean aCanDrain, boolean aCanFill) { ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); @@ -95,37 +83,35 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { // cannot take AND cannot fill, why make this call then? return null; // the slot does not allow filling, so try take some - return drainFluid(aFluidAccess.get(), aPlayer, aProcessFullStack); + return drainFluid(aFluidAccess, aPlayer, aProcessFullStack); } else { // cannot fill and there is something to take if (!aCanDrain) // but the slot does not allow taking, so bail out return null; - ItemStack tResultStack = drainFluid(tInputFluid, aPlayer, aProcessFullStack); - if (tInputFluid.amount == 0) - aFluidAccess.set(null); - return tResultStack; + return drainFluid(aFluidAccess, aPlayer, aProcessFullStack); } } - protected static ItemStack drainFluid(FluidStack aTankStack, EntityPlayer aPlayer, boolean aProcessFullStack) { - if (aTankStack == null) return null; + protected static ItemStack drainFluid(IFluidAccess aFluidAccess, EntityPlayer aPlayer, boolean aProcessFullStack) { + FluidStack tTankStack = aFluidAccess.get(); + if (tTankStack == null) return null; ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; - int tOriginalFluidAmount = aTankStack.amount; - ItemStack tFilled = GT_Utility.fillFluidContainer(aTankStack, tStackSizedOne, true, false); - if (tFilled == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + int tOriginalFluidAmount = tTankStack.amount; + ItemStack tFilledContainer = GT_Utility.fillFluidContainer(tTankStack, tStackSizedOne, true, false); + if (tFilledContainer == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem(); - int tFilledAmount = tContainerItem.fill(tStackSizedOne, aTankStack, true); + int tFilledAmount = tContainerItem.fill(tStackSizedOne, tTankStack, true); if (tFilledAmount > 0) { - tFilled = tStackSizedOne; - aTankStack.amount -= tFilledAmount; + tFilledContainer = tStackSizedOne; + tTankStack.amount -= tFilledAmount; } } - if (tFilled != null) { + if (tFilledContainer != null) { if (aProcessFullStack) { - int tFilledAmount = tOriginalFluidAmount - aTankStack.amount; + int tFilledAmount = tOriginalFluidAmount - tTankStack.amount; /* work out how many more items we can fill one cell is already used, so account for that @@ -133,13 +119,15 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { the user then get to decide what to do with it it will not be too fancy if it spills out partially filled cells */ - int tAdditionalParallel = Math.min(tStackHeld.stackSize - 1, aTankStack.amount / tFilledAmount); - aTankStack.amount -= tFilledAmount * tAdditionalParallel; - tFilled.stackSize += tAdditionalParallel; + int tAdditionalParallel = Math.min(tStackHeld.stackSize - 1, tTankStack.amount / tFilledAmount); + tTankStack.amount -= tFilledAmount * tAdditionalParallel; + tFilledContainer.stackSize += tAdditionalParallel; } - replaceCursorItemStack(aPlayer, tFilled); + replaceCursorItemStack(aPlayer, tFilledContainer); } - return tFilled; + if (tTankStack.amount <= 0) + aFluidAccess.set(null); + return tFilledContainer; } protected static ItemStack fillFluid(IFluidAccess aFluidAccess, EntityPlayer aPlayer, FluidStack aFluidHeld, boolean aProcessFullStack) { diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index cc224b977d..4b4c01345a 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -65,7 +65,7 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { } public static void initExecutorService() { - EXECUTOR_SERVICE = Executors.newFixedThreadPool((Runtime.getRuntime().availableProcessors() * 2 / 3), THREAD_FACTORY); + EXECUTOR_SERVICE = Executors.newFixedThreadPool(Math.max(1, (Runtime.getRuntime().availableProcessors() * 2 / 3)), THREAD_FACTORY); } public static void shutdownExecutorService() { diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 4059c6cd92..f941a86f5c 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -613,7 +613,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static final GT_Recipe_Map sChemicalRecipes = new GT_Recipe_Map(new HashSet<>(1170), "gt.recipe.chemicalreactor", "Chemical Reactor", null, RES_PATH_GUI + "basicmachines/ChemicalReactor", 2, 2, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sMultiblockChemicalRecipes = new GT_Recipe_Map_LargeChemicalReactor(); public static final GT_Recipe_Map sDistillationRecipes = new GT_Recipe_Map_DistillationTower(); - public static final GT_Recipe_Map sCrakingRecipes = new GT_Recipe_Map(new HashSet<>(70), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/OilCracker", 1, 1, 1, 2, 1, E, 1, E, true, true); + public static final GT_Recipe_Map_OilCracker sCrackingRecipes = new GT_Recipe_Map_OilCracker(); + /** + * Use sCrackingRecipes instead + */ + @Deprecated + public static final GT_Recipe_Map sCrakingRecipes = sCrackingRecipes; public static final GT_Recipe_Map sPyrolyseRecipes = new GT_Recipe_Map(new HashSet<>(150), "gt.recipe.pyro", "Pyrolyse Oven", null, RES_PATH_GUI + "basicmachines/Default", 2, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sWiremillRecipes = new GT_Recipe_Map(new HashSet<>(450), "gt.recipe.wiremill", "Wiremill", null, RES_PATH_GUI + "basicmachines/Wiremill", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sBenderRecipes = new GT_Recipe_Map(new HashSet<>(5000), "gt.recipe.metalbender", "Bending Machine", null, RES_PATH_GUI + "basicmachines/Bender", 2, 1, 2, 0, 1, E, 1, E, true, true); @@ -1840,6 +1845,26 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } } + public static class GT_Recipe_Map_OilCracker extends GT_Recipe_Map { + private final Set<String> mValidCatalystFluidNames = new HashSet<>(); + public GT_Recipe_Map_OilCracker() { + super(new HashSet<>(70), "gt.recipe.craker", "Oil Cracker", null, RES_PATH_GUI + "basicmachines/OilCracker", 1, 1, 1, 2, 1, E, 1, E, true, true); + } + + @Override + public GT_Recipe add(GT_Recipe aRecipe) { + GT_Recipe ret = super.add(aRecipe); + if (ret != null && ret.mFluidInputs != null && ret.mFluidInputs.length>1 && ret.mFluidInputs[1] != null) { + mValidCatalystFluidNames.add(ret.mFluidInputs[1].getFluid().getName()); + } + return ret; + } + + public boolean isValidCatalystFluid(FluidStack aFluidStack) { + return mValidCatalystFluidNames.contains(aFluidStack.getFluid().getName()); + } + } + public static class GT_Recipe_WithAlt extends GT_Recipe { ItemStack[][] mOreDictAlt; diff --git a/src/main/java/gregtech/common/GT_RecipeAdder.java b/src/main/java/gregtech/common/GT_RecipeAdder.java index 0e421843a9..0799606f50 100644 --- a/src/main/java/gregtech/common/GT_RecipeAdder.java +++ b/src/main/java/gregtech/common/GT_RecipeAdder.java @@ -453,7 +453,7 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { boolean ret = false; for (int oreID : OreDictionary.getOreIDs(aOutput1)) { - if (OreDictionary.getOreName(oreID).contains("circuit")){ + if (OreDictionary.getOreName(oreID).startsWith("circuit")){ return this.addAssemblerRecipeNonOD(aInputs, aFluidInput, aOutput1, aDuration, aEUt, aCleanroom); } } @@ -465,7 +465,7 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { } for (int oreID : OreDictionary.getOreIDs(aInputs[i])) { String odName = OreDictionary.getOreName(oreID); - if (odName.contains("circuit")) { + if (odName.startsWith("circuit")) { for (ItemStack tStack : GT_OreDictUnificator.getOresImmutable(odName)) { if (!GT_Utility.isStackValid(tStack)) continue; @@ -1383,7 +1383,7 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { boolean ret = false; for (int oreID : OreDictionary.getOreIDs(aOutput)) { - if (OreDictionary.getOreName(oreID).contains("circuit")){ + if (OreDictionary.getOreName(oreID).startsWith("circuit")){ return this.addCircuitAssemblerRecipeNonOredicted(aInputs, aFluidInput, aOutput, aDuration, aEUt, aCleanroom); } } @@ -1391,7 +1391,7 @@ public class GT_RecipeAdder implements IGT_RecipeAdder { for (int i = 0; i < aInputs.length; ++i) { for (int oreID : OreDictionary.getOreIDs(aInputs[i])) { String odName = OreDictionary.getOreName(oreID); - if (odName.contains("circuit")) { + if (odName.startsWith("circuit")) { for (ItemStack tStack : GT_OreDictUnificator.getOresImmutable(odName)) { if (!GT_Utility.isStackValid(tStack)) continue; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index a90e1948d0..b9ade288c1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -20,6 +20,7 @@ import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; @@ -126,7 +127,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCrakingRecipes; + return GT_Recipe.GT_Recipe_Map.sCrackingRecipes; } @Override @@ -140,7 +141,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], - tFluidInputs , + tFluidInputs, mInventory[1] ); @@ -327,14 +328,15 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { - rList.add(tHatch.getFillableStack()); + if (!GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tHatch.getFillableStack())) + rList.add(tHatch.getFillableStack()); } } for (GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { FluidStack tStack = tHatch.getFillableStack(); - if (tStack.isFluidEqual(GT_ModHandler.getSteam(1000)) || tStack.isFluidEqual(Materials.Hydrogen.getGas(1000))) { + if (GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tStack)) { rList.add(tStack); } } |