Take from inventory if no bucket is in the system
This commit is contained in:
@@ -11,10 +11,13 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.network.NetworkUtils;
|
||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||
import refinedstorage.api.storage.CompareUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FluidGridHandler implements IFluidGridHandler {
|
||||
private static final ItemStack EMPTY_BUCKET = new ItemStack(Items.BUCKET);
|
||||
|
||||
private INetworkMaster network;
|
||||
|
||||
public FluidGridHandler(INetworkMaster network) {
|
||||
@@ -26,7 +29,21 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
FluidStack stack = network.getFluidStorage().get(hash);
|
||||
|
||||
if (stack != null) {
|
||||
ItemStack bucket = NetworkUtils.extractItem(network, new ItemStack(Items.BUCKET), 1);
|
||||
ItemStack bucket = NetworkUtils.extractItem(network, EMPTY_BUCKET, 1);
|
||||
|
||||
if (bucket == null) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
||||
|
||||
if (CompareUtils.compareStack(EMPTY_BUCKET, slot)) {
|
||||
bucket = slot;
|
||||
|
||||
player.inventory.setInventorySlotContents(i, null);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bucket != null) {
|
||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).fill(NetworkUtils.extractFluid(network, stack, 1000), true);
|
||||
|
||||
@@ -30,7 +30,6 @@ import refinedstorage.integration.jei.IntegrationJEI;
|
||||
import refinedstorage.network.*;
|
||||
import refinedstorage.tile.grid.IGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
import refinedstorage.tile.grid.WirelessGrid;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -269,7 +268,7 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t(grid instanceof WirelessGrid ? "gui.refinedstorage:wireless_grid" : "gui.refinedstorage:grid"));
|
||||
drawString(7, 7, t(grid.getGuiTitle()));
|
||||
drawString(7, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 153 : 114, t("container.inventory"));
|
||||
|
||||
int x = 8;
|
||||
|
||||
@@ -252,6 +252,15 @@ public class CommonProxy {
|
||||
new ItemStack(RefinedStorageItems.PATTERN)
|
||||
));
|
||||
|
||||
// Fluid Grid
|
||||
RefinedStorageAPI.SOLDERER_REGISTRY.addRecipe(new SoldererRecipeBasic(
|
||||
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.FLUID.getId()),
|
||||
500,
|
||||
new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_ADVANCED),
|
||||
new ItemStack(RefinedStorageBlocks.GRID, 1, EnumGridType.FLUID.getId()),
|
||||
new ItemStack(Items.BUCKET)
|
||||
));
|
||||
|
||||
// Wireless Grid
|
||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.WIRELESS_GRID, 1, ItemWirelessGrid.TYPE_NORMAL),
|
||||
"EPE",
|
||||
|
||||
@@ -19,6 +19,8 @@ public interface IGrid {
|
||||
|
||||
IFluidGridHandler getFluidHandler();
|
||||
|
||||
String getGuiTitle();
|
||||
|
||||
int getViewType();
|
||||
|
||||
int getSortingType();
|
||||
|
||||
@@ -209,6 +209,11 @@ public class TileGrid extends TileNode implements IGrid {
|
||||
return isConnected() ? network.getFluidGridHandler() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTitle() {
|
||||
return getType() == EnumGridType.FLUID ? "gui.refinedstorage:fluid_grid" : "gui.refinedstorage:grid";
|
||||
}
|
||||
|
||||
public InventoryCrafting getMatrix() {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
@@ -96,6 +96,11 @@ public class WirelessGrid implements IGrid {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTitle() {
|
||||
return "gui.refinedstorage:wireless_grid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewType() {
|
||||
return viewType;
|
||||
|
||||
@@ -7,6 +7,7 @@ gui.refinedstorage:grid=Grid
|
||||
gui.refinedstorage:grid.craft=Craft
|
||||
gui.refinedstorage:grid.pattern_create=Create Pattern
|
||||
gui.refinedstorage:wireless_grid=Wireless Grid
|
||||
gui.refinedstorage:fluid_grid=Fluid Grid
|
||||
gui.refinedstorage:disk_drive=Drive
|
||||
gui.refinedstorage:external_storage=External Storage
|
||||
gui.refinedstorage:importer=Importer
|
||||
|
||||
Reference in New Issue
Block a user