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.INetworkMaster;
|
||||||
import refinedstorage.api.network.NetworkUtils;
|
import refinedstorage.api.network.NetworkUtils;
|
||||||
import refinedstorage.api.network.grid.IFluidGridHandler;
|
import refinedstorage.api.network.grid.IFluidGridHandler;
|
||||||
|
import refinedstorage.api.storage.CompareUtils;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class FluidGridHandler implements IFluidGridHandler {
|
public class FluidGridHandler implements IFluidGridHandler {
|
||||||
|
private static final ItemStack EMPTY_BUCKET = new ItemStack(Items.BUCKET);
|
||||||
|
|
||||||
private INetworkMaster network;
|
private INetworkMaster network;
|
||||||
|
|
||||||
public FluidGridHandler(INetworkMaster network) {
|
public FluidGridHandler(INetworkMaster network) {
|
||||||
@@ -26,7 +29,21 @@ public class FluidGridHandler implements IFluidGridHandler {
|
|||||||
FluidStack stack = network.getFluidStorage().get(hash);
|
FluidStack stack = network.getFluidStorage().get(hash);
|
||||||
|
|
||||||
if (stack != null) {
|
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) {
|
if (bucket != null) {
|
||||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).fill(NetworkUtils.extractFluid(network, stack, 1000), true);
|
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.network.*;
|
||||||
import refinedstorage.tile.grid.IGrid;
|
import refinedstorage.tile.grid.IGrid;
|
||||||
import refinedstorage.tile.grid.TileGrid;
|
import refinedstorage.tile.grid.TileGrid;
|
||||||
import refinedstorage.tile.grid.WirelessGrid;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -269,7 +268,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawForeground(int mouseX, int mouseY) {
|
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"));
|
drawString(7, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 153 : 114, t("container.inventory"));
|
||||||
|
|
||||||
int x = 8;
|
int x = 8;
|
||||||
|
|||||||
@@ -252,6 +252,15 @@ public class CommonProxy {
|
|||||||
new ItemStack(RefinedStorageItems.PATTERN)
|
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
|
// Wireless Grid
|
||||||
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.WIRELESS_GRID, 1, ItemWirelessGrid.TYPE_NORMAL),
|
GameRegistry.addRecipe(new ItemStack(RefinedStorageItems.WIRELESS_GRID, 1, ItemWirelessGrid.TYPE_NORMAL),
|
||||||
"EPE",
|
"EPE",
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public interface IGrid {
|
|||||||
|
|
||||||
IFluidGridHandler getFluidHandler();
|
IFluidGridHandler getFluidHandler();
|
||||||
|
|
||||||
|
String getGuiTitle();
|
||||||
|
|
||||||
int getViewType();
|
int getViewType();
|
||||||
|
|
||||||
int getSortingType();
|
int getSortingType();
|
||||||
|
|||||||
@@ -209,6 +209,11 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
return isConnected() ? network.getFluidGridHandler() : null;
|
return isConnected() ? network.getFluidGridHandler() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGuiTitle() {
|
||||||
|
return getType() == EnumGridType.FLUID ? "gui.refinedstorage:fluid_grid" : "gui.refinedstorage:grid";
|
||||||
|
}
|
||||||
|
|
||||||
public InventoryCrafting getMatrix() {
|
public InventoryCrafting getMatrix() {
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ public class WirelessGrid implements IGrid {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGuiTitle() {
|
||||||
|
return "gui.refinedstorage:wireless_grid";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getViewType() {
|
public int getViewType() {
|
||||||
return viewType;
|
return viewType;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ gui.refinedstorage:grid=Grid
|
|||||||
gui.refinedstorage:grid.craft=Craft
|
gui.refinedstorage:grid.craft=Craft
|
||||||
gui.refinedstorage:grid.pattern_create=Create Pattern
|
gui.refinedstorage:grid.pattern_create=Create Pattern
|
||||||
gui.refinedstorage:wireless_grid=Wireless Grid
|
gui.refinedstorage:wireless_grid=Wireless Grid
|
||||||
|
gui.refinedstorage:fluid_grid=Fluid Grid
|
||||||
gui.refinedstorage:disk_drive=Drive
|
gui.refinedstorage:disk_drive=Drive
|
||||||
gui.refinedstorage:external_storage=External Storage
|
gui.refinedstorage:external_storage=External Storage
|
||||||
gui.refinedstorage:importer=Importer
|
gui.refinedstorage:importer=Importer
|
||||||
|
|||||||
Reference in New Issue
Block a user