Fluid Grid
This commit is contained in:
@@ -137,13 +137,31 @@ public interface INetworkMaster {
|
|||||||
void sendItemStorageToClient(EntityPlayerMP player);
|
void sendItemStorageToClient(EntityPlayerMP player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a storage change to all clients that are watching a grid.
|
* Sends a item storage change to all clients that are watching a grid.
|
||||||
*
|
*
|
||||||
* @param stack The stack
|
* @param stack The stack
|
||||||
* @param delta The delta
|
* @param delta The delta
|
||||||
*/
|
*/
|
||||||
void sendItemStorageDeltaToClient(ItemStack stack, int delta);
|
void sendItemStorageDeltaToClient(ItemStack stack, int delta);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a grid packet with all the fluids to all clients that are watching a grid.
|
||||||
|
*/
|
||||||
|
void sendFluidStorageToClient();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a grid packet with all the fluids to a specific player.
|
||||||
|
*/
|
||||||
|
void sendFluidStorageToClient(EntityPlayerMP player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a fluids storage change to all clients that are watching a grid.
|
||||||
|
*
|
||||||
|
* @param stack The stack
|
||||||
|
* @param delta The delta
|
||||||
|
*/
|
||||||
|
void sendFluidStorageDeltaToClient(FluidStack stack, int delta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts an item to this network.
|
* Inserts an item to this network.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ public class GroupedFluidStorage implements IGroupedFluidStorage {
|
|||||||
add(stack, true);
|
add(stack, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network.sendFluidStorageToClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,11 +49,19 @@ public class GroupedFluidStorage implements IGroupedFluidStorage {
|
|||||||
if (otherStack.isFluidEqual(stack)) {
|
if (otherStack.isFluidEqual(stack)) {
|
||||||
otherStack.amount += stack.amount;
|
otherStack.amount += stack.amount;
|
||||||
|
|
||||||
|
if (!rebuilding) {
|
||||||
|
network.sendFluidStorageDeltaToClient(stack, stack.amount);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stacks.put(stack.getFluid(), stack.copy());
|
stacks.put(stack.getFluid(), stack.copy());
|
||||||
|
|
||||||
|
if (!rebuilding) {
|
||||||
|
network.sendFluidStorageDeltaToClient(stack, stack.amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,6 +74,8 @@ public class GroupedFluidStorage implements IGroupedFluidStorage {
|
|||||||
stacks.remove(otherStack.getFluid(), otherStack);
|
stacks.remove(otherStack.getFluid(), otherStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
network.sendFluidStorageDeltaToClient(stack, -stack.amount);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class BlockGrid extends BlockNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> subItems) {
|
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> subItems) {
|
||||||
for (int i = 0; i <= 2; i++) {
|
for (int i = 0; i <= 3; i++) {
|
||||||
subItems.add(new ItemStack(item, 1, i));
|
subItems.add(new ItemStack(item, 1, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,12 +47,12 @@ public class BlockGrid extends BlockNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getStateFromMeta(int meta) {
|
public IBlockState getStateFromMeta(int meta) {
|
||||||
return getDefaultState().withProperty(TYPE, meta == 0 ? EnumGridType.NORMAL : (meta == 1 ? EnumGridType.CRAFTING : EnumGridType.PATTERN));
|
return getDefaultState().withProperty(TYPE, meta == 0 ? EnumGridType.NORMAL : (meta == 1 ? EnumGridType.CRAFTING : (meta == 2 ? EnumGridType.PATTERN : EnumGridType.FLUID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetaFromState(IBlockState state) {
|
public int getMetaFromState(IBlockState state) {
|
||||||
return state.getValue(TYPE) == EnumGridType.NORMAL ? 0 : (state.getValue(TYPE) == EnumGridType.CRAFTING ? 1 : 2);
|
return state.getValue(TYPE) == EnumGridType.NORMAL ? 0 : (state.getValue(TYPE) == EnumGridType.CRAFTING ? 1 : (state.getValue(TYPE) == EnumGridType.PATTERN ? 2 : 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import net.minecraft.util.IStringSerializable;
|
|||||||
public enum EnumGridType implements IStringSerializable {
|
public enum EnumGridType implements IStringSerializable {
|
||||||
NORMAL(0, "normal"),
|
NORMAL(0, "normal"),
|
||||||
CRAFTING(1, "crafting"),
|
CRAFTING(1, "crafting"),
|
||||||
PATTERN(2, "pattern");
|
PATTERN(2, "pattern"),
|
||||||
|
FLUID(3, "fluid");
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -61,10 +61,12 @@ public class ContainerGrid extends ContainerBase {
|
|||||||
addSlotToContainer(new SlotOutput(((TileGrid) grid).getPatterns(), 1, 152, 132));
|
addSlotToContainer(new SlotOutput(((TileGrid) grid).getPatterns(), 1, 152, 132));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grid.getType() != EnumGridType.FLUID) {
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
addSlotToContainer(new SlotItemHandler(grid.getFilter(), i, 204, 6 + (18 * i)));
|
addSlotToContainer(new SlotItemHandler(grid.getFilter(), i, 204, 6 + (18 * i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IGrid getGrid() {
|
public IGrid getGrid() {
|
||||||
return grid;
|
return grid;
|
||||||
@@ -104,7 +106,7 @@ public class ContainerGrid extends ContainerBase {
|
|||||||
if (slot.getHasStack()) {
|
if (slot.getHasStack()) {
|
||||||
if (slot == craftingResultSlot) {
|
if (slot == craftingResultSlot) {
|
||||||
((TileGrid) grid).onCraftedShift(this, player);
|
((TileGrid) grid).onCraftedShift(this, player);
|
||||||
} else if (grid.getHandler() != null && slot != patternResultSlot && !(slot instanceof SlotSpecimenLegacy)) {
|
} else if (grid.getHandler() != null && slot != patternResultSlot && !(slot instanceof SlotSpecimenLegacy) && grid.getType() != EnumGridType.FLUID) {
|
||||||
slot.putStack(grid.getHandler().onInsert(slot.getStack()));
|
slot.putStack(grid.getHandler().onInsert(slot.getStack()));
|
||||||
|
|
||||||
detectAndSendChanges();
|
detectAndSendChanges();
|
||||||
|
|||||||
@@ -212,6 +212,11 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
itemRender.renderItemOverlayIntoGUI(fontRendererObj, stack, x, y, "");
|
itemRender.renderItemOverlayIntoGUI(fontRendererObj, stack, x, y, "");
|
||||||
|
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
|
drawQuantity(x, y, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawQuantity(int x, int y, String qty) {
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate(x, y, 1);
|
GlStateManager.translate(x, y, 1);
|
||||||
GlStateManager.scale(0.5f, 0.5f, 1);
|
GlStateManager.scale(0.5f, 0.5f, 1);
|
||||||
@@ -223,7 +228,7 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
GlStateManager.blendFunc(770, 771);
|
GlStateManager.blendFunc(770, 771);
|
||||||
GlStateManager.disableDepth();
|
GlStateManager.disableDepth();
|
||||||
|
|
||||||
fontRendererObj.drawStringWithShadow(text, 30 - fontRendererObj.getStringWidth(text), 22, 16777215);
|
fontRendererObj.drawStringWithShadow(qty, 30 - fontRendererObj.getStringWidth(qty), 22, 16777215);
|
||||||
|
|
||||||
GlStateManager.enableDepth();
|
GlStateManager.enableDepth();
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
@@ -232,7 +237,6 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void drawString(int x, int y, String message) {
|
public void drawString(int x, int y, String message) {
|
||||||
drawString(x, y, message, 4210752);
|
drawString(x, y, message, 4210752);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import net.minecraft.init.SoundEvents;
|
|||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||||
@@ -21,6 +22,7 @@ import refinedstorage.gui.GuiBase;
|
|||||||
import refinedstorage.gui.Scrollbar;
|
import refinedstorage.gui.Scrollbar;
|
||||||
import refinedstorage.gui.grid.sorting.GridSortingName;
|
import refinedstorage.gui.grid.sorting.GridSortingName;
|
||||||
import refinedstorage.gui.grid.sorting.GridSortingQuantity;
|
import refinedstorage.gui.grid.sorting.GridSortingQuantity;
|
||||||
|
import refinedstorage.gui.grid.stack.ClientStackFluid;
|
||||||
import refinedstorage.gui.grid.stack.ClientStackItem;
|
import refinedstorage.gui.grid.stack.ClientStackItem;
|
||||||
import refinedstorage.gui.grid.stack.IClientStack;
|
import refinedstorage.gui.grid.stack.IClientStack;
|
||||||
import refinedstorage.gui.sidebutton.*;
|
import refinedstorage.gui.sidebutton.*;
|
||||||
@@ -43,8 +45,10 @@ public class GuiGrid extends GuiBase {
|
|||||||
public static final GridSortingQuantity SORTING_QUANTITY = new GridSortingQuantity();
|
public static final GridSortingQuantity SORTING_QUANTITY = new GridSortingQuantity();
|
||||||
public static final GridSortingName SORTING_NAME = new GridSortingName();
|
public static final GridSortingName SORTING_NAME = new GridSortingName();
|
||||||
|
|
||||||
public static Multimap<Item, IClientStack> ITEMS = ArrayListMultimap.create();
|
public static Multimap<Item, ClientStackItem> ITEMS = ArrayListMultimap.create();
|
||||||
public static List<IClientStack> SORTED_ITEMS = new ArrayList<>();
|
public static Multimap<Fluid, ClientStackFluid> FLUIDS = ArrayListMultimap.create();
|
||||||
|
|
||||||
|
public static List<IClientStack> STACKS = new ArrayList<>();
|
||||||
|
|
||||||
private static boolean markedForSorting;
|
private static boolean markedForSorting;
|
||||||
|
|
||||||
@@ -62,7 +66,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
public GuiGrid(ContainerGrid container, IGrid grid) {
|
public GuiGrid(ContainerGrid container, IGrid grid) {
|
||||||
super(container, 227, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208);
|
super(container, 227, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 247 : 208);
|
||||||
|
|
||||||
setScrollbar(new Scrollbar(174, 20, 12, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 70 : 88));
|
setScrollbar(new Scrollbar(174, 20, 12, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN || grid.getType() == EnumGridType.FLUID) ? 70 : 88));
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
@@ -89,7 +93,10 @@ public class GuiGrid extends GuiBase {
|
|||||||
searchField.yPosition = sy;
|
searchField.yPosition = sy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grid.getType() != EnumGridType.FLUID) {
|
||||||
addSideButton(new SideButtonGridViewType(grid));
|
addSideButton(new SideButtonGridViewType(grid));
|
||||||
|
}
|
||||||
|
|
||||||
addSideButton(new SideButtonGridSortingDirection(grid));
|
addSideButton(new SideButtonGridSortingDirection(grid));
|
||||||
addSideButton(new SideButtonGridSortingType(grid));
|
addSideButton(new SideButtonGridSortingType(grid));
|
||||||
addSideButton(new SideButtonGridSearchBoxMode(this));
|
addSideButton(new SideButtonGridSearchBoxMode(this));
|
||||||
@@ -102,18 +109,19 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sortItems() {
|
private void sortItems() {
|
||||||
List<IClientStack> sortedItems = new ArrayList<>();
|
List<IClientStack> stacks = new ArrayList<>();
|
||||||
|
|
||||||
if (grid.isConnected()) {
|
if (grid.isConnected()) {
|
||||||
sortedItems.addAll(ITEMS.values());
|
stacks.addAll(grid.getType() == EnumGridType.FLUID ? FLUIDS.values() : ITEMS.values());
|
||||||
|
|
||||||
String query = searchField.getText().trim().toLowerCase();
|
String query = searchField.getText().trim().toLowerCase();
|
||||||
|
|
||||||
Iterator<IClientStack> t = sortedItems.iterator();
|
Iterator<IClientStack> t = stacks.iterator();
|
||||||
|
|
||||||
while (t.hasNext()) {
|
while (t.hasNext()) {
|
||||||
IClientStack stack = t.next();
|
IClientStack stack = t.next();
|
||||||
|
|
||||||
|
if (grid.getType() != EnumGridType.FLUID) {
|
||||||
List<GridFilteredItem> filteredItems = grid.getFilteredItems();
|
List<GridFilteredItem> filteredItems = grid.getFilteredItems();
|
||||||
|
|
||||||
boolean found = filteredItems.isEmpty();
|
boolean found = filteredItems.isEmpty();
|
||||||
@@ -132,15 +140,16 @@ public class GuiGrid extends GuiBase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grid.getViewType() == TileGrid.VIEW_TYPE_NON_CRAFTABLES && stack.isCraftable()) {
|
if (grid.getViewType() == TileGrid.VIEW_TYPE_NON_CRAFTABLES && ((ClientStackItem) stack).isCraftable()) {
|
||||||
t.remove();
|
t.remove();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} else if (grid.getViewType() == TileGrid.VIEW_TYPE_CRAFTABLES && !stack.isCraftable()) {
|
} else if (grid.getViewType() == TileGrid.VIEW_TYPE_CRAFTABLES && !((ClientStackItem) stack).isCraftable()) {
|
||||||
t.remove();
|
t.remove();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (query.startsWith("@")) {
|
if (query.startsWith("@")) {
|
||||||
String[] parts = query.split(" ");
|
String[] parts = query.split(" ");
|
||||||
@@ -173,14 +182,14 @@ public class GuiGrid extends GuiBase {
|
|||||||
SORTING_NAME.setSortingDirection(grid.getSortingDirection());
|
SORTING_NAME.setSortingDirection(grid.getSortingDirection());
|
||||||
SORTING_QUANTITY.setSortingDirection(grid.getSortingDirection());
|
SORTING_QUANTITY.setSortingDirection(grid.getSortingDirection());
|
||||||
|
|
||||||
Collections.sort(sortedItems, SORTING_NAME);
|
Collections.sort(stacks, SORTING_NAME);
|
||||||
|
|
||||||
if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) {
|
if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) {
|
||||||
Collections.sort(sortedItems, SORTING_QUANTITY);
|
Collections.sort(stacks, SORTING_QUANTITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SORTED_ITEMS = sortedItems;
|
STACKS = stacks;
|
||||||
|
|
||||||
getScrollbar().setEnabled(getRows() > getVisibleRows());
|
getScrollbar().setEnabled(getRows() > getVisibleRows());
|
||||||
getScrollbar().setMaxOffset(getRows() - getVisibleRows());
|
getScrollbar().setMaxOffset(getRows() - getVisibleRows());
|
||||||
@@ -196,11 +205,11 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getRows() {
|
private int getRows() {
|
||||||
return Math.max(0, (int) Math.ceil((float) SORTED_ITEMS.size() / 9F));
|
return Math.max(0, (int) Math.ceil((float) STACKS.size() / 9F));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOverSlotWithItem() {
|
private boolean isOverSlotWithItem() {
|
||||||
return grid.isConnected() && isOverSlot() && slotNumber < SORTED_ITEMS.size();
|
return grid.isConnected() && isOverSlot() && slotNumber < STACKS.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOverSlot() {
|
private boolean isOverSlot() {
|
||||||
@@ -236,6 +245,8 @@ public class GuiGrid extends GuiBase {
|
|||||||
bindTexture("gui/crafting_grid.png");
|
bindTexture("gui/crafting_grid.png");
|
||||||
} else if (grid.getType() == EnumGridType.PATTERN) {
|
} else if (grid.getType() == EnumGridType.PATTERN) {
|
||||||
bindTexture("gui/pattern_grid.png");
|
bindTexture("gui/pattern_grid.png");
|
||||||
|
} else if (grid.getType() == EnumGridType.FLUID) {
|
||||||
|
bindTexture("gui/fluid_grid.png");
|
||||||
} else {
|
} else {
|
||||||
bindTexture("gui/grid.png");
|
bindTexture("gui/grid.png");
|
||||||
}
|
}
|
||||||
@@ -278,8 +289,8 @@ public class GuiGrid extends GuiBase {
|
|||||||
this.slotNumber = slot;
|
this.slotNumber = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot < SORTED_ITEMS.size()) {
|
if (slot < STACKS.size()) {
|
||||||
SORTED_ITEMS.get(slot).draw(this, x, y, GuiScreen.isShiftKeyDown() && slotNumber == slot);
|
STACKS.get(slot).draw(this, x, y, GuiScreen.isShiftKeyDown() && slotNumber == slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
if (inBounds(x, y, 16, 16, mouseX, mouseY) || !grid.isConnected()) {
|
||||||
@@ -307,7 +318,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isOverSlotWithItem()) {
|
if (isOverSlotWithItem()) {
|
||||||
drawTooltip(mouseX, mouseY, SORTED_ITEMS.get(slotNumber).getTooltip());
|
drawTooltip(mouseX, mouseY, STACKS.get(slotNumber).getTooltip());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOverClear(mouseX, mouseY)) {
|
if (isOverClear(mouseX, mouseY)) {
|
||||||
@@ -341,21 +352,21 @@ public class GuiGrid extends GuiBase {
|
|||||||
BlockPos gridPos = ((TileGrid) grid).getPos();
|
BlockPos gridPos = ((TileGrid) grid).getPos();
|
||||||
|
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridPatternCreate(gridPos.getX(), gridPos.getY(), gridPos.getZ()));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridPatternCreate(gridPos.getX(), gridPos.getY(), gridPos.getZ()));
|
||||||
} else if (grid.isConnected()) {
|
} else if (grid.isConnected() && grid.getType() != EnumGridType.FLUID) {
|
||||||
if (clickedClear) {
|
if (clickedClear) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack held = container.getPlayer().inventory.getItemStack();
|
ItemStack held = container.getPlayer().inventory.getItemStack();
|
||||||
|
|
||||||
ClientStackItem stack = (ClientStackItem) SORTED_ITEMS.get(slotNumber);
|
|
||||||
|
|
||||||
if (isOverSlotArea(mouseX - guiLeft, mouseY - guiTop) && held != null && (clickedButton == 0 || clickedButton == 1)) {
|
if (isOverSlotArea(mouseX - guiLeft, mouseY - guiTop) && held != null && (clickedButton == 0 || clickedButton == 1)) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridInsertHeld(clickedButton == 1));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridInsertHeld(clickedButton == 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOverSlotWithItem() && (held == null || (held != null && clickedButton == 2))) {
|
if (isOverSlotWithItem() && (held == null || (held != null && clickedButton == 2))) {
|
||||||
if (SORTED_ITEMS.get(slotNumber).isCraftable() && (stack.getQuantity() == 0 || (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown()))) {
|
ClientStackItem stack = (ClientStackItem) STACKS.get(slotNumber);
|
||||||
|
|
||||||
|
if (stack.isCraftable() && (stack.getQuantity() == 0 || (GuiScreen.isShiftKeyDown() && GuiScreen.isCtrlKeyDown()))) {
|
||||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingSettings(this, container.getPlayer(), stack));
|
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingSettings(this, container.getPlayer(), stack));
|
||||||
} else {
|
} else {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|||||||
64
src/main/java/refinedstorage/gui/grid/stack/ClientStackFluid.java
Executable file
64
src/main/java/refinedstorage/gui/grid/stack/ClientStackFluid.java
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
package refinedstorage.gui.grid.stack;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import mezz.jei.gui.ingredients.FluidStackRenderer;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
|
import refinedstorage.gui.GuiBase;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class ClientStackFluid implements IClientStack {
|
||||||
|
private FluidStack stack;
|
||||||
|
private FluidStackRenderer renderer;
|
||||||
|
|
||||||
|
public ClientStackFluid(ByteBuf buf) {
|
||||||
|
stack = new FluidStack(FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf)), buf.readInt(), ByteBufUtils.readTag(buf));
|
||||||
|
renderer = new FluidStackRenderer(1000, false, 16, 16, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FluidStack getStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return stack.getFluid().getLocalizedName(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo: ;-)
|
||||||
|
@Override
|
||||||
|
public String getModId() {
|
||||||
|
return "minecraft";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTooltip() {
|
||||||
|
return stack.getFluid().getLocalizedName(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getQuantity() {
|
||||||
|
return stack.amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(GuiBase gui, int x, int y, boolean isOverWithShift) {
|
||||||
|
renderer.draw(Minecraft.getMinecraft(), x, y, stack);
|
||||||
|
|
||||||
|
gui.drawQuantity(x, y, String.format(Locale.US, "%.1f", (float) stack.amount / 1000).replace(".0", "") + "B");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return obj instanceof ClientStackFluid && ((ClientStackFluid) obj).getStack().isFluidEqual(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void write(ByteBuf buf, FluidStack stack) {
|
||||||
|
ByteBufUtils.writeUTF8String(buf, FluidRegistry.getFluidName(stack.getFluid()));
|
||||||
|
buf.writeInt(stack.amount);
|
||||||
|
ByteBufUtils.writeTag(buf, stack.tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,6 @@ public class ClientStackItem implements IClientStack {
|
|||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCraftable() {
|
public boolean isCraftable() {
|
||||||
return craftable;
|
return craftable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package refinedstorage.gui.grid.stack;
|
|||||||
import refinedstorage.gui.GuiBase;
|
import refinedstorage.gui.GuiBase;
|
||||||
|
|
||||||
public interface IClientStack {
|
public interface IClientStack {
|
||||||
boolean isCraftable();
|
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
String getModId();
|
String getModId();
|
||||||
|
|||||||
61
src/main/java/refinedstorage/network/MessageGridFluidDelta.java
Executable file
61
src/main/java/refinedstorage/network/MessageGridFluidDelta.java
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
package refinedstorage.network;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import refinedstorage.gui.grid.GuiGrid;
|
||||||
|
import refinedstorage.gui.grid.stack.ClientStackFluid;
|
||||||
|
|
||||||
|
public class MessageGridFluidDelta implements IMessage, IMessageHandler<MessageGridFluidDelta, IMessage> {
|
||||||
|
private FluidStack stack;
|
||||||
|
private int delta;
|
||||||
|
|
||||||
|
private ClientStackFluid clientStack;
|
||||||
|
|
||||||
|
public MessageGridFluidDelta() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageGridFluidDelta(FluidStack stack, int delta) {
|
||||||
|
this.stack = stack;
|
||||||
|
this.delta = delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
clientStack = new ClientStackFluid(buf);
|
||||||
|
delta = buf.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
ClientStackFluid.write(buf, stack);
|
||||||
|
buf.writeInt(delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(MessageGridFluidDelta message, MessageContext ctx) {
|
||||||
|
Fluid fluid = message.clientStack.getStack().getFluid();
|
||||||
|
|
||||||
|
for (ClientStackFluid stack : GuiGrid.FLUIDS.get(fluid)) {
|
||||||
|
if (stack.equals(message.clientStack)) {
|
||||||
|
if (stack.getStack().amount + message.delta == 0) {
|
||||||
|
GuiGrid.FLUIDS.remove(fluid, stack);
|
||||||
|
} else {
|
||||||
|
stack.getStack().amount += message.delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiGrid.markForSorting();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiGrid.FLUIDS.put(fluid, message.clientStack);
|
||||||
|
GuiGrid.markForSorting();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
56
src/main/java/refinedstorage/network/MessageGridFluidUpdate.java
Executable file
56
src/main/java/refinedstorage/network/MessageGridFluidUpdate.java
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
package refinedstorage.network;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
|
import refinedstorage.gui.grid.GuiGrid;
|
||||||
|
import refinedstorage.gui.grid.stack.ClientStackFluid;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MessageGridFluidUpdate implements IMessage, IMessageHandler<MessageGridFluidUpdate, IMessage> {
|
||||||
|
private INetworkMaster network;
|
||||||
|
private List<ClientStackFluid> stacks = new ArrayList<>();
|
||||||
|
|
||||||
|
public MessageGridFluidUpdate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageGridFluidUpdate(INetworkMaster network) {
|
||||||
|
this.network = network;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
int items = buf.readInt();
|
||||||
|
|
||||||
|
for (int i = 0; i < items; ++i) {
|
||||||
|
this.stacks.add(new ClientStackFluid(buf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
buf.writeInt(network.getFluidStorage().getStacks().size());
|
||||||
|
|
||||||
|
for (FluidStack stack : network.getFluidStorage().getStacks()) {
|
||||||
|
ClientStackFluid.write(buf, stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(MessageGridFluidUpdate message, MessageContext ctx) {
|
||||||
|
GuiGrid.FLUIDS.clear();
|
||||||
|
|
||||||
|
for (ClientStackFluid item : message.stacks) {
|
||||||
|
GuiGrid.FLUIDS.put(item.getStack().getFluid(), item);
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiGrid.markForSorting();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,19 +9,18 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
|||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.gui.grid.GuiGrid;
|
import refinedstorage.gui.grid.GuiGrid;
|
||||||
import refinedstorage.gui.grid.stack.ClientStackItem;
|
import refinedstorage.gui.grid.stack.ClientStackItem;
|
||||||
import refinedstorage.gui.grid.stack.IClientStack;
|
|
||||||
|
|
||||||
public class MessageGridDelta implements IMessage, IMessageHandler<MessageGridDelta, IMessage> {
|
public class MessageGridItemDelta implements IMessage, IMessageHandler<MessageGridItemDelta, IMessage> {
|
||||||
private INetworkMaster network;
|
private INetworkMaster network;
|
||||||
private ItemStack stack;
|
private ItemStack stack;
|
||||||
private int delta;
|
private int delta;
|
||||||
|
|
||||||
private ClientStackItem clientStack;
|
private ClientStackItem clientStack;
|
||||||
|
|
||||||
public MessageGridDelta() {
|
public MessageGridItemDelta() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageGridDelta(INetworkMaster network, ItemStack stack, int delta) {
|
public MessageGridItemDelta(INetworkMaster network, ItemStack stack, int delta) {
|
||||||
this.network = network;
|
this.network = network;
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.delta = delta;
|
this.delta = delta;
|
||||||
@@ -40,12 +39,10 @@ public class MessageGridDelta implements IMessage, IMessageHandler<MessageGridDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(MessageGridDelta message, MessageContext ctx) {
|
public IMessage onMessage(MessageGridItemDelta message, MessageContext ctx) {
|
||||||
Item item = message.clientStack.getStack().getItem();
|
Item item = message.clientStack.getStack().getItem();
|
||||||
|
|
||||||
for (IClientStack anyStack : GuiGrid.ITEMS.get(item)) {
|
for (ClientStackItem stack : GuiGrid.ITEMS.get(item)) {
|
||||||
ClientStackItem stack = (ClientStackItem) anyStack;
|
|
||||||
|
|
||||||
if (stack.equals(message.clientStack)) {
|
if (stack.equals(message.clientStack)) {
|
||||||
if (stack.getStack().stackSize + message.delta == 0 && !message.clientStack.isCraftable()) {
|
if (stack.getStack().stackSize + message.delta == 0 && !message.clientStack.isCraftable()) {
|
||||||
GuiGrid.ITEMS.remove(item, stack);
|
GuiGrid.ITEMS.remove(item, stack);
|
||||||
@@ -12,14 +12,14 @@ import refinedstorage.gui.grid.stack.ClientStackItem;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MessageGridUpdate implements IMessage, IMessageHandler<MessageGridUpdate, IMessage> {
|
public class MessageGridItemUpdate implements IMessage, IMessageHandler<MessageGridItemUpdate, IMessage> {
|
||||||
private INetworkMaster network;
|
private INetworkMaster network;
|
||||||
private List<ClientStackItem> items = new ArrayList<>();
|
private List<ClientStackItem> stacks = new ArrayList<>();
|
||||||
|
|
||||||
public MessageGridUpdate() {
|
public MessageGridItemUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageGridUpdate(INetworkMaster network) {
|
public MessageGridItemUpdate(INetworkMaster network) {
|
||||||
this.network = network;
|
this.network = network;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ public class MessageGridUpdate implements IMessage, IMessageHandler<MessageGridU
|
|||||||
int items = buf.readInt();
|
int items = buf.readInt();
|
||||||
|
|
||||||
for (int i = 0; i < items; ++i) {
|
for (int i = 0; i < items; ++i) {
|
||||||
this.items.add(new ClientStackItem(buf));
|
this.stacks.add(new ClientStackItem(buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@ public class MessageGridUpdate implements IMessage, IMessageHandler<MessageGridU
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(MessageGridUpdate message, MessageContext ctx) {
|
public IMessage onMessage(MessageGridItemUpdate message, MessageContext ctx) {
|
||||||
GuiGrid.ITEMS.clear();
|
GuiGrid.ITEMS.clear();
|
||||||
|
|
||||||
for (ClientStackItem item : message.items) {
|
for (ClientStackItem item : message.stacks) {
|
||||||
GuiGrid.ITEMS.put(item.getStack().getItem(), item);
|
GuiGrid.ITEMS.put(item.getStack().getItem(), item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,8 +52,10 @@ public class CommonProxy {
|
|||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridCraftingStart.class, MessageGridCraftingStart.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridCraftingStart.class, MessageGridCraftingStart.class, id++, Side.SERVER);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridPatternCreate.class, MessageGridPatternCreate.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridPatternCreate.class, MessageGridPatternCreate.class, id++, Side.SERVER);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageCraftingMonitorCancel.class, MessageCraftingMonitorCancel.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageCraftingMonitorCancel.class, MessageCraftingMonitorCancel.class, id++, Side.SERVER);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridUpdate.class, MessageGridUpdate.class, id++, Side.CLIENT);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridItemUpdate.class, MessageGridItemUpdate.class, id++, Side.CLIENT);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridDelta.class, MessageGridDelta.class, id++, Side.CLIENT);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridItemDelta.class, MessageGridItemDelta.class, id++, Side.CLIENT);
|
||||||
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridFluidUpdate.class, MessageGridFluidUpdate.class, id++, Side.CLIENT);
|
||||||
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridFluidDelta.class, MessageGridFluidDelta.class, id++, Side.CLIENT);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderClear.class, MessageProcessingPatternEncoderClear.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderClear.class, MessageProcessingPatternEncoderClear.class, id++, Side.SERVER);
|
||||||
RefinedStorage.INSTANCE.network.registerMessage(MessageGridFilterUpdate.class, MessageGridFilterUpdate.class, id++, Side.SERVER);
|
RefinedStorage.INSTANCE.network.registerMessage(MessageGridFilterUpdate.class, MessageGridFilterUpdate.class, id++, Side.SERVER);
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import refinedstorage.apiimpl.storage.fluid.GroupedFluidStorage;
|
|||||||
import refinedstorage.apiimpl.storage.item.GroupedItemStorage;
|
import refinedstorage.apiimpl.storage.item.GroupedItemStorage;
|
||||||
import refinedstorage.block.BlockController;
|
import refinedstorage.block.BlockController;
|
||||||
import refinedstorage.block.EnumControllerType;
|
import refinedstorage.block.EnumControllerType;
|
||||||
|
import refinedstorage.block.EnumGridType;
|
||||||
import refinedstorage.container.ContainerGrid;
|
import refinedstorage.container.ContainerGrid;
|
||||||
import refinedstorage.integration.ic2.ControllerEnergyIC2;
|
import refinedstorage.integration.ic2.ControllerEnergyIC2;
|
||||||
import refinedstorage.integration.ic2.ControllerEnergyIC2None;
|
import refinedstorage.integration.ic2.ControllerEnergyIC2None;
|
||||||
@@ -48,14 +49,17 @@ import refinedstorage.integration.ic2.IntegrationIC2;
|
|||||||
import refinedstorage.integration.tesla.ControllerEnergyTesla;
|
import refinedstorage.integration.tesla.ControllerEnergyTesla;
|
||||||
import refinedstorage.integration.tesla.IntegrationTesla;
|
import refinedstorage.integration.tesla.IntegrationTesla;
|
||||||
import refinedstorage.item.ItemPattern;
|
import refinedstorage.item.ItemPattern;
|
||||||
import refinedstorage.network.MessageGridDelta;
|
import refinedstorage.network.MessageGridFluidDelta;
|
||||||
import refinedstorage.network.MessageGridUpdate;
|
import refinedstorage.network.MessageGridFluidUpdate;
|
||||||
|
import refinedstorage.network.MessageGridItemDelta;
|
||||||
|
import refinedstorage.network.MessageGridItemUpdate;
|
||||||
import refinedstorage.tile.config.IRedstoneConfigurable;
|
import refinedstorage.tile.config.IRedstoneConfigurable;
|
||||||
import refinedstorage.tile.config.RedstoneMode;
|
import refinedstorage.tile.config.RedstoneMode;
|
||||||
import refinedstorage.tile.data.ITileDataProducer;
|
import refinedstorage.tile.data.ITileDataProducer;
|
||||||
import refinedstorage.tile.data.RefinedStorageSerializers;
|
import refinedstorage.tile.data.RefinedStorageSerializers;
|
||||||
import refinedstorage.tile.data.TileDataParameter;
|
import refinedstorage.tile.data.TileDataParameter;
|
||||||
import refinedstorage.tile.externalstorage.ItemStorageExternal;
|
import refinedstorage.tile.externalstorage.ItemStorageExternal;
|
||||||
|
import refinedstorage.tile.grid.IGrid;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -177,7 +181,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
dataManager.addParameter(NODES);
|
dataManager.addParameter(NODES);
|
||||||
|
|
||||||
fluidStorage.add(new FluidStack(FluidRegistry.WATER, 1000 * 32), false);
|
fluidStorage.add(new FluidStack(FluidRegistry.WATER, 1000 * 32), false);
|
||||||
fluidStorage.add(new FluidStack(FluidRegistry.LAVA, 1000 * 32), false);
|
fluidStorage.add(new FluidStack(FluidRegistry.LAVA, 1000 * 64), false);
|
||||||
|
|
||||||
if (IntegrationIC2.isLoaded()) {
|
if (IntegrationIC2.isLoaded()) {
|
||||||
this.energyEU = new ControllerEnergyIC2(this);
|
this.energyEU = new ControllerEnergyIC2(this);
|
||||||
@@ -458,24 +462,51 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
|||||||
@Override
|
@Override
|
||||||
public void sendItemStorageToClient() {
|
public void sendItemStorageToClient() {
|
||||||
worldObj.getMinecraftServer().getPlayerList().getPlayerList().stream()
|
worldObj.getMinecraftServer().getPlayerList().getPlayerList().stream()
|
||||||
.filter(this::isWatchingGrid)
|
.filter(player -> isWatchingGrid(player, EnumGridType.NORMAL, EnumGridType.CRAFTING, EnumGridType.PATTERN))
|
||||||
.forEach(this::sendItemStorageToClient);
|
.forEach(this::sendItemStorageToClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendItemStorageToClient(EntityPlayerMP player) {
|
public void sendItemStorageToClient(EntityPlayerMP player) {
|
||||||
RefinedStorage.INSTANCE.network.sendTo(new MessageGridUpdate(this), player);
|
RefinedStorage.INSTANCE.network.sendTo(new MessageGridItemUpdate(this), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendItemStorageDeltaToClient(ItemStack stack, int delta) {
|
public void sendItemStorageDeltaToClient(ItemStack stack, int delta) {
|
||||||
worldObj.getMinecraftServer().getPlayerList().getPlayerList().stream()
|
worldObj.getMinecraftServer().getPlayerList().getPlayerList().stream()
|
||||||
.filter(this::isWatchingGrid)
|
.filter(player -> isWatchingGrid(player, EnumGridType.NORMAL, EnumGridType.CRAFTING, EnumGridType.PATTERN))
|
||||||
.forEach(player -> RefinedStorage.INSTANCE.network.sendTo(new MessageGridDelta(this, stack, delta), player));
|
.forEach(player -> RefinedStorage.INSTANCE.network.sendTo(new MessageGridItemDelta(this, stack, delta), player));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWatchingGrid(EntityPlayer player) {
|
@Override
|
||||||
return player.openContainer.getClass() == ContainerGrid.class && pos.equals(((ContainerGrid) player.openContainer).getGrid().getNetworkPosition());
|
public void sendFluidStorageToClient() {
|
||||||
|
worldObj.getMinecraftServer().getPlayerList().getPlayerList().stream()
|
||||||
|
.filter(player -> isWatchingGrid(player, EnumGridType.FLUID))
|
||||||
|
.forEach(this::sendFluidStorageToClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendFluidStorageToClient(EntityPlayerMP player) {
|
||||||
|
RefinedStorage.INSTANCE.network.sendTo(new MessageGridFluidUpdate(this), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendFluidStorageDeltaToClient(FluidStack stack, int delta) {
|
||||||
|
worldObj.getMinecraftServer().getPlayerList().getPlayerList().stream()
|
||||||
|
.filter(player -> isWatchingGrid(player, EnumGridType.FLUID))
|
||||||
|
.forEach(player -> RefinedStorage.INSTANCE.network.sendTo(new MessageGridFluidDelta(stack, delta), player));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isWatchingGrid(EntityPlayer player, EnumGridType... types) {
|
||||||
|
if (player.openContainer.getClass() == ContainerGrid.class) {
|
||||||
|
IGrid grid = ((ContainerGrid) player.openContainer).getGrid();
|
||||||
|
|
||||||
|
if (pos.equals(grid.getNetworkPosition())) {
|
||||||
|
return Arrays.asList(types).contains(grid.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -190,9 +190,13 @@ public class TileGrid extends TileNode implements IGrid {
|
|||||||
|
|
||||||
public void onGridOpened(EntityPlayer player) {
|
public void onGridOpened(EntityPlayer player) {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
|
if (getType() == EnumGridType.FLUID) {
|
||||||
|
network.sendFluidStorageToClient((EntityPlayerMP) player);
|
||||||
|
} else {
|
||||||
network.sendItemStorageToClient((EntityPlayerMP) player);
|
network.sendItemStorageToClient((EntityPlayerMP) player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemGridHandler getHandler() {
|
public IItemGridHandler getHandler() {
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ block.refinedstorage:cable.name=Cable
|
|||||||
block.refinedstorage:grid.0.name=Grid
|
block.refinedstorage:grid.0.name=Grid
|
||||||
block.refinedstorage:grid.1.name=Crafting Grid
|
block.refinedstorage:grid.1.name=Crafting Grid
|
||||||
block.refinedstorage:grid.2.name=Pattern Grid
|
block.refinedstorage:grid.2.name=Pattern Grid
|
||||||
|
block.refinedstorage:grid.3.name=Fluid Grid
|
||||||
block.refinedstorage:disk_drive.name=Disk Drive
|
block.refinedstorage:disk_drive.name=Disk Drive
|
||||||
block.refinedstorage:external_storage.name=External Storage
|
block.refinedstorage:external_storage.name=External Storage
|
||||||
block.refinedstorage:importer.name=Importer
|
block.refinedstorage:importer.name=Importer
|
||||||
|
|||||||
BIN
src/main/resources/assets/refinedstorage/textures/gui/fluid_grid.png
Executable file
BIN
src/main/resources/assets/refinedstorage/textures/gui/fluid_grid.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user