Make entire gui pkg compile

This commit is contained in:
raoulvdberge
2019-09-11 19:56:35 +02:00
parent 944fc5e759
commit 26a35a2ce3
10 changed files with 93 additions and 104 deletions

View File

@@ -22,7 +22,7 @@ public class GuiController extends GuiBase<ContainerController> {
private int barWidth = 16; private int barWidth = 16;
private int barHeight = 59; private int barHeight = 59;
public GuiController(ContainerController container, PlayerInventory inventory, TileController controller) { public GuiController(ContainerController container, TileController controller, PlayerInventory inventory) {
super(container, 176, 181, inventory, null); super(container, 176, 181, inventory, null);
this.controller = controller; this.controller = controller;

View File

@@ -23,7 +23,7 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
private TextFieldSearch searchField; private TextFieldSearch searchField;
public GuiCrafterManager(PlayerInventory inventory, NetworkNodeCrafterManager crafterManager) { public GuiCrafterManager(NetworkNodeCrafterManager crafterManager, PlayerInventory inventory) {
super(null, 193, 0, inventory, null); super(null, 193, 0, inventory, null);
this.crafterManager = crafterManager; this.crafterManager = crafterManager;

View File

@@ -8,15 +8,14 @@ import com.raoulvdberge.refinedstorage.tile.*;
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor; import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.WirelessCraftingMonitor; import com.raoulvdberge.refinedstorage.tile.craftingmonitor.WirelessCraftingMonitor;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler; import net.minecraftforge.fml.common.network.IGuiHandler;
public class GuiHandler implements IGuiHandler { public class GuiHandler implements IGuiHandler {
private Container getContainer(int ID, PlayerEntity player, TileEntity tile) { private Object getContainer(int ID, PlayerEntity player, TileEntity tile) {
switch (ID) { switch (ID) {
case RSGui.CONTROLLER: case RSGui.CONTROLLER:
return new ContainerController((TileController) tile, player); return new ContainerController((TileController) tile, player);
@@ -84,58 +83,59 @@ public class GuiHandler implements IGuiHandler {
switch (ID) { switch (ID) {
case RSGui.CONTROLLER: case RSGui.CONTROLLER:
return new GuiController((ContainerController) getContainer(ID, player, tile), (TileController) tile); return new GuiController((ContainerController) getContainer(ID, player, tile), (TileController) tile, player.inventory);
case RSGui.DISK_DRIVE: case RSGui.DISK_DRIVE:
return new GuiStorage((ContainerDiskDrive) getContainer(ID, player, tile), ((TileDiskDrive) tile).getNode(), "gui/disk_drive.png"); return new GuiStorage((ContainerDiskDrive) getContainer(ID, player, tile), ((TileDiskDrive) tile).getNode(), "gui/disk_drive.png", player.inventory);
case RSGui.IMPORTER: case RSGui.IMPORTER:
return new GuiImporter((ContainerImporter) getContainer(ID, player, tile)); return new GuiImporter((ContainerImporter) getContainer(ID, player, tile), player.inventory);
case RSGui.EXPORTER: case RSGui.EXPORTER:
return new GuiExporter((ContainerExporter) getContainer(ID, player, tile)); return new GuiExporter((ContainerExporter) getContainer(ID, player, tile), player.inventory);
case RSGui.DETECTOR: case RSGui.DETECTOR:
return new GuiDetector((ContainerDetector) getContainer(ID, player, tile)); return new GuiDetector((ContainerDetector) getContainer(ID, player, tile), player.inventory);
case RSGui.DESTRUCTOR: case RSGui.DESTRUCTOR:
return new GuiDestructor((ContainerDestructor) getContainer(ID, player, tile)); return new GuiDestructor((ContainerDestructor) getContainer(ID, player, tile), player.inventory);
case RSGui.CONSTRUCTOR: case RSGui.CONSTRUCTOR:
return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile)); return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile), player.inventory);
case RSGui.STORAGE: case RSGui.STORAGE:
return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), ((TileStorage) tile).getNode()); return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), ((TileStorage) tile).getNode(), player.inventory);
case RSGui.EXTERNAL_STORAGE: case RSGui.EXTERNAL_STORAGE:
return new GuiStorage((ContainerExternalStorage) getContainer(ID, player, tile), ((TileExternalStorage) tile).getNode()); return new GuiStorage((ContainerExternalStorage) getContainer(ID, player, tile), ((TileExternalStorage) tile).getNode(), player.inventory);
case RSGui.RELAY: case RSGui.RELAY:
return new GuiRelay((ContainerRelay) getContainer(ID, player, tile)); return new GuiRelay((ContainerRelay) getContainer(ID, player, tile), player.inventory);
case RSGui.INTERFACE: case RSGui.INTERFACE:
return new GuiInterface((ContainerInterface) getContainer(ID, player, tile)); return new GuiInterface((ContainerInterface) getContainer(ID, player, tile), player.inventory);
case RSGui.CRAFTING_MONITOR: { case RSGui.CRAFTING_MONITOR: {
NetworkNodeCraftingMonitor node = ((TileCraftingMonitor) tile).getNode(); NetworkNodeCraftingMonitor node = ((TileCraftingMonitor) tile).getNode();
GuiCraftingMonitor gui = new GuiCraftingMonitor(null, node);
gui.inventorySlots = new ContainerCraftingMonitor(node, (TileCraftingMonitor) tile, player); return new GuiCraftingMonitor(new ContainerCraftingMonitor(node, (TileCraftingMonitor) tile, player), node, player.inventory);
return gui;
} }
case RSGui.WIRELESS_TRANSMITTER: case RSGui.WIRELESS_TRANSMITTER:
return new GuiWirelessTransmitter((ContainerWirelessTransmitter) getContainer(ID, player, tile)); return new GuiWirelessTransmitter((ContainerWirelessTransmitter) getContainer(ID, player, tile), player.inventory);
case RSGui.CRAFTER: case RSGui.CRAFTER:
return new GuiCrafter((ContainerCrafter) getContainer(ID, player, tile)); return new GuiCrafter((ContainerCrafter) getContainer(ID, player, tile), player.inventory);
case RSGui.FILTER: case RSGui.FILTER:
return new GuiFilter(getFilterContainer(player, x)); return new GuiFilter(getFilterContainer(player, x), player.inventory);
case RSGui.NETWORK_TRANSMITTER: case RSGui.NETWORK_TRANSMITTER:
return new GuiNetworkTransmitter((ContainerNetworkTransmitter) getContainer(ID, player, tile), (TileNetworkTransmitter) tile); return new GuiNetworkTransmitter((ContainerNetworkTransmitter) getContainer(ID, player, tile), (TileNetworkTransmitter) tile, player.inventory);
case RSGui.FLUID_INTERFACE: case RSGui.FLUID_INTERFACE:
return new GuiFluidInterface((ContainerFluidInterface) getContainer(ID, player, tile)); return new GuiFluidInterface((ContainerFluidInterface) getContainer(ID, player, tile), player.inventory);
case RSGui.FLUID_STORAGE: case RSGui.FLUID_STORAGE:
return new GuiStorage((ContainerFluidStorage) getContainer(ID, player, tile), ((TileFluidStorage) tile).getNode()); return new GuiStorage((ContainerFluidStorage) getContainer(ID, player, tile), ((TileFluidStorage) tile).getNode(), player.inventory);
case RSGui.DISK_MANIPULATOR: case RSGui.DISK_MANIPULATOR:
return new GuiDiskManipulator((ContainerDiskManipulator) getContainer(ID, player, tile)); return new GuiDiskManipulator((ContainerDiskManipulator) getContainer(ID, player, tile), player.inventory);
case RSGui.WIRELESS_CRAFTING_MONITOR: case RSGui.WIRELESS_CRAFTING_MONITOR:
return getWirelessCraftingMonitorGui(player, x); return getWirelessCraftingMonitorGui(player, x);
case RSGui.READER_WRITER: case RSGui.READER_WRITER:
return new GuiReaderWriter((ContainerReaderWriter) getContainer(ID, player, tile), (IGuiReaderWriter) ((TileNode) tile).getNode()); return new GuiReaderWriter((ContainerReaderWriter) getContainer(ID, player, tile), (IGuiReaderWriter) ((TileNode) tile).getNode(), player.inventory);
case RSGui.SECURITY_MANAGER: case RSGui.SECURITY_MANAGER:
return new GuiSecurityManager((ContainerSecurityManager) getContainer(ID, player, tile), (TileSecurityManager) tile); return new GuiSecurityManager((ContainerSecurityManager) getContainer(ID, player, tile), (TileSecurityManager) tile, player.inventory);
case RSGui.STORAGE_MONITOR: case RSGui.STORAGE_MONITOR:
return new GuiStorageMonitor((ContainerStorageMonitor) getContainer(ID, player, tile)); return new GuiStorageMonitor((ContainerStorageMonitor) getContainer(ID, player, tile), player.inventory);
case RSGui.CRAFTER_MANAGER: case RSGui.CRAFTER_MANAGER:
GuiCrafterManager crafterManagerGui = new GuiCrafterManager(((TileCrafterManager) tile).getNode()); GuiCrafterManager crafterManagerGui = new GuiCrafterManager(((TileCrafterManager) tile).getNode(), player.inventory);
crafterManagerGui.setContainer(new ContainerCrafterManager((TileCrafterManager) tile, player, crafterManagerGui)); crafterManagerGui.setContainer(new ContainerCrafterManager((TileCrafterManager) tile, player, crafterManagerGui));
return crafterManagerGui; return crafterManagerGui;
default: default:
return null; return null;
@@ -149,9 +149,7 @@ public class GuiHandler implements IGuiHandler {
private GuiCraftingMonitor getWirelessCraftingMonitorGui(PlayerEntity player, int invIndex) { private GuiCraftingMonitor getWirelessCraftingMonitorGui(PlayerEntity player, int invIndex) {
WirelessCraftingMonitor craftingMonitor = getWirelessCraftingMonitor(player, invIndex); WirelessCraftingMonitor craftingMonitor = getWirelessCraftingMonitor(player, invIndex);
GuiCraftingMonitor gui = new GuiCraftingMonitor(null, craftingMonitor); return new GuiCraftingMonitor(new ContainerCraftingMonitor(craftingMonitor, null, player), craftingMonitor, player.inventory);
gui.inventorySlots = new ContainerCraftingMonitor(craftingMonitor, null, player);
return gui;
} }
private ContainerCraftingMonitor getCraftingMonitorContainer(PlayerEntity player, int invIndex) { private ContainerCraftingMonitor getCraftingMonitorContainer(PlayerEntity player, int invIndex) {
@@ -159,6 +157,6 @@ public class GuiHandler implements IGuiHandler {
} }
private ContainerFilter getFilterContainer(PlayerEntity player, int hand) { private ContainerFilter getFilterContainer(PlayerEntity player, int hand) {
return new ContainerFilter(player, player.getHeldItem(EnumHand.values()[hand])); return new ContainerFilter(player, player.getHeldItem(Hand.values()[hand]));
} }
} }

View File

@@ -1,12 +1,10 @@
package com.raoulvdberge.refinedstorage.gui.grid; package com.raoulvdberge.refinedstorage.gui.grid;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.mojang.blaze3d.platform.GlStateManager;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.RSKeyBindings;
import com.raoulvdberge.refinedstorage.api.network.grid.GridType; import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid; import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
import com.raoulvdberge.refinedstorage.api.network.grid.IGridNetworkAware;
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
import com.raoulvdberge.refinedstorage.container.ContainerGrid; import com.raoulvdberge.refinedstorage.container.ContainerGrid;
import com.raoulvdberge.refinedstorage.gui.GuiBase; import com.raoulvdberge.refinedstorage.gui.GuiBase;
@@ -18,31 +16,22 @@ import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
import com.raoulvdberge.refinedstorage.gui.grid.view.GridViewFluid; import com.raoulvdberge.refinedstorage.gui.grid.view.GridViewFluid;
import com.raoulvdberge.refinedstorage.gui.grid.view.GridViewItem; import com.raoulvdberge.refinedstorage.gui.grid.view.GridViewItem;
import com.raoulvdberge.refinedstorage.gui.grid.view.IGridView; import com.raoulvdberge.refinedstorage.gui.grid.view.IGridView;
import com.raoulvdberge.refinedstorage.network.*;
import com.raoulvdberge.refinedstorage.tile.config.IType; import com.raoulvdberge.refinedstorage.tile.config.IType;
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid; import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid; import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid; import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid;
import com.raoulvdberge.refinedstorage.util.RenderUtils; import com.raoulvdberge.refinedstorage.util.RenderUtils;
import com.raoulvdberge.refinedstorage.util.TimeUtils; import com.raoulvdberge.refinedstorage.util.TimeUtils;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.init.SoundEvents; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.client.config.GuiCheckBox; import net.minecraftforge.fml.client.config.GuiCheckBox;
import net.minecraftforge.fml.common.FMLCommonHandler;
import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public class GuiGrid extends GuiBase implements IResizableDisplay { public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay {
private IGridView view; private IGridView view;
private TextFieldSearch searchField; private TextFieldSearch searchField;
@@ -56,8 +45,8 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
private int slotNumber; private int slotNumber;
public GuiGrid(ContainerGrid container, IGrid grid) { public GuiGrid(ContainerGrid container, IGrid grid, PlayerInventory inventory) {
super(container, 227, 0); super(container, 227, 0, inventory, null);
this.grid = grid; this.grid = grid;
this.view = grid.getGridType() == GridType.FLUID ? new GridViewFluid(this, getDefaultSorter(), getSorters()) : new GridViewItem(this, getDefaultSorter(), getSorters()); this.view = grid.getGridType() == GridType.FLUID ? new GridViewFluid(this, getDefaultSorter(), getSorters()) : new GridViewItem(this, getDefaultSorter(), getSorters());
@@ -84,7 +73,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
@Override @Override
public void init(int x, int y) { public void init(int x, int y) {
((ContainerGrid) this.inventorySlots).initSlots(); ((ContainerGrid) this.container).initSlots();
this.tabs.init(xSize - 32); this.tabs.init(xSize - 32);
@@ -98,7 +87,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
int sy = y + 6 + 1; int sy = y + 6 + 1;
if (searchField == null) { if (searchField == null) {
searchField = new TextFieldSearch(0, fontRenderer, sx, sy, 88 - 6); searchField = new TextFieldSearch(font, sx, sy, 88 - 6);
searchField.addListener(() -> { searchField.addListener(() -> {
this.getView().sort(); // Use getter since this view can be replaced. this.getView().sort(); // Use getter since this view can be replaced.
}); });
@@ -126,7 +115,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
} }
if (showOredict) { if (showOredict) {
oredictPattern = addCheckBox(processingPattern.x + processingPattern.width + 5, y + getTopHeight() + (getVisibleRows() * 18) + 60, t("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue()); oredictPattern = addCheckBox(processingPattern.x + processingPattern.getWidth() + 5, y + getTopHeight() + (getVisibleRows() * 18) + 60, t("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
} }
addSideButton(new SideButtonType(this, TileGrid.PROCESSING_TYPE)); addSideButton(new SideButtonType(this, TileGrid.PROCESSING_TYPE));
@@ -309,13 +298,13 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
tabs.drawForeground(x, y - tabs.getHeight(), mouseX, mouseY, true); tabs.drawForeground(x, y - tabs.getHeight(), mouseX, mouseY, true);
if (searchField != null) { if (searchField != null) {
searchField.drawTextBox(); searchField.render(0, 0, 0);
} }
} }
@Override @Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void render(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks); super.render(mouseX, mouseY, partialTicks);
// Drawn in here for bug #1844 (https://github.com/raoulvdberge/refinedstorage/issues/1844) // Drawn in here for bug #1844 (https://github.com/raoulvdberge/refinedstorage/issues/1844)
// Item tooltips can't be rendered in the foreground layer due to the X offset translation. // Item tooltips can't be rendered in the foreground layer due to the X offset translation.
@@ -351,14 +340,12 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
int color = grid.isActive() ? -2130706433 : 0xFF5B5B5B; int color = grid.isActive() ? -2130706433 : 0xFF5B5B5B;
GlStateManager.disableLighting(); GlStateManager.disableLighting();
GlStateManager.disableDepth(); GlStateManager.disableDepthTest();
zLevel = 190;
GlStateManager.colorMask(true, true, true, false); GlStateManager.colorMask(true, true, true, false);
drawGradientRect(x, y, x + 16, y + 16, color, color); fillGradient(x, y, x + 16, y + 16, color, color);
zLevel = 0;
GlStateManager.colorMask(true, true, true, true); GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableLighting(); GlStateManager.enableLighting();
GlStateManager.enableDepth(); GlStateManager.enableDepthTest();
} }
slot++; slot++;
@@ -379,7 +366,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:grid.pattern_create")); drawTooltip(mouseX, mouseY, t("gui.refinedstorage:grid.pattern_create"));
} }
tabs.drawTooltip(fontRenderer, mouseX, mouseY); tabs.drawTooltip(font, mouseX, mouseY);
} }
private void drawGridTooltip(IGridStack gridStack, int mouseX, int mouseY) { private void drawGridTooltip(IGridStack gridStack, int mouseX, int mouseY) {
@@ -396,9 +383,10 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
ItemStack stack = gridStack instanceof GridStackItem ? ((GridStackItem) gridStack).getStack() : ItemStack.EMPTY; ItemStack stack = gridStack instanceof GridStackItem ? ((GridStackItem) gridStack).getStack() : ItemStack.EMPTY;
RenderUtils.drawTooltipWithSmallText(textLines, smallTextLines, RS.INSTANCE.config.detailedTooltip, stack, mouseX, mouseY, screenWidth, screenHeight, fontRenderer); RenderUtils.drawTooltipWithSmallText(textLines, smallTextLines, RS.INSTANCE.config.detailedTooltip, stack, mouseX, mouseY, screenWidth, screenHeight, font);
} }
/* TODO
@Override @Override
protected void actionPerformed(GuiButton button) throws IOException { protected void actionPerformed(GuiButton button) throws IOException {
super.actionPerformed(button); super.actionPerformed(button);
@@ -497,7 +485,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
} else { } else {
super.keyTyped(character, keyCode); super.keyTyped(character, keyCode);
} }
} }*/
public TextFieldSearch getSearchField() { public TextFieldSearch getSearchField() {
return searchField; return searchField;

View File

@@ -1,21 +1,19 @@
package com.raoulvdberge.refinedstorage.gui.grid; package com.raoulvdberge.refinedstorage.gui.grid;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.container.ContainerCraftingSettings; import com.raoulvdberge.refinedstorage.container.ContainerCraftingSettings;
import com.raoulvdberge.refinedstorage.gui.GuiAmountSpecifying; import com.raoulvdberge.refinedstorage.gui.GuiAmountSpecifying;
import com.raoulvdberge.refinedstorage.gui.GuiBase; import com.raoulvdberge.refinedstorage.gui.GuiBase;
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid; import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack; import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreview;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidAttributes;
public class GuiGridCraftingSettings extends GuiAmountSpecifying { public class GuiGridCraftingSettings extends GuiAmountSpecifying<ContainerCraftingSettings> {
private IGridStack stack; private IGridStack stack;
public GuiGridCraftingSettings(GuiBase parent, PlayerEntity player, IGridStack stack) { public GuiGridCraftingSettings(GuiBase parent, PlayerEntity player, IGridStack stack) {
super(parent, new ContainerCraftingSettings(player, stack), 172, 99); super(parent, new ContainerCraftingSettings(player, stack), 172, 99, player.inventory);
this.stack = stack; this.stack = stack;
} }
@@ -26,7 +24,7 @@ public class GuiGridCraftingSettings extends GuiAmountSpecifying {
} }
@Override @Override
protected String getTitle() { protected String getGuiTitle() {
return t("container.crafting"); return t("container.crafting");
} }
@@ -52,7 +50,7 @@ public class GuiGridCraftingSettings extends GuiAmountSpecifying {
@Override @Override
protected int getDefaultAmount() { protected int getDefaultAmount() {
return stack instanceof GridStackFluid ? Fluid.BUCKET_VOLUME : 1; return stack instanceof GridStackFluid ? FluidAttributes.BUCKET_VOLUME : 1;
} }
@Override @Override
@@ -69,9 +67,9 @@ public class GuiGridCraftingSettings extends GuiAmountSpecifying {
Integer quantity = Ints.tryParse(amountField.getText()); Integer quantity = Ints.tryParse(amountField.getText());
if (quantity != null && quantity > 0) { if (quantity != null && quantity > 0) {
RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity, shiftDown, stack instanceof GridStackFluid)); // TODO RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity, shiftDown, stack instanceof GridStackFluid));
okButton.enabled = false; okButton.active = false; // TODO is active correct
} }
} }
} }

View File

@@ -6,7 +6,6 @@ import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem; import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack; import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import java.util.List; import java.util.List;
@@ -47,7 +46,7 @@ public class GridFilterFilter implements Predicate<IGridStack> {
FluidStack stackInFilter = (FluidStack) filter.getStack(); FluidStack stackInFilter = (FluidStack) filter.getStack();
if (filter.isModFilter()) { if (filter.isModFilter()) {
String stackInFilterModId = FluidRegistry.getModId(stackInFilter); String stackInFilterModId = /* TODO FluidRegistry.getModId(stackInFilter)*/"bla bla";
if (stackInFilterModId != null && stackInFilterModId.equalsIgnoreCase(stack.getModId())) { if (stackInFilterModId != null && stackInFilterModId.equalsIgnoreCase(stack.getModId())) {
return filter.getMode() == IFilter.MODE_WHITELIST; return filter.getMode() == IFilter.MODE_WHITELIST;

View File

@@ -1,15 +1,23 @@
package com.raoulvdberge.refinedstorage.gui.grid.sorting; package com.raoulvdberge.refinedstorage.gui.grid.sorting;
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid; import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack; import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
import invtweaks.api.InvTweaksAPI;
import net.minecraftforge.fml.common.Loader;
// TODO
public class GridSorterInventoryTweaks implements IGridSorter { public class GridSorterInventoryTweaks implements IGridSorter {
public static final String MOD_ID = "inventorytweaks"; public static final String MOD_ID = "inventorytweaks";
private InvTweaksAPI api = null; @Override
public boolean isApplicable(IGrid grid) {
return false;
}
@Override
public int compare(IGridStack left, IGridStack right, GridSorterDirection direction) {
return 0;
}
/* private InvTweaksAPI api = null;
public GridSorterInventoryTweaks() { public GridSorterInventoryTweaks() {
try { try {
@@ -35,6 +43,6 @@ public class GridSorterInventoryTweaks implements IGridSorter {
} }
return 0; return 0;
} }*/
} }

View File

@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.gui.GuiBase; import com.raoulvdberge.refinedstorage.gui.GuiBase;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -53,13 +52,14 @@ public class GridStackFluid implements IGridStack {
@Override @Override
public String getName() { public String getName() {
return stack.getFluid().getLocalizedName(stack); return stack.getDisplayName().getFormattedText(); // TODO correct method usage
} }
@Override @Override
public String getModId() { public String getModId() {
if (modId == null) { if (modId == null) {
modId = FluidRegistry.getModId(stack); // modId = FluidRegistry.getModId(stack);
modId = "dinosaur";//TODO
if (modId == null) { if (modId == null) {
modId = "???"; modId = "???";
@@ -84,17 +84,18 @@ public class GridStackFluid implements IGridStack {
@Override @Override
public String[] getOreIds() { public String[] getOreIds() {
return new String[]{stack.getFluid().getName()}; return new String[]{};
//return new String[]{stack.getFluid().getName()};
} }
@Override @Override
public String getTooltip() { public String getTooltip() {
return stack.getFluid().getLocalizedName(stack); return stack.getDisplayName().getFormattedText();//TODO
} }
@Override @Override
public int getQuantity() { public int getQuantity() {
return stack.amount; return stack.getAmount();
} }
@Override @Override
@@ -104,7 +105,7 @@ public class GridStackFluid implements IGridStack {
@Override @Override
public void draw(GuiBase gui, int x, int y) { public void draw(GuiBase gui, int x, int y) {
GuiBase.FLUID_RENDERER.draw(gui.mc, x, y, stack); GuiBase.FLUID_RENDERER.draw(gui.getMinecraft(), x, y, stack);
String text; String text;

View File

@@ -4,18 +4,12 @@ import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerEntry; import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerEntry;
import com.raoulvdberge.refinedstorage.gui.GuiBase; import com.raoulvdberge.refinedstorage.gui.GuiBase;
import com.raoulvdberge.refinedstorage.util.RenderUtils;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.stream.Collectors;
public class GridStackItem implements IGridStack { public class GridStackItem implements IGridStack {
private int hash; private int hash;
@@ -34,7 +28,7 @@ public class GridStackItem implements IGridStack {
this.stack = stack; this.stack = stack;
} }
public GridStackItem(ByteBuf buf) { public GridStackItem(PacketBuffer buf) {
this.stack = StackUtils.readItemStack(buf); this.stack = StackUtils.readItemStack(buf);
this.hash = buf.readInt(); this.hash = buf.readInt();
this.craftable = buf.readBoolean(); this.craftable = buf.readBoolean();
@@ -48,12 +42,13 @@ public class GridStackItem implements IGridStack {
@Nullable @Nullable
static String getModNameByModId(String modId) { static String getModNameByModId(String modId) {
ModContainer container = Loader.instance().getActiveModList().stream() /*ModContainer container = Loader.instance().getActiveModList().stream()
.filter(m -> m.getModId().toLowerCase().equals(modId)) .filter(m -> m.getModId().toLowerCase().equals(modId))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
return container == null ? null : container.getName(); return container == null ? null : container.getName();*/
return "dinosaur"; // TODO
} }
public ItemStack getStack() { public ItemStack getStack() {
@@ -88,7 +83,7 @@ public class GridStackItem implements IGridStack {
public String getName() { public String getName() {
try { try {
if (cachedName == null) { if (cachedName == null) {
cachedName = stack.getDisplayName(); cachedName = stack.getDisplayName().getFormattedText(); // TODO
} }
return cachedName; return cachedName;
@@ -129,7 +124,8 @@ public class GridStackItem implements IGridStack {
if (stack.isEmpty()) { if (stack.isEmpty()) {
oreIds = new String[]{}; oreIds = new String[]{};
} else { } else {
oreIds = Arrays.stream(OreDictionary.getOreIDs(stack)).mapToObj(OreDictionary::getOreName).toArray(String[]::new); oreIds = new String[]{};//TODO OreDict
//oreIds = Arrays.stream(OreDictionary.getOreIDs(stack)).mapToObj(OreDictionary::getOreName).toArray(String[]::new);
} }
} }
@@ -140,7 +136,8 @@ public class GridStackItem implements IGridStack {
public String getTooltip() { public String getTooltip() {
if (tooltip == null) { if (tooltip == null) {
try { try {
tooltip = RenderUtils.getItemTooltip(stack).stream().collect(Collectors.joining("\n")); tooltip = "dinosaur";//TODO
//tooltip = RenderUtils.getItemTooltip(stack).stream().collect(Collectors.joining("\n"));
} catch (Throwable t) { } catch (Throwable t) {
tooltip = ""; tooltip = "";
} }

View File

@@ -35,11 +35,11 @@ public class GridViewFluid extends GridViewBase {
GridStackFluid existing = (GridStackFluid) map.get(stack.getHash()); GridStackFluid existing = (GridStackFluid) map.get(stack.getHash());
if (existing == null) { if (existing == null) {
((GridStackFluid) stack).getStack().amount = delta; ((GridStackFluid) stack).getStack().setAmount(delta);
map.put(stack.getHash(), stack); map.put(stack.getHash(), stack);
} else { } else {
if (existing.getStack().amount + delta <= 0) { if (existing.getStack().getAmount() + delta <= 0) {
if (existing.isCraftable()) { if (existing.isCraftable()) {
existing.setDisplayCraftText(true); existing.setDisplayCraftText(true);
} else { } else {
@@ -49,9 +49,9 @@ public class GridViewFluid extends GridViewBase {
if (existing.doesDisplayCraftText()) { if (existing.doesDisplayCraftText()) {
existing.setDisplayCraftText(false); existing.setDisplayCraftText(false);
existing.getStack().amount = delta; existing.getStack().setAmount(delta);
} else { } else {
existing.getStack().amount += delta; existing.getStack().grow(delta);
} }
} }