mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-10-26 14:24:23 +00:00
Allow decode drops into fluid (#430)
This commit is contained in:
1 parent
387c740dcb
commit
07ce2fd1ea
4 files changed
+68
-42
No files matched your search
+11
-1
@@ -1,7 +1,10 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.DROP;
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.PACKET;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
|
||||
@@ -13,7 +16,14 @@ public class ContainerFluidPacketDecoder extends AEBaseContainer {
|
||||
|
||||
public ContainerFluidPacketDecoder(InventoryPlayer ipl, TileFluidPacketDecoder tile) {
|
||||
super(ipl, tile);
|
||||
addSlotToContainer(new FCSlotRestrictedInput(PACKET.stack(), tile.getInventory(), 0, 80, 35, ipl));
|
||||
addSlotToContainer(
|
||||
new FCSlotRestrictedInput(
|
||||
Arrays.asList(PACKET.stack(), DROP.stack()),
|
||||
tile.getInventory(),
|
||||
0,
|
||||
80,
|
||||
35,
|
||||
ipl));
|
||||
bindPlayerInventory(ipl, 0, 84);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.common.tile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -10,6 +11,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
|
||||
import appeng.api.networking.GridFlags;
|
||||
@@ -60,13 +62,22 @@ public class TileFluidPacketDecoder extends AENetworkTile
|
||||
return new TickingRequest(5, 120, false, true);
|
||||
}
|
||||
|
||||
private FluidStack getFluidStack() {
|
||||
final ItemStack stack = inventory.getStackInSlot(0);
|
||||
if (stack == null) return null;
|
||||
|
||||
if (stack.getItem() instanceof ItemFluidPacket) {
|
||||
return ItemFluidPacket.getFluidStack(stack);
|
||||
} else if (stack.getItem() instanceof ItemFluidDrop) {
|
||||
return ItemFluidDrop.getFluidStack(stack);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
|
||||
ItemStack stack = inventory.getStackInSlot(0);
|
||||
if (stack == null || !(stack.getItem() instanceof ItemFluidPacket)) {
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
|
||||
final FluidStack fluid = getFluidStack();
|
||||
if (fluid == null || fluid.amount <= 0) {
|
||||
inventory.setInventorySlotContents(0, null);
|
||||
return TickRateModulation.SLEEP;
|
||||
@@ -167,7 +178,8 @@ public class TileFluidPacketDecoder extends AENetworkTile
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemFluidPacket;
|
||||
final Item item = stack.getItem();
|
||||
return item instanceof ItemFluidPacket || item instanceof ItemFluidDrop;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,34 +194,27 @@ public class TileFluidPacketDecoder extends AENetworkTile
|
||||
|
||||
private FluidStack drain(FluidStack requestFluid, boolean doDrain) {
|
||||
if (requestFluid == null || requestFluid.amount <= 0) return null;
|
||||
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
|
||||
if (fluidPacket != null) {
|
||||
FluidStack fs = ItemFluidPacket.getFluidStack(fluidPacket);
|
||||
if (fs == null) return null;
|
||||
if (fs.isFluidEqual(requestFluid)) {
|
||||
if (fs.amount > requestFluid.amount) {
|
||||
fs.amount -= requestFluid.amount;
|
||||
if (doDrain) this.inventory.setInventorySlotContents(0, ItemFluidPacket.newStack(fs));
|
||||
return requestFluid;
|
||||
} else {
|
||||
if (doDrain) this.inventory.setInventorySlotContents(0, null);
|
||||
return fs;
|
||||
}
|
||||
final FluidStack fs = this.getFluidStack();
|
||||
if (fs != null && fs.isFluidEqual(requestFluid)) {
|
||||
if (fs.amount > requestFluid.amount) {
|
||||
fs.amount -= requestFluid.amount;
|
||||
if (doDrain) this.inventory.setInventorySlotContents(0, ItemFluidPacket.newStack(fs));
|
||||
return requestFluid;
|
||||
} else {
|
||||
if (doDrain) this.inventory.setInventorySlotContents(0, null);
|
||||
return fs;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
|
||||
if (fluidPacket != null) {
|
||||
FluidStack requestFluid = ItemFluidPacket.getFluidStack(fluidPacket);
|
||||
if (requestFluid == null) return null;
|
||||
requestFluid.amount = maxDrain;
|
||||
return this.drain(requestFluid, doDrain);
|
||||
}
|
||||
return null;
|
||||
final FluidStack requestFluid = this.getFluidStack();
|
||||
if (requestFluid == null) return null;
|
||||
requestFluid.amount = maxDrain;
|
||||
return this.drain(requestFluid, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,13 +229,8 @@ public class TileFluidPacketDecoder extends AENetworkTile
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
ItemStack fluidPacket = this.inventory.getStackInSlot(0);
|
||||
if (fluidPacket == null) {
|
||||
return new FluidTankInfo[0];
|
||||
} else {
|
||||
FluidStack fs = ItemFluidPacket.getFluidStack(fluidPacket);
|
||||
if (fs == null) return new FluidTankInfo[0];
|
||||
return new FluidTankInfo[] { new FluidTankInfo(fs, fs.amount) };
|
||||
}
|
||||
final FluidStack fs = this.getFluidStack();
|
||||
if (fs == null) return new FluidTankInfo[0];
|
||||
return new FluidTankInfo[] { new FluidTankInfo(fs, fs.amount) };
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.glodblock.github.inventory.slot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -17,10 +20,22 @@ public class FCSlotRestrictedInput extends SlotRestrictedInput {
|
||||
MutablePair<Boolean, ItemStack> isItemValid(final ItemStack inputItem);
|
||||
}
|
||||
|
||||
private final Filter filter;
|
||||
private final List<Filter> filter = new ArrayList<>();
|
||||
private final InventoryPlayer p;
|
||||
private ItemStack validItem = null;
|
||||
|
||||
public FCSlotRestrictedInput(List<ItemStack> validList, IInventory i, int slotIndex, int x, int y,
|
||||
InventoryPlayer p) {
|
||||
super(PlacableItemType.INSCRIBER_PLATE, i, slotIndex, x, y, p);
|
||||
validList.forEach(
|
||||
valid -> filter.add(
|
||||
(inputItem) -> new MutablePair<>(
|
||||
valid.getItem().getClass().isAssignableFrom(inputItem.getItem().getClass()),
|
||||
valid)));
|
||||
this.p = p;
|
||||
this.validItem = validList.get(0);
|
||||
}
|
||||
|
||||
public FCSlotRestrictedInput(ItemStack valid, IInventory i, int slotIndex, int x, int y, InventoryPlayer p) {
|
||||
this(
|
||||
(inputItem) -> new MutablePair<>(
|
||||
@@ -36,14 +51,15 @@ public class FCSlotRestrictedInput extends SlotRestrictedInput {
|
||||
|
||||
public FCSlotRestrictedInput(Filter filter, IInventory i, int slotIndex, int x, int y, InventoryPlayer p) {
|
||||
super(PlacableItemType.INSCRIBER_PLATE, i, slotIndex, x, y, p);
|
||||
this.filter = filter;
|
||||
this.filter.add(filter);
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack inputItem) {
|
||||
MutablePair<Boolean, ItemStack> result = this.filter.isItemValid(inputItem);
|
||||
return result.left;
|
||||
for (Filter filter : this.filter) if (filter.isItemValid(inputItem).left) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getAllowEdit() {
|
||||
|
||||
@@ -85,7 +85,7 @@ ae2fc.waila.disable=Disable
|
||||
|
||||
ae2fc.tooltip.shift_for_more=§r> Hold §3Shift§r for more information
|
||||
ae2fc.tooltip.ctrl_for_more=§r> Hold §3Ctrl§r for more information
|
||||
ae2fc.tooltip.fluid_packet_decoder.desc=The Fluid Decoder can decode Fluid packets. It has to be connected to a ME System and a place to store the liquid in, otherwise it won't work.
|
||||
ae2fc.tooltip.fluid_packet_decoder.desc=The Fluid Decoder can decode Fluid packets/drops. It has to be connected to a ME System and a place to store the liquid in, otherwise it won't work.
|
||||
ae2fc.tooltip.fluid_buffer.desc=This is a high speed fluid IO
|
||||
ae2fc.tooltip.walrus.desc=GTNH is like a job
|
||||
ae2fc.tooltip.fluid_auto_filler=Creates a fluid canning pattern with the given container automatically.
|
||||
@@ -132,7 +132,7 @@ ae2fc.tooltip.fluid_terminal=uh So we don't need EC2 anymore?
|
||||
ae2fc.tooltip.level_terminal=uh...
|
||||
ae2fc.tooltip.invalid_fluid=Invalid fluid!
|
||||
ae2fc.tooltip.encode_pattern=Encode Pattern
|
||||
ae2fc.tooltip.fluid_packet=Use a Fluid Packet Decoder to\nconvert this back into fluid.
|
||||
ae2fc.tooltip.fluid_packet=Use a Fluid Packet/Drops Decoder to\nconvert this back into fluid.
|
||||
ae2fc.tooltip.empty=Empty
|
||||
ae2fc.tooltip.dump_tank=Dump Tank Contents
|
||||
ae2fc.tooltip.switch_fluid_interface=Switch ME Dual Interface GUI
|
||||
|
||||
Reference in new issue
Block a user