Solderer can probably use some speed upgradability too

This commit is contained in:
Raoul Van den Berge
2016-05-04 21:52:56 +02:00
parent fe1f7e0f2a
commit 3f5c902086
4 changed files with 39 additions and 4 deletions

View File

@@ -3,7 +3,11 @@ package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import refinedstorage.RefinedStorageItems;
import refinedstorage.container.slot.IItemValidator;
import refinedstorage.container.slot.SlotFiltered;
import refinedstorage.container.slot.SlotOutput; import refinedstorage.container.slot.SlotOutput;
import refinedstorage.item.ItemUpgrade;
import refinedstorage.tile.TileSolderer; import refinedstorage.tile.TileSolderer;
public class ContainerSolderer extends ContainerBase { public class ContainerSolderer extends ContainerBase {
@@ -21,6 +25,15 @@ public class ContainerSolderer extends ContainerBase {
addSlotToContainer(new SlotOutput(solderer, 3, 134, 38)); addSlotToContainer(new SlotOutput(solderer, 3, 134, 38));
for (int i = 0; i < 4; ++i) {
addSlotToContainer(new SlotFiltered(solderer.getUpgradesInventory(), i, 187, 6 + (i * 18), new IItemValidator() {
@Override
public boolean isValid(ItemStack stack) {
return stack.getItem() == RefinedStorageItems.UPGRADE && stack.getMetadata() == ItemUpgrade.TYPE_SPEED;
}
}));
}
addPlayerInventory(8, 95); addPlayerInventory(8, 95);
} }

View File

@@ -8,7 +8,7 @@ public class GuiSolderer extends GuiBase {
private TileSolderer solderer; private TileSolderer solderer;
public GuiSolderer(ContainerSolderer container, TileSolderer solderer) { public GuiSolderer(ContainerSolderer container, TileSolderer solderer) {
super(container, 176, 177); super(container, 211, 177);
this.solderer = solderer; this.solderer = solderer;
} }
@@ -29,7 +29,7 @@ public class GuiSolderer extends GuiBase {
drawTexture(x, y, 0, 0, width, height); drawTexture(x, y, 0, 0, width, height);
if (solderer.isWorking()) { if (solderer.isWorking()) {
drawTexture(x + 83, y + 40 - 1, 177, 0, solderer.getProgressScaled(22), 15); drawTexture(x + 83, y + 40 - 1, 212, 0, solderer.getProgressScaled(22), 15);
} }
} }

View File

@@ -27,6 +27,7 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
}; };
private InventorySimple inventory = new InventorySimple("solderer", 4, this); private InventorySimple inventory = new InventorySimple("solderer", 4, this);
private InventorySimple upgradesInventory = new InventorySimple("upgrades", 4, this);
private ISoldererRecipe recipe; private ISoldererRecipe recipe;
@@ -56,9 +57,9 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
markDirty(); markDirty();
} }
} else if (working) { } else if (working) {
progress++; progress += getSpeed();
if (progress == recipe.getDuration()) { if (progress >= recipe.getDuration()) {
if (inventory.getStackInSlot(3) != null) { if (inventory.getStackInSlot(3) != null) {
inventory.getStackInSlot(3).stackSize += recipe.getResult().stackSize; inventory.getStackInSlot(3).stackSize += recipe.getResult().stackSize;
} else { } else {
@@ -76,6 +77,18 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
} }
} }
public int getSpeed() {
int speed = 1;
for (int i = 0; i < upgradesInventory.getSizeInventory(); ++i) {
if (upgradesInventory.getStackInSlot(i) != null) {
speed += 1;
}
}
return speed;
}
@Override @Override
public void onDisconnected() { public void onDisconnected() {
super.onDisconnected(); super.onDisconnected();
@@ -96,6 +109,7 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
super.readFromNBT(nbt); super.readFromNBT(nbt);
InventoryUtils.restoreInventory(this, 0, nbt); InventoryUtils.restoreInventory(this, 0, nbt);
InventoryUtils.restoreInventory(upgradesInventory, 1, nbt);
recipe = SoldererRegistry.getRecipe(inventory); recipe = SoldererRegistry.getRecipe(inventory);
@@ -113,6 +127,7 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
super.writeToNBT(nbt); super.writeToNBT(nbt);
InventoryUtils.saveInventory(this, 0, nbt); InventoryUtils.saveInventory(this, 0, nbt);
InventoryUtils.saveInventory(upgradesInventory, 1, nbt);
nbt.setBoolean(NBT_WORKING, working); nbt.setBoolean(NBT_WORKING, working);
nbt.setInteger(NBT_PROGRESS, progress); nbt.setInteger(NBT_PROGRESS, progress);
@@ -164,6 +179,9 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
} }
public int getProgressScaled(int i) { public int getProgressScaled(int i) {
if (progress > duration) {
return i;
}
return (int) ((float) progress / (float) duration * (float) i); return (int) ((float) progress / (float) duration * (float) i);
} }
@@ -271,4 +289,8 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing direction) { public boolean canExtractItem(int slot, ItemStack stack, EnumFacing direction) {
return slot == 3; return slot == 3;
} }
public InventorySimple getUpgradesInventory() {
return upgradesInventory;
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB