fix some todos

This commit is contained in:
Raoul Van den Berge
2015-12-13 20:13:36 +01:00
parent 7f594b5e36
commit 129e5a5428
8 changed files with 121 additions and 69 deletions

View File

@@ -2,8 +2,8 @@ package storagecraft.inventory;
import net.minecraft.entity.player.EntityPlayer;
import storagecraft.SCItems;
import storagecraft.inventory.slot.SlotDrive;
import storagecraft.tile.TileDrive;
import storagecraft.inventory.slot.SlotItemFilter;
public class ContainerDrive extends ContainerSC {
public ContainerDrive(EntityPlayer player, TileDrive drive) {
@@ -15,7 +15,7 @@ public class ContainerDrive extends ContainerSC {
int y = 20;
for (int i = 0; i < 8; ++i) {
addSlotToContainer(new SlotItemFilter(drive, i, x, y, SCItems.STORAGE_CELL, drive));
addSlotToContainer(new SlotDrive(drive, i, x, y, SCItems.STORAGE_CELL, drive));
if ((i + 1) % 2 == 0) {
x = 71;

View File

@@ -0,0 +1,28 @@
package storagecraft.inventory.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import storagecraft.tile.TileDrive;
public class SlotDrive extends SlotItemFilter {
private TileDrive drive;
public SlotDrive(IInventory inventory, int id, int x, int y, Item item, TileDrive drive) {
super(inventory, id, x, y, item);
this.drive = drive;
}
@Override
public boolean isItemValid(ItemStack item) {
return drive.isConnected() && super.isItemValid(item);
}
@Override
public void onSlotChanged() {
super.onSlotChanged();
drive.getController().getStorage().sync();
}
}

View File

@@ -4,30 +4,18 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import storagecraft.tile.TileDrive;
// @TODO: make special SlotDrive
public class SlotItemFilter extends Slot {
private Item item;
private TileDrive dr;
public SlotItemFilter(IInventory inventory, int id, int x, int y, Item item, TileDrive dr) {
public SlotItemFilter(IInventory inventory, int id, int x, int y, Item item) {
super(inventory, id, x, y);
this.item = item;
this.dr = dr;
}
@Override
public boolean isItemValid(ItemStack item) {
return dr.isConnected() && item.getItem() == this.item;
}
@Override
public void onSlotChanged() {
super.onSlotChanged();
dr.getController().getStorage().sync();
return item.getItem() == this.item;
}
}