mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-14 17:24:53 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5ad490947 | ||
|
|
00051c4594 | ||
|
|
d913e245ed |
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:ForestryMC:4.11.28:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.11.19:dev')
|
||||
implementation('com.github.GTNewHorizons:GTNHLib:0.11.30:dev')
|
||||
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.105-GTNH:dev')
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ public class ContainerCraftGUI extends Container {
|
||||
ItemStack heldItem = player.inventory.getItemStack().copy();
|
||||
IInventory entityInventory = window.getInventory();
|
||||
heldItem = new TransferRequest(heldItem, entityInventory).setOrigin(player.inventory).setTargetSlots(new int[0])
|
||||
.setTargetTanks(new int[] { slotID }).transfer(true);
|
||||
.setTargetTanks(new int[] { slotID }).dropOverflow(player).transfer(true);
|
||||
|
||||
player.inventory.setItemStack(heldItem);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ManagerLiquid extends ManagerBase {
|
||||
}
|
||||
|
||||
private static boolean isExternalFluid(String identifier) {
|
||||
return EXTERNAL_FLUIDS.contains(identifier) && Loader.isModLoaded("gregtech");
|
||||
return EXTERNAL_FLUIDS.contains(identifier) && Loader.isModLoaded("gregtech_nh");
|
||||
}
|
||||
|
||||
public Map<String, IFluidType> fluids;
|
||||
|
||||
@@ -3,6 +3,7 @@ package binnie.core.machines.transfer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
@@ -25,6 +26,7 @@ public class TransferRequest {
|
||||
private int[] targetTanks;
|
||||
private boolean transferLiquids;
|
||||
private boolean ignoreReadOnly;
|
||||
private EntityPlayer overflowPlayer;
|
||||
private final List<TransferSlot> insertedSlots;
|
||||
private final List<Integer> insertedTanks;
|
||||
|
||||
@@ -35,6 +37,7 @@ public class TransferRequest {
|
||||
targetTanks = new int[0];
|
||||
transferLiquids = true;
|
||||
ignoreReadOnly = false;
|
||||
overflowPlayer = null;
|
||||
insertedSlots = new ArrayList<>();
|
||||
insertedTanks = new ArrayList<>();
|
||||
int[] target = new int[destination.getSizeInventory()];
|
||||
@@ -95,6 +98,11 @@ public class TransferRequest {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TransferRequest dropOverflow(EntityPlayer player) {
|
||||
overflowPlayer = player;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack getReturnItem() {
|
||||
return returnItem;
|
||||
}
|
||||
@@ -107,9 +115,15 @@ public class TransferRequest {
|
||||
|
||||
if (transferLiquids && destination instanceof ITankMachine) {
|
||||
for (int tankID : targetTanks) {
|
||||
ItemStack itemBeforeTransfer = item.copy();
|
||||
item = transferToTank(item, origin, (ITankMachine) destination, tankID, doAdd);
|
||||
if (item != null) {
|
||||
item = transferFromTank(item, origin, (ITankMachine) destination, tankID, doAdd);
|
||||
if (item == null || !ItemStack.areItemStacksEqual(item, itemBeforeTransfer)) {
|
||||
break;
|
||||
}
|
||||
|
||||
item = transferFromTank(item, origin, (ITankMachine) destination, tankID, doAdd);
|
||||
if (item == null || !ItemStack.areItemStacksEqual(item, itemBeforeTransfer)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,11 +214,13 @@ public class TransferRequest {
|
||||
|
||||
private ItemStack transferToTankUsingFluidContainer(ItemStack item, IInventory origin, ITankMachine destination,
|
||||
int tankID, boolean doAdd) {
|
||||
if (item == null || !(item.getItem() instanceof IFluidContainerItem fluidContainer)) {
|
||||
if (item == null || origin == null || !(item.getItem() instanceof IFluidContainerItem fluidContainer)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
FluidStack fluid = fluidContainer.getFluid(item);
|
||||
ItemStack singleContainer = item.copy();
|
||||
singleContainer.stackSize = 1;
|
||||
FluidStack fluid = fluidContainer.getFluid(singleContainer);
|
||||
if (fluid == null) {
|
||||
return item;
|
||||
}
|
||||
@@ -216,11 +232,22 @@ public class TransferRequest {
|
||||
}
|
||||
|
||||
int maxFill = tank.fill(fluid, false);
|
||||
FluidStack toTake = fluidContainer.drain(item, maxFill, true);
|
||||
FluidStack toTake = fluidContainer.drain(singleContainer, maxFill, true);
|
||||
if (toTake == null || toTake.amount <= 0) {
|
||||
return item;
|
||||
}
|
||||
|
||||
TransferRequest containerDump = createContainerDump(singleContainer, origin);
|
||||
boolean dropContainer = containerDump.transfer(false) != null;
|
||||
if (dropContainer && overflowPlayer == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
if (doAdd) {
|
||||
tank.fill(toTake, true);
|
||||
dumpContainer(singleContainer, containerDump, dropContainer);
|
||||
}
|
||||
return item;
|
||||
return removeSingleContainer(item);
|
||||
}
|
||||
|
||||
private ItemStack transferToTankUsingContainerData(ItemStack item, IInventory origin, ITankMachine destination,
|
||||
@@ -305,24 +332,69 @@ public class TransferRequest {
|
||||
|
||||
private ItemStack transferFromTankUsingFluidContainer(ItemStack item, IInventory origin, ITankMachine destination,
|
||||
int tankID, boolean doAdd) {
|
||||
if (item == null || !(item.getItem() instanceof IFluidContainerItem fluidContainer)) {
|
||||
if (item == null || origin == null || !(item.getItem() instanceof IFluidContainerItem fluidContainer)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
ItemStack singleContainer = item.copy();
|
||||
singleContainer.stackSize = 1;
|
||||
IFluidTank tank = destination.getTanks()[tankID];
|
||||
FluidStack fluid = tank.getFluid();
|
||||
if (fluid == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
int amount = fluidContainer.fill(item, fluid, false);
|
||||
amount = Math.min(amount, (tank.drain(amount, false) == null) ? 0 : tank.drain(amount, false).amount);
|
||||
if (amount <= 0) {
|
||||
int amount = fluidContainer.fill(singleContainer, fluid, false);
|
||||
FluidStack drained = tank.drain(amount, false);
|
||||
if (drained == null || drained.amount <= 0) {
|
||||
return item;
|
||||
}
|
||||
|
||||
fluidContainer.fill(item, tank.drain(amount, doAdd), doAdd);
|
||||
return item;
|
||||
int amountFilled = fluidContainer.fill(singleContainer, drained, true);
|
||||
if (amountFilled <= 0) {
|
||||
return item;
|
||||
}
|
||||
|
||||
TransferRequest containerDump = createContainerDump(singleContainer, origin);
|
||||
boolean dropContainer = containerDump.transfer(false) != null;
|
||||
if (dropContainer && overflowPlayer == null) {
|
||||
return item;
|
||||
}
|
||||
|
||||
if (doAdd) {
|
||||
tank.drain(amountFilled, true);
|
||||
dumpContainer(singleContainer, containerDump, dropContainer);
|
||||
}
|
||||
return removeSingleContainer(item);
|
||||
}
|
||||
|
||||
private TransferRequest createContainerDump(ItemStack container, IInventory origin) {
|
||||
TransferRequest containerDump = new TransferRequest(container, origin).setTargetTanks(new int[0]);
|
||||
if (overflowPlayer != null && origin == overflowPlayer.inventory) {
|
||||
int[] mainInventorySlots = new int[overflowPlayer.inventory.mainInventory.length];
|
||||
for (int i = 0; i < mainInventorySlots.length; ++i) {
|
||||
mainInventorySlots[i] = i;
|
||||
}
|
||||
containerDump.setTargetSlots(mainInventorySlots);
|
||||
}
|
||||
return containerDump;
|
||||
}
|
||||
|
||||
private void dumpContainer(ItemStack container, TransferRequest containerDump, boolean dropContainer) {
|
||||
if (dropContainer) {
|
||||
overflowPlayer.dropPlayerItemWithRandomChoice(container.copy(), false);
|
||||
} else {
|
||||
containerDump.transfer(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack removeSingleContainer(ItemStack item) {
|
||||
if (item.stackSize <= 1) {
|
||||
return null;
|
||||
}
|
||||
ItemStack leftover = item.copy();
|
||||
--leftover.stackSize;
|
||||
return leftover;
|
||||
}
|
||||
|
||||
private ItemStack transferFromTankUsingContainerData(ItemStack item, IInventory origin, ITankMachine destination,
|
||||
|
||||
@@ -11,6 +11,7 @@ import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import binnie.genetics.item.ItemSerumArray;
|
||||
import binnie.genetics.nei.helper.ColorUtils;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.ItemList;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
@@ -60,7 +61,7 @@ public class DatabaseRecipeHandler extends RecipeHandlerBase {
|
||||
StatCollector.translateToLocalFormatted("genetics.nei.tip.databaseDesc"),
|
||||
140);
|
||||
for (int i = 0; i < desc.size(); i++) {
|
||||
GuiDraw.drawStringC(desc.get(i), 88, 44 + 12 * (i - 1), 0xFFFFFF);
|
||||
GuiDraw.drawStringC(desc.get(i), 88, 44 + 12 * (i - 1), ColorUtils.neiDisplayText.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import binnie.core.nei.PositionedFluidTank;
|
||||
import binnie.core.nei.RecipeHandlerBase;
|
||||
import binnie.genetics.api.IIncubatorRecipe;
|
||||
import binnie.genetics.machine.incubator.Incubator;
|
||||
import binnie.genetics.nei.helper.ColorUtils;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
@@ -48,8 +49,16 @@ public class IncubatorRecipeHandler extends RecipeHandlerBase {
|
||||
@Override
|
||||
public void drawExtras(int recipe) {
|
||||
this.drawProgressBar(75, 27, 176, 0, 24, 17, 40, 0);
|
||||
GuiDraw.drawStringC(StatCollector.translateToLocal("genetics.nei.tip.loss"), 62, 5, 0xFFFFFF);
|
||||
GuiDraw.drawStringC(((CachedIncubatorRecipe) arecipes.get(recipe)).lossChance, 62, 15, 0xFFFFFF);
|
||||
GuiDraw.drawStringC(
|
||||
StatCollector.translateToLocal("genetics.nei.tip.loss"),
|
||||
62,
|
||||
5,
|
||||
ColorUtils.neiDisplayText.getColor());
|
||||
GuiDraw.drawStringC(
|
||||
((CachedIncubatorRecipe) arecipes.get(recipe)).lossChance,
|
||||
62,
|
||||
15,
|
||||
ColorUtils.neiDisplayText.getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package binnie.genetics.nei.helper;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.color.ColorResource;
|
||||
|
||||
public class ColorUtils {
|
||||
|
||||
private static final ColorResource.Factory color = new ColorResource.Factory("binniecore");
|
||||
|
||||
public static final ColorResource
|
||||
// spotless:off
|
||||
neiDisplayText = color.rgb("neiDisplayText", "0xFFFFFF");
|
||||
// spotless:on
|
||||
}
|
||||
Reference in new issue
Block a user