Various code improvements
This commit is contained in:
@@ -10,15 +10,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ContainerGrid extends ContainerBase {
|
||||
private TileGrid grid;
|
||||
|
||||
private List<Slot> craftingSlots = new ArrayList<Slot>();
|
||||
|
||||
public ContainerGrid(EntityPlayer player, TileGrid grid) {
|
||||
super(player);
|
||||
|
||||
this.grid = grid;
|
||||
|
||||
addPlayerInventory(8, grid.getType() == EnumGridType.CRAFTING ? 174 : 108);
|
||||
|
||||
if (grid.getType() == EnumGridType.CRAFTING) {
|
||||
|
@@ -3,5 +3,5 @@ package refinedstorage.container.slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IItemValidator {
|
||||
public boolean isValid(ItemStack stack);
|
||||
boolean isValid(ItemStack stack);
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiController extends GuiBase {
|
||||
public static final int VISIBLE_ROWS = 2;
|
||||
|
||||
private TileController controller;
|
||||
|
||||
private int barX = 8;
|
||||
@@ -36,7 +38,7 @@ public class GuiController extends GuiBase {
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
scrollbar.setCanScroll(getRows() > getVisibleRows());
|
||||
scrollbar.setCanScroll(getRows() > VISIBLE_ROWS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,7 +49,7 @@ public class GuiController extends GuiBase {
|
||||
|
||||
int barHeightNew = (int) ((float) controller.getEnergyStored(null) / (float) controller.getMaxEnergyStored(null) * (float) barHeight);
|
||||
|
||||
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 178, 0 + (barHeight - barHeightNew), barWidth, barHeightNew);
|
||||
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 178, barHeight - barHeightNew, barWidth, barHeightNew);
|
||||
|
||||
scrollbar.draw(this);
|
||||
}
|
||||
@@ -115,8 +117,4 @@ public class GuiController extends GuiBase {
|
||||
|
||||
return max < 0 ? 0 : max;
|
||||
}
|
||||
|
||||
private int getVisibleRows() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
@@ -22,12 +22,11 @@ import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class GuiGrid extends GuiBase {
|
||||
public static final int VISIBLE_ROWS = 4;
|
||||
|
||||
private ContainerGrid container;
|
||||
private TileGrid grid;
|
||||
|
||||
@@ -62,17 +61,13 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
scrollbar.setCanScroll(getRows() > getVisibleRows());
|
||||
scrollbar.setCanScroll(getRows() > VISIBLE_ROWS);
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return (int) (scrollbar.getCurrentScroll() / 70f * (float) getRows());
|
||||
}
|
||||
|
||||
public int getVisibleRows() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int getRows() {
|
||||
if (!grid.isConnected()) {
|
||||
return 0;
|
||||
@@ -137,7 +132,7 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
for (int i = 0; i < 9 * getVisibleRows(); ++i) {
|
||||
for (int i = 0; i < 9 * VISIBLE_ROWS; ++i) {
|
||||
if (slot < items.size()) {
|
||||
int qty = items.get(slot).getQuantity();
|
||||
|
||||
@@ -218,7 +213,7 @@ public class GuiGrid extends GuiBase {
|
||||
}
|
||||
}
|
||||
|
||||
items.sort(new Comparator<StorageItem>() {
|
||||
Collections.sort(items, new Comparator<StorageItem>() {
|
||||
@Override
|
||||
public int compare(StorageItem o1, StorageItem o2) {
|
||||
if (o1 != null && o2 != null) {
|
||||
@@ -234,7 +229,7 @@ public class GuiGrid extends GuiBase {
|
||||
});
|
||||
|
||||
if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) {
|
||||
items.sort(new Comparator<StorageItem>() {
|
||||
Collections.sort(items, new Comparator<StorageItem>() {
|
||||
@Override
|
||||
public int compare(StorageItem o1, StorageItem o2) {
|
||||
if (o1 != null && o2 != null) {
|
||||
|
@@ -69,7 +69,7 @@ public class GuiStorage extends GuiBase {
|
||||
|
||||
int barHeightNew = (int) ((float) gui.getStored() / (float) gui.getCapacity() * (float) barHeight);
|
||||
|
||||
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 179, 0 + (barHeight - barHeightNew), barWidth, barHeightNew);
|
||||
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 179, barHeight - barHeightNew, barWidth, barHeightNew);
|
||||
|
||||
priorityField.drawTextBox();
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class GuiWirelessTransmitter extends GuiBase {
|
||||
if (wirelessTransmitter.isWorking()) {
|
||||
int progress = (int) ((float) wirelessTransmitter.getProgress() / (float) TileWirelessTransmitter.TOTAL_PROGRESS * 14f);
|
||||
|
||||
drawTexture(x + 36 - 1, y + 21 - 1 + progress, 178, 0 + progress, 14, 14);
|
||||
drawTexture(x + 36 - 1, y + 21 - 1 + progress, 178, progress, 14, 14);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,6 @@ public class SideButtonDetectorMode extends SideButton {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.GREEN).append(gui.t("sidebutton.refinedstorage:detector.mode")).append(TextFormatting.RESET).append("\n");
|
||||
|
||||
builder.append(gui.t("sidebutton.refinedstorage:detector.mode." + detector.getMode()));
|
||||
|
||||
return builder.toString();
|
||||
|
@@ -18,7 +18,6 @@ public class SideButtonGridSortingDirection extends SideButton {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:sorting.direction")).append(TextFormatting.RESET).append("\n");
|
||||
|
||||
builder.append(gui.t("sidebutton.refinedstorage:sorting.direction." + grid.getSortingDirection()));
|
||||
|
||||
return builder.toString();
|
||||
|
@@ -18,7 +18,6 @@ public class SideButtonGridSortingType extends SideButton {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:sorting.type")).append(TextFormatting.RESET).append("\n");
|
||||
|
||||
builder.append(gui.t("sidebutton.refinedstorage:sorting.type." + grid.getSortingType()));
|
||||
|
||||
return builder.toString();
|
||||
|
@@ -18,7 +18,6 @@ public class SideButtonMode extends SideButton {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.GREEN).append(gui.t("sidebutton.refinedstorage:mode")).append(TextFormatting.RESET).append("\n");
|
||||
|
||||
builder.append(gui.t("sidebutton.refinedstorage:mode." + (mode.isWhitelist() ? "whitelist" : "blacklist")));
|
||||
|
||||
return builder.toString();
|
||||
|
@@ -18,7 +18,6 @@ public class SideButtonRedstoneMode extends SideButton {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.RED).append(gui.t("sidebutton.refinedstorage:redstone_mode")).append(TextFormatting.RESET).append("\n");
|
||||
|
||||
builder.append(gui.t("sidebutton.refinedstorage:redstone_mode." + setting.getRedstoneMode().id));
|
||||
|
||||
return builder.toString();
|
||||
|
@@ -5,13 +5,13 @@ import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
|
||||
public interface IStorage {
|
||||
public void addItems(List<StorageItem> items);
|
||||
void addItems(List<StorageItem> items);
|
||||
|
||||
public void push(ItemStack stack);
|
||||
void push(ItemStack stack);
|
||||
|
||||
public ItemStack take(ItemStack stack, int flags);
|
||||
ItemStack take(ItemStack stack, int flags);
|
||||
|
||||
public boolean canPush(ItemStack stack);
|
||||
boolean canPush(ItemStack stack);
|
||||
|
||||
public int getPriority();
|
||||
int getPriority();
|
||||
}
|
||||
|
@@ -6,21 +6,21 @@ import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
|
||||
public interface IStorageGui {
|
||||
public String getName();
|
||||
String getName();
|
||||
|
||||
public int getPriority();
|
||||
int getPriority();
|
||||
|
||||
public void onPriorityChanged(int priority);
|
||||
void onPriorityChanged(int priority);
|
||||
|
||||
public IInventory getInventory();
|
||||
IInventory getInventory();
|
||||
|
||||
public IRedstoneModeSetting getRedstoneModeSetting();
|
||||
IRedstoneModeSetting getRedstoneModeSetting();
|
||||
|
||||
public ICompareSetting getCompareSetting();
|
||||
ICompareSetting getCompareSetting();
|
||||
|
||||
public IModeSetting getModeSetting();
|
||||
IModeSetting getModeSetting();
|
||||
|
||||
public int getStored();
|
||||
int getStored();
|
||||
|
||||
public int getCapacity();
|
||||
int getCapacity();
|
||||
}
|
||||
|
@@ -3,5 +3,5 @@ package refinedstorage.storage;
|
||||
import java.util.List;
|
||||
|
||||
public interface IStorageProvider {
|
||||
public void addStorages(List<IStorage> storages);
|
||||
void addStorages(List<IStorage> storages);
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface INetworkTile {
|
||||
public void fromBytes(ByteBuf buf);
|
||||
void fromBytes(ByteBuf buf);
|
||||
|
||||
public void toBytes(ByteBuf buf);
|
||||
void toBytes(ByteBuf buf);
|
||||
|
||||
public BlockPos getTilePos();
|
||||
BlockPos getTilePos();
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ import refinedstorage.tile.settings.RedstoneMode;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,7 +83,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
}
|
||||
}
|
||||
|
||||
storages.sort(new Comparator<IStorage>() {
|
||||
Collections.sort(storages, new Comparator<IStorage>() {
|
||||
@Override
|
||||
public int compare(IStorage s1, IStorage s2) {
|
||||
return (s1.getPriority() > s2.getPriority()) ? -1 : 1;
|
||||
|
@@ -3,9 +3,9 @@ package refinedstorage.tile.settings;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface ICompareSetting {
|
||||
public int getCompare();
|
||||
int getCompare();
|
||||
|
||||
public void setCompare(int compare);
|
||||
void setCompare(int compare);
|
||||
|
||||
public BlockPos getMachinePos();
|
||||
BlockPos getMachinePos();
|
||||
}
|
||||
|
@@ -3,13 +3,13 @@ package refinedstorage.tile.settings;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IModeSetting {
|
||||
public boolean isWhitelist();
|
||||
boolean isWhitelist();
|
||||
|
||||
public boolean isBlacklist();
|
||||
boolean isBlacklist();
|
||||
|
||||
public void setToWhitelist();
|
||||
void setToWhitelist();
|
||||
|
||||
public void setToBlacklist();
|
||||
void setToBlacklist();
|
||||
|
||||
public BlockPos getMachinePos();
|
||||
BlockPos getMachinePos();
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package refinedstorage.tile.settings;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IRedstoneModeSetting {
|
||||
public RedstoneMode getRedstoneMode();
|
||||
RedstoneMode getRedstoneMode();
|
||||
|
||||
public void setRedstoneMode(RedstoneMode mode);
|
||||
void setRedstoneMode(RedstoneMode mode);
|
||||
|
||||
public BlockPos getMachinePos();
|
||||
BlockPos getMachinePos();
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package refinedstorage.tile.solderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISoldererRecipe {
|
||||
public ItemStack getRow(int row);
|
||||
ItemStack getRow(int row);
|
||||
|
||||
public ItemStack getResult();
|
||||
ItemStack getResult();
|
||||
|
||||
public int getDuration();
|
||||
int getDuration();
|
||||
}
|
||||
|
Reference in New Issue
Block a user