speed upgrades on interface

This commit is contained in:
Raoul Van den Berge
2016-04-28 21:24:16 +02:00
parent a0521a0fda
commit 6fdb895b1d
7 changed files with 28 additions and 38 deletions

View File

@@ -9,6 +9,7 @@ import refinedstorage.container.slot.SlotFiltered;
import refinedstorage.container.slot.SlotOutput; import refinedstorage.container.slot.SlotOutput;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
import refinedstorage.item.ItemPattern; import refinedstorage.item.ItemPattern;
import refinedstorage.item.ItemUpgrade;
import refinedstorage.tile.TileInterface; import refinedstorage.tile.TileInterface;
public class ContainerInterface extends ContainerBase { public class ContainerInterface extends ContainerBase {
@@ -27,16 +28,16 @@ public class ContainerInterface extends ContainerBase {
addSlotToContainer(new SlotOutput(tile, i, 8 + (18 * (i - 18)), 100)); addSlotToContainer(new SlotOutput(tile, i, 8 + (18 * (i - 18)), 100));
} }
for (int i = 27; i < 27 + 9; ++i) { for (int i = 0; i < 4; ++i) {
addSlotToContainer(new SlotFiltered(tile, i, 8 + (18 * (i - 27)), 134, new IItemValidator() { addSlotToContainer(new SlotFiltered(tile.getUpgradesInventory(), i, 187, 6 + (i * 18), new IItemValidator() {
@Override @Override
public boolean isValid(ItemStack stack) { public boolean isValid(ItemStack stack) {
return stack.getItem() == RefinedStorageItems.PATTERN && ItemPattern.hasResult(stack); return stack.getItem() == RefinedStorageItems.UPGRADE && stack.getMetadata() == ItemUpgrade.TYPE_SPEED;
} }
})); }));
} }
addPlayerInventory(8, 168); addPlayerInventory(8, 134);
} }
@Override @Override

View File

@@ -10,7 +10,7 @@ public class GuiInterface extends GuiBase {
private TileInterface tile; private TileInterface tile;
public GuiInterface(ContainerInterface container, TileInterface tile) { public GuiInterface(ContainerInterface container, TileInterface tile) {
super(container, 176, 250); super(container, 211, 217);
this.tile = tile; this.tile = tile;
} }
@@ -38,7 +38,6 @@ public class GuiInterface extends GuiBase {
public void drawForeground(int mouseX, int mouseY) { public void drawForeground(int mouseX, int mouseY) {
drawString(7, 7, t("gui.refinedstorage:interface.import")); drawString(7, 7, t("gui.refinedstorage:interface.import"));
drawString(7, 42, t("gui.refinedstorage:interface.export")); drawString(7, 42, t("gui.refinedstorage:interface.export"));
drawString(7, 122, t("gui.refinedstorage:interface.patterns")); drawString(7, 122, t("container.inventory"));
drawString(7, 156, t("container.inventory"));
} }
} }

View File

@@ -243,20 +243,6 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
public List<ItemStack> getPatterns() { public List<ItemStack> getPatterns() {
List<ItemStack> patterns = new ArrayList<ItemStack>(); List<ItemStack> patterns = new ArrayList<ItemStack>();
for (TileMachine machine : machines) {
if (machine instanceof TileInterface) {
TileInterface tile = (TileInterface) machine;
for (int i = 27; i < 27 + 9; ++i) {
ItemStack pattern = tile.getStackInSlot(i);
if (pattern != null) {
patterns.add(pattern);
}
}
}
}
return patterns; return patterns;
} }

View File

@@ -17,8 +17,6 @@ import refinedstorage.util.InventoryUtils;
public class TileInterface extends TileMachine implements ICompareConfig, ISidedInventory { public class TileInterface extends TileMachine implements ICompareConfig, ISidedInventory {
public static final String NBT_COMPARE = "Compare"; public static final String NBT_COMPARE = "Compare";
public static final int SPEED = 3;
public static final int[] FACES = new int[]{ public static final int[] FACES = new int[]{
0, 1, 2, 3, 4, 5, 6, 7, 8 0, 1, 2, 3, 4, 5, 6, 7, 8
}; };
@@ -26,7 +24,8 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
18, 19, 20, 21, 22, 23, 24, 25, 26 18, 19, 20, 21, 22, 23, 24, 25, 26
}; };
private InventorySimple inventory = new InventorySimple("interface", 9 * 4, this); private InventorySimple inventory = new InventorySimple("interface", 9 * 3, this);
private InventorySimple upgradesInventory = new InventorySimple("upgrades", 4, this);
private int compare = 0; private int compare = 0;
@@ -37,6 +36,18 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
return 4; return 4;
} }
public int getSpeed() {
int upgrades = 0;
for (int i = 0; i < upgradesInventory.getSizeInventory(); ++i) {
if (upgradesInventory.getStackInSlot(i) != null) {
upgrades++;
}
}
return 9 - (upgrades * 2);
}
@Override @Override
public void updateMachine() { public void updateMachine() {
if (currentSlot > 8) { if (currentSlot > 8) {
@@ -48,7 +59,7 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
if (slot == null) { if (slot == null) {
currentSlot++; currentSlot++;
} else { } else {
if (ticks % SPEED == 0) { if (ticks % getSpeed() == 0) {
ItemStack toPush = slot.copy(); ItemStack toPush = slot.copy();
toPush.stackSize = 1; toPush.stackSize = 1;
@@ -108,6 +119,7 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
super.readFromNBT(nbt); super.readFromNBT(nbt);
InventoryUtils.restoreInventory(this, 0, nbt); InventoryUtils.restoreInventory(this, 0, nbt);
InventoryUtils.restoreInventory(upgradesInventory, 1, nbt);
if (nbt.hasKey(NBT_COMPARE)) { if (nbt.hasKey(NBT_COMPARE)) {
compare = nbt.getInteger(NBT_COMPARE); compare = nbt.getInteger(NBT_COMPARE);
@@ -119,10 +131,15 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
super.writeToNBT(nbt); super.writeToNBT(nbt);
InventoryUtils.saveInventory(this, 0, nbt); InventoryUtils.saveInventory(this, 0, nbt);
InventoryUtils.saveInventory(upgradesInventory, 1, nbt);
nbt.setInteger(NBT_COMPARE, compare); nbt.setInteger(NBT_COMPARE, compare);
} }
public InventorySimple getUpgradesInventory() {
return upgradesInventory;
}
@Override @Override
public void receiveContainerData(ByteBuf buf) { public void receiveContainerData(ByteBuf buf) {
super.receiveContainerData(buf); super.receiveContainerData(buf);
@@ -227,17 +244,6 @@ public class TileInterface extends TileMachine implements ICompareConfig, ISided
return inventory.getDisplayName(); return inventory.getDisplayName();
} }
@Override
public IInventory getDroppedInventory() {
InventorySimple dummy = new InventorySimple("dummy", 9);
for (int i = 0; i < 9; ++i) {
dummy.setInventorySlotContents(i, inventory.getStackInSlot(18 + i));
}
return dummy;
}
@Override @Override
public int[] getSlotsForFace(EnumFacing side) { public int[] getSlotsForFace(EnumFacing side) {
return side == EnumFacing.DOWN ? FACES_DOWN : FACES; return side == EnumFacing.DOWN ? FACES_DOWN : FACES;

View File

@@ -20,7 +20,6 @@ gui.refinedstorage:constructor=Constructor
gui.refinedstorage:relay=Relay gui.refinedstorage:relay=Relay
gui.refinedstorage:interface.import=Interface Import gui.refinedstorage:interface.import=Interface Import
gui.refinedstorage:interface.export=Interface Export gui.refinedstorage:interface.export=Interface Export
gui.refinedstorage:interface.patterns=Patterns
gui.refinedstorage:crafting_monitor=Crafting Monitor gui.refinedstorage:crafting_monitor=Crafting Monitor
gui.refinedstorage:wireless_transmitter=Wireless Transmitter gui.refinedstorage:wireless_transmitter=Wireless Transmitter
gui.refinedstorage:wireless_transmitter.distance=%d blocks gui.refinedstorage:wireless_transmitter.distance=%d blocks

View File

@@ -20,7 +20,6 @@ gui.refinedstorage:constructor=Constructor
gui.refinedstorage:relay=Relais gui.refinedstorage:relay=Relais
gui.refinedstorage:interface.import=Interface Import gui.refinedstorage:interface.import=Interface Import
gui.refinedstorage:interface.export=Interface Export gui.refinedstorage:interface.export=Interface Export
gui.refinedstorage:interface.patterns=Patronen
gui.refinedstorage:crafting_monitor=Crafting Monitor gui.refinedstorage:crafting_monitor=Crafting Monitor
gui.refinedstorage:wireless_transmitter=Draadloze Zender gui.refinedstorage:wireless_transmitter=Draadloze Zender
gui.refinedstorage:wireless_transmitter.distance=%d blokken gui.refinedstorage:wireless_transmitter.distance=%d blokken

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB