diff options
Diffstat (limited to 'src/main')
4 files changed, 123 insertions, 57 deletions
diff --git a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java index f4b28ede2b..2388a92cd3 100644 --- a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java +++ b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java @@ -50,14 +50,14 @@ public enum HeatingCoilLevel { * @return the coil Level, used for Parallels in the Multi Furnace for example */ public byte getLevel() { - return (byte) Math.min(16, 2 << (this.ordinal() - 2)); + return (byte) (1 << Math.min(Math.max(0, this.ordinal() - 2), 4)); } /** * @return the coil Discount, used for discount in the Multi Furnace for example */ - public byte getCostDiscount() { - return (byte) Math.max(1, 2 << (this.ordinal() - 1 - 6)); //-1 bcs. of none, -4 = offset + public int getCostDiscount() { + return 1 << Math.max(0, this.ordinal() - 5); } public static HeatingCoilLevel getFromTier(byte tier){ diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index da528d67fc..38f8bd3b35 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -12,9 +12,7 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -import net.minecraftforge.fluids.IFluidTank; -import static gregtech.api.enums.GT_Values.NI; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT; /** @@ -198,29 +196,33 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { machine.mItemTransfer = !machine.mItemTransfer; return null; case 2: - tResultStack = pickupFluid(machine.getDrainableStack(), aPlayer); - if (machine.getDrainableStack().amount == 0) + if (aMouseclick > 1) + return null; + tResultStack = pickupFluid(machine.getDrainableStack(), aPlayer, aMouseclick == 0); + if (machine.getDrainableStack() != null && machine.getDrainableStack().amount == 0) machine.setDrainableStack(null); return tResultStack; default: if (aSlotIndex == OTHER_SLOT_COUNT + 1 + machine.mInputSlotCount + machine.mOutputItems.length) { + if (aMouseclick > 1) + return null; // input fluid slot ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null) return null; + if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; FluidStack tInputFluid = machine.getFillableStack(); FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackSizedOne, true); if (tInputFluid == null) { if (tFluidHeld == null) // both null -> no op return null; - return fillFluid(machine, aPlayer, tFluidHeld); + return fillFluid(machine, aPlayer, tFluidHeld, aMouseclick == 0); } else { if (tFluidHeld != null) { // both nonnull. actually both pickup and fill is reasonable, but I'll go with fill here - return fillFluid(machine, aPlayer, tFluidHeld); + return fillFluid(machine, aPlayer, tFluidHeld, aMouseclick == 0); } else { - tResultStack = pickupFluid(tInputFluid, aPlayer); + tResultStack = pickupFluid(tInputFluid, aPlayer, aMouseclick == 0); if (tInputFluid.amount == 0) machine.setFillableStack(null); return tResultStack; @@ -232,11 +234,12 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } } - private ItemStack pickupFluid(FluidStack aTankStack, EntityPlayer aPlayer) { + private ItemStack pickupFluid(FluidStack aTankStack, EntityPlayer aPlayer, boolean aProcessFullStack) { if (aTankStack == null) return null; ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null) return null; + 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) { IFluidContainerItem tContainerItem = (IFluidContainerItem) tStackSizedOne.getItem(); @@ -247,47 +250,94 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } } if (tFilled != null) { - reduceStackSizeInHandByOne(aPlayer); - GT_Utility.addItemToPlayerInventory(aPlayer, tFilled); + if (aProcessFullStack) { + int tFilledAmount = tOriginalFluidAmount - aTankStack.amount; + /* + work out how many more items we can fill + one cell is already used, so account for that + the round down behavior will left over a fraction of a cell worth of fluid + 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; + } + replaceCursorItemStack(aPlayer, tFilled); } return tFilled; } - private ItemStack fillFluid(IFluidTank aTank, EntityPlayer aPlayer, FluidStack aFluidHeld) { + private ItemStack fillFluid(GT_MetaTileEntity_BasicMachine aMachine, EntityPlayer aPlayer, FluidStack aFluidHeld, boolean aProcessFullStack) { + // we are not using aMachine.fill() here any more, so we need to check for fluid type here ourselves + if (aMachine.getFillableStack() != null && !aMachine.getFillableStack().isFluidEqual(aFluidHeld)) + return null; ItemStack tStackHeld = aPlayer.inventory.getItemStack(); ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); if (tStackSizedOne == null) return null; - int tFilled = aTank.fill(aFluidHeld, false); - if (tFilled == 0) // filled nothing + int tFreeSpace = aMachine.getCapacity() - (aMachine.getFillableStack() != null ? aMachine.getFillableStack().amount : 0); + if (tFreeSpace <= 0) + // no space left return null; + + // find out how much fluid can be taken + // some cells cannot be partially filled ItemStack tStackEmptied = null; - if (tFilled == aFluidHeld.amount) + int tAmountTaken = 0; + if (tFreeSpace >= aFluidHeld.amount) { // fully accepted - try take it from item now // IFluidContainerItem is intentionally not checked here. it will be checked later tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); - if (tStackEmptied == null && tStackHeld.getItem() instanceof IFluidContainerItem) { - IFluidContainerItem container = (IFluidContainerItem) tStackHeld.getItem(); - FluidStack tDrained = container.drain(tStackSizedOne, tFilled, true); - if (tDrained != null && tDrained.amount > 0) + tAmountTaken = aFluidHeld.amount; + } + if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem) { + // either partially accepted, or is IFluidContainerItem + IFluidContainerItem container = (IFluidContainerItem) tStackSizedOne.getItem(); + FluidStack tDrained = container.drain(tStackSizedOne, tFreeSpace, true); + if (tDrained != null && tDrained.amount > 0) { // something is actually drained - change the cell and drop it to player tStackEmptied = tStackSizedOne; + tAmountTaken = tDrained.amount; + } } if (tStackEmptied == null) - // somehow the cell refuse to take that amount of fluid, no op then + // somehow the cell refuse to give out that amount of fluid, no op then return null; - aTank.fill(aFluidHeld, true); - GT_Utility.addItemToPlayerInventory(aPlayer, tStackEmptied); - reduceStackSizeInHandByOne(aPlayer); + + // find out how many fill can we do + // same round down behavior as above + // however here the fluid stack is not changed at all, so the exact code will slightly differ + int tParallel = aProcessFullStack ? Math.min(tFreeSpace / tAmountTaken, tStackHeld.stackSize) : 1; + if (aMachine.getFillableStack() == null) { + FluidStack tNewFillableStack = aFluidHeld.copy(); + tNewFillableStack.amount = tAmountTaken * tParallel; + aMachine.setFillableStack(tNewFillableStack); + } else { + aMachine.getFillableStack().amount += tAmountTaken * tParallel; + } + tStackEmptied.stackSize = tParallel; + replaceCursorItemStack(aPlayer, tStackEmptied); return tStackEmptied; } - private void reduceStackSizeInHandByOne(EntityPlayer aPlayer) { - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - tStackHeld.stackSize -= 1; - if (tStackHeld.stackSize == 0) - aPlayer.inventory.setItemStack(NI); + private void replaceCursorItemStack(EntityPlayer aPlayer, ItemStack tStackResult) { + int tStackResultMaxStackSize = tStackResult.getMaxStackSize(); + while (tStackResult.stackSize > tStackResultMaxStackSize) { + aPlayer.inventory.getItemStack().stackSize -= tStackResultMaxStackSize; + GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult.splitStack(tStackResultMaxStackSize)); + } + if (aPlayer.inventory.getItemStack().stackSize == tStackResult.stackSize) { + // every cell is mutated. it could just stay on the cursor. + aPlayer.inventory.setItemStack(tStackResult); + } else { + // some cells not mutated. The mutated cells must go into the inventory + // or drop into the world if there isn't enough space. + ItemStack tStackHeld = aPlayer.inventory.getItemStack(); + tStackHeld.stackSize -= tStackResult.stackSize; + GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult); + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java index 9b9442fef2..755fae8bce 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -2,10 +2,7 @@ package gregtech.common.tileentities.machines.basic; import com.google.common.collect.ArrayListMultimap; import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; +import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -31,8 +28,33 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachine { + public GT_MetaTileEntity_Disassembler(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "Disassembles Machines at " + Math.min(50 + 10 * aTier,100) + "% Efficiency", 1, 9, "Disassembler.png", "", new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_DISASSEMBLER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_DISASSEMBLER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_DISASSEMBLER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_DISASSEMBLER), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_DISASSEMBLER_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_DISASSEMBLER)); + super( + aID, + aName, + aNameRegional, + aTier, + 1, + new String[]{ + "Disassembles Machines up to " + GT_Values.TIER_COLORS[aTier] + GT_Values.VOLTAGE_NAMES[aTier], + "Can also disassemble most assembler recipes!" + }, + 1, + 9, + "Disassembler.png", + "", + + //Textures + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_DISASSEMBLER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_DISASSEMBLER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_DISASSEMBLER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_DISASSEMBLER), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_DISASSEMBLER_ACTIVE), + new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_DISASSEMBLER) + ); } public GT_MetaTileEntity_Disassembler(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { @@ -179,36 +201,30 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi inputsStacks = recipesColl.stream() .map(x -> x.mInputs) .collect(Collectors.toSet()); - ItemStack input = inputs[i]; - ItemData data = GT_OreDictUnificator.getItemData(input); - if (data == null || data.mMaterial == null || data.mMaterial.mMaterial == null || data.mPrefix == null) { - output[i] = input; - continue; - } - handleReplacement(inputsStacks, data, output, input, i); + handleRecipeTransformationInternal(inputs, output, inputsStacks, i); } addOthersAndHandleAlwaysReplace(inputs, output); } /** * Public Interface for ReverseRecipes, do not call inside of this class. - * @param inputs - * @param output - * @param inputsStacks */ public static void handleRecipeTransformation(ItemStack[] inputs, ItemStack[] output, Set<ItemStack[]> inputsStacks) { - for (int i = 0, inputsLength = inputs.length; i < inputsLength; i++) { - ItemStack input = inputs[i]; - ItemData data = GT_OreDictUnificator.getItemData(input); - if (data == null || data.mMaterial == null || data.mMaterial.mMaterial == null || data.mPrefix == null) { - output[i] = input; - continue; - } - handleReplacement(inputsStacks, data, output, input, i); - } + for (int i = 0, inputsLength = inputs.length; i < inputsLength; i++) + handleRecipeTransformationInternal(inputs, output, inputsStacks, i); addOthersAndHandleAlwaysReplace(inputs, output); } + private static void handleRecipeTransformationInternal(ItemStack[] inputs, ItemStack[] output, Set<ItemStack[]> inputsStacks, int i) { + ItemStack input = inputs[i]; + ItemData data = GT_OreDictUnificator.getItemData(input); + if (data == null || data.mMaterial == null || data.mMaterial.mMaterial == null || data.mPrefix == null) { + output[i] = input; + return; + } + handleReplacement(inputsStacks, data, output, input, i); + } + private static void addOthersAndHandleAlwaysReplace(ItemStack[] inputs, ItemStack[] output){ for (int i = 0; i < inputs.length; i++) { //Adds rest of Items diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index 760cb18b3a..0578bbe6c7 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2600,7 +2600,7 @@ public class GT_MachineRecipeLoader implements Runnable { tKey = "GT_CRYSTALLISATION"; GT_LanguageManager.addStringLocalization(GT_MachineRecipeLoader.aTextTCGTPage + tKey, "Sometimes when processing your Crystal Shards they become a pile of Dust instead of the mostly required Shard.<BR><BR>You have finally found a way to reverse this Process by using Vitreus Essentia for recrystallising the Shards."); GregTech_API.sThaumcraftCompat.addResearch(tKey, "Shard Recrystallisation", "Fixing your precious crystals", new String[]{"ALCHEMICALMANUFACTURE"}, "ALCHEMY", GT_OreDictUnificator.get(OrePrefixes.gem, Materials.InfusedOrder, 1L), 3, 0, -11, -3, Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.VITREUS, 5L), new TC_Aspects.TC_AspectStack(TC_Aspects.PERMUTATIO, 3L), new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 3L)), null, new Object[]{GT_MachineRecipeLoader.aTextTCGTPage + tKey, - //GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, OrePrefixes.dust.get(Materials.Amber), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Amber, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.VITREUS, 4L))), + GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, OrePrefixes.dust.get(Materials.Amber), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Amber, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.VITREUS, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, OrePrefixes.dust.get(Materials.InfusedOrder), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.InfusedOrder, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.VITREUS, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, OrePrefixes.dust.get(Materials.InfusedEntropy), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.InfusedEntropy, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.VITREUS, 4L))), GregTech_API.sThaumcraftCompat.addCrucibleRecipe(tKey, OrePrefixes.dust.get(Materials.InfusedAir), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.InfusedAir, 1L), Arrays.asList(new TC_Aspects.TC_AspectStack(TC_Aspects.VITREUS, 4L))), |