Speed upgrade and crafting if needed on constructor
This commit is contained in:
@@ -6,7 +6,7 @@ WIP
|
|||||||
**TODO**
|
**TODO**
|
||||||
- Saving crafting task state
|
- Saving crafting task state
|
||||||
- Cancelling crafting tasks
|
- Cancelling crafting tasks
|
||||||
- "Craft if needed" upgrade on constructor and interface
|
- "Craft if needed" upgrade on interface
|
||||||
- Textures
|
- Textures
|
||||||
- Update wiki
|
- Update wiki
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package refinedstorage.container;
|
package refinedstorage.container;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import refinedstorage.RefinedStorageItems;
|
||||||
|
import refinedstorage.container.slot.IItemValidator;
|
||||||
|
import refinedstorage.container.slot.SlotFiltered;
|
||||||
import refinedstorage.container.slot.SlotSpecimenItemBlock;
|
import refinedstorage.container.slot.SlotSpecimenItemBlock;
|
||||||
|
import refinedstorage.item.ItemUpgrade;
|
||||||
import refinedstorage.tile.TileConstructor;
|
import refinedstorage.tile.TileConstructor;
|
||||||
|
|
||||||
public class ContainerConstructor extends ContainerBase {
|
public class ContainerConstructor extends ContainerBase {
|
||||||
@@ -11,6 +16,15 @@ public class ContainerConstructor extends ContainerBase {
|
|||||||
|
|
||||||
addSlotToContainer(new SlotSpecimenItemBlock(constructor.getInventory(), 0, 80, 20));
|
addSlotToContainer(new SlotSpecimenItemBlock(constructor.getInventory(), 0, 80, 20));
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
addSlotToContainer(new SlotFiltered(constructor.getUpgradesInventory(), i, 187, 6 + (i * 18), new IItemValidator() {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(ItemStack stack) {
|
||||||
|
return stack.getItem() == RefinedStorageItems.UPGRADE && (stack.getMetadata() == ItemUpgrade.TYPE_SPEED || stack.getMetadata() == ItemUpgrade.TYPE_CRAFTING);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
addPlayerInventory(8, 55);
|
addPlayerInventory(8, 55);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class GuiConstructor extends GuiBase {
|
|||||||
private TileConstructor constructor;
|
private TileConstructor constructor;
|
||||||
|
|
||||||
public GuiConstructor(ContainerConstructor container, TileConstructor constructor) {
|
public GuiConstructor(ContainerConstructor container, TileConstructor constructor) {
|
||||||
super(container, 176, 137);
|
super(container, 211, 137);
|
||||||
|
|
||||||
this.constructor = constructor;
|
this.constructor = constructor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import refinedstorage.container.ContainerConstructor;
|
import refinedstorage.container.ContainerConstructor;
|
||||||
import refinedstorage.inventory.InventorySimple;
|
import refinedstorage.inventory.InventorySimple;
|
||||||
|
import refinedstorage.tile.autocrafting.CraftingPattern;
|
||||||
import refinedstorage.tile.config.ICompareConfig;
|
import refinedstorage.tile.config.ICompareConfig;
|
||||||
import refinedstorage.util.InventoryUtils;
|
import refinedstorage.util.InventoryUtils;
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
public static final String NBT_COMPARE = "Compare";
|
public static final String NBT_COMPARE = "Compare";
|
||||||
|
|
||||||
private InventorySimple inventory = new InventorySimple("constructor", 1, this);
|
private InventorySimple inventory = new InventorySimple("constructor", 1, this);
|
||||||
|
private InventorySimple upgradesInventory = new InventorySimple("upgrades", 4, this);
|
||||||
|
|
||||||
private int compare = 0;
|
private int compare = 0;
|
||||||
|
|
||||||
@@ -29,7 +31,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMachine() {
|
public void updateMachine() {
|
||||||
if (ticks % SPEED == 0 && inventory.getStackInSlot(0) != null) {
|
if (ticks % TileInterface.getSpeed(upgradesInventory) == 0 && inventory.getStackInSlot(0) != null) {
|
||||||
BlockPos front = pos.offset(getDirection());
|
BlockPos front = pos.offset(getDirection());
|
||||||
|
|
||||||
Block tryingToPlace = ((ItemBlock) inventory.getStackInSlot(0).getItem()).getBlock();
|
Block tryingToPlace = ((ItemBlock) inventory.getStackInSlot(0).getItem()).getBlock();
|
||||||
@@ -39,6 +41,12 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
|
|
||||||
if (took != null) {
|
if (took != null) {
|
||||||
worldObj.setBlockState(front, tryingToPlace.getStateFromMeta(took.getItemDamage()), 1 | 2);
|
worldObj.setBlockState(front, tryingToPlace.getStateFromMeta(took.getItemDamage()), 1 | 2);
|
||||||
|
} else if (TileInterface.hasCrafting(upgradesInventory)) {
|
||||||
|
CraftingPattern pattern = controller.getPatternForItem(inventory.getStackInSlot(0).copy(), compare);
|
||||||
|
|
||||||
|
if (pattern != null && !controller.hasCraftingTaskWithPattern(pattern, compare)) {
|
||||||
|
controller.addCraftingTaskForPattern(pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,6 +73,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InventoryUtils.restoreInventory(inventory, 0, nbt);
|
InventoryUtils.restoreInventory(inventory, 0, nbt);
|
||||||
|
InventoryUtils.restoreInventory(upgradesInventory, 1, nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,6 +83,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
nbt.setInteger(NBT_COMPARE, compare);
|
nbt.setInteger(NBT_COMPARE, compare);
|
||||||
|
|
||||||
InventoryUtils.saveInventory(inventory, 0, nbt);
|
InventoryUtils.saveInventory(inventory, 0, nbt);
|
||||||
|
InventoryUtils.saveInventory(upgradesInventory, 1, nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,6 +105,10 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
return ContainerConstructor.class;
|
return ContainerConstructor.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InventorySimple getUpgradesInventory() {
|
||||||
|
return upgradesInventory;
|
||||||
|
}
|
||||||
|
|
||||||
public IInventory getInventory() {
|
public IInventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user