crafter base block
This commit is contained in:
@@ -18,4 +18,5 @@ public final class StorageCraftBlocks
|
|||||||
public static final BlockDestructor DESTRUCTOR = new BlockDestructor();
|
public static final BlockDestructor DESTRUCTOR = new BlockDestructor();
|
||||||
public static final BlockConstructor CONSTRUCTOR = new BlockConstructor();
|
public static final BlockConstructor CONSTRUCTOR = new BlockConstructor();
|
||||||
public static final BlockStorage STORAGE = new BlockStorage();
|
public static final BlockStorage STORAGE = new BlockStorage();
|
||||||
|
public static final BlockCrafter CRAFTER = new BlockCrafter();
|
||||||
}
|
}
|
||||||
|
@@ -13,4 +13,5 @@ public final class StorageCraftGUI
|
|||||||
public static final int DESTRUCTOR = 9;
|
public static final int DESTRUCTOR = 9;
|
||||||
public static final int CONSTRUCTOR = 10;
|
public static final int CONSTRUCTOR = 10;
|
||||||
public static final int STORAGE = 11;
|
public static final int STORAGE = 11;
|
||||||
|
public static final int CRAFTER = 12;
|
||||||
}
|
}
|
||||||
|
36
src/main/java/storagecraft/block/BlockCrafter.java
Normal file
36
src/main/java/storagecraft/block/BlockCrafter.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package storagecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import storagecraft.StorageCraft;
|
||||||
|
import storagecraft.StorageCraftGUI;
|
||||||
|
import storagecraft.tile.crafting.TileCrafter;
|
||||||
|
|
||||||
|
public class BlockCrafter extends BlockMachine
|
||||||
|
{
|
||||||
|
public BlockCrafter()
|
||||||
|
{
|
||||||
|
super("crafter");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createTileEntity(World world, IBlockState state)
|
||||||
|
{
|
||||||
|
return new TileCrafter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if (!world.isRemote)
|
||||||
|
{
|
||||||
|
player.openGui(StorageCraft.INSTANCE, StorageCraftGUI.CRAFTER, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
31
src/main/java/storagecraft/container/ContainerCrafter.java
Normal file
31
src/main/java/storagecraft/container/ContainerCrafter.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package storagecraft.container;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import storagecraft.StorageCraftItems;
|
||||||
|
import storagecraft.container.slot.IItemValidator;
|
||||||
|
import storagecraft.container.slot.SlotFiltered;
|
||||||
|
import storagecraft.item.ItemPattern;
|
||||||
|
import storagecraft.tile.crafting.TileCrafter;
|
||||||
|
|
||||||
|
public class ContainerCrafter extends ContainerBase
|
||||||
|
{
|
||||||
|
public ContainerCrafter(final EntityPlayer player, TileCrafter crafter)
|
||||||
|
{
|
||||||
|
super(player);
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; ++i)
|
||||||
|
{
|
||||||
|
addSlotToContainer(new SlotFiltered(crafter, i, 8 + (18 * i), 20, new IItemValidator()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean isValid(ItemStack stack)
|
||||||
|
{
|
||||||
|
return stack.getItem() == StorageCraftItems.PATTERN && ItemPattern.isValid(player.worldObj, stack);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
addPlayerInventory(8, 55);
|
||||||
|
}
|
||||||
|
}
|
43
src/main/java/storagecraft/gui/GuiCrafter.java
Normal file
43
src/main/java/storagecraft/gui/GuiCrafter.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package storagecraft.gui;
|
||||||
|
|
||||||
|
import storagecraft.container.ContainerCrafter;
|
||||||
|
import storagecraft.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
|
import storagecraft.tile.crafting.TileCrafter;
|
||||||
|
|
||||||
|
public class GuiCrafter extends GuiBase
|
||||||
|
{
|
||||||
|
private TileCrafter crafter;
|
||||||
|
|
||||||
|
public GuiCrafter(ContainerCrafter container, TileCrafter crafter)
|
||||||
|
{
|
||||||
|
super(container, 176, 137);
|
||||||
|
|
||||||
|
this.crafter = crafter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(int x, int y)
|
||||||
|
{
|
||||||
|
addSideButton(new SideButtonRedstoneMode(crafter));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(int x, int y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBackground(int x, int y, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
bindTexture("gui/crafter.png");
|
||||||
|
|
||||||
|
drawTexture(x, y, 0, 0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawForeground(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
drawString(7, 7, t("gui.storagecraft:crafter"));
|
||||||
|
drawString(7, 43, t("container.inventory"));
|
||||||
|
}
|
||||||
|
}
|
@@ -10,6 +10,7 @@ import storagecraft.StorageCraftGUI;
|
|||||||
import storagecraft.container.*;
|
import storagecraft.container.*;
|
||||||
import storagecraft.storage.IStorageGui;
|
import storagecraft.storage.IStorageGui;
|
||||||
import storagecraft.tile.*;
|
import storagecraft.tile.*;
|
||||||
|
import storagecraft.tile.crafting.TileCrafter;
|
||||||
|
|
||||||
public class GuiHandler implements IGuiHandler
|
public class GuiHandler implements IGuiHandler
|
||||||
{
|
{
|
||||||
@@ -39,6 +40,8 @@ public class GuiHandler implements IGuiHandler
|
|||||||
return new ContainerConstructor(player, (TileConstructor) tile);
|
return new ContainerConstructor(player, (TileConstructor) tile);
|
||||||
case StorageCraftGUI.STORAGE:
|
case StorageCraftGUI.STORAGE:
|
||||||
return new ContainerStorage(player, ((IStorageGui) tile).getInventory());
|
return new ContainerStorage(player, ((IStorageGui) tile).getInventory());
|
||||||
|
case StorageCraftGUI.CRAFTER:
|
||||||
|
return new ContainerCrafter(player, (TileCrafter) tile);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -79,6 +82,8 @@ public class GuiHandler implements IGuiHandler
|
|||||||
return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile), (TileConstructor) tile);
|
return new GuiConstructor((ContainerConstructor) getContainer(ID, player, tile), (TileConstructor) tile);
|
||||||
case StorageCraftGUI.STORAGE:
|
case StorageCraftGUI.STORAGE:
|
||||||
return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile);
|
return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile);
|
||||||
|
case StorageCraftGUI.CRAFTER:
|
||||||
|
return new GuiCrafter((ContainerCrafter) getContainer(ID, player, tile), (TileCrafter) tile);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ import storagecraft.item.*;
|
|||||||
import storagecraft.network.*;
|
import storagecraft.network.*;
|
||||||
import storagecraft.storage.NBTStorage;
|
import storagecraft.storage.NBTStorage;
|
||||||
import storagecraft.tile.*;
|
import storagecraft.tile.*;
|
||||||
|
import storagecraft.tile.crafting.TileCrafter;
|
||||||
import storagecraft.tile.solderer.*;
|
import storagecraft.tile.solderer.*;
|
||||||
|
|
||||||
public class CommonProxy
|
public class CommonProxy
|
||||||
@@ -54,6 +55,7 @@ public class CommonProxy
|
|||||||
GameRegistry.registerTileEntity(TileDestructor.class, "destructor");
|
GameRegistry.registerTileEntity(TileDestructor.class, "destructor");
|
||||||
GameRegistry.registerTileEntity(TileConstructor.class, "constructor");
|
GameRegistry.registerTileEntity(TileConstructor.class, "constructor");
|
||||||
GameRegistry.registerTileEntity(TileStorage.class, "storage");
|
GameRegistry.registerTileEntity(TileStorage.class, "storage");
|
||||||
|
GameRegistry.registerTileEntity(TileCrafter.class, "crafter");
|
||||||
|
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.CONTROLLER, ItemBlockController.class, "controller");
|
GameRegistry.registerBlock(StorageCraftBlocks.CONTROLLER, ItemBlockController.class, "controller");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.CABLE, "cable");
|
GameRegistry.registerBlock(StorageCraftBlocks.CABLE, "cable");
|
||||||
@@ -69,6 +71,7 @@ public class CommonProxy
|
|||||||
GameRegistry.registerBlock(StorageCraftBlocks.DESTRUCTOR, "destructor");
|
GameRegistry.registerBlock(StorageCraftBlocks.DESTRUCTOR, "destructor");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.CONSTRUCTOR, "constructor");
|
GameRegistry.registerBlock(StorageCraftBlocks.CONSTRUCTOR, "constructor");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.STORAGE, ItemBlockStorage.class, "storage");
|
GameRegistry.registerBlock(StorageCraftBlocks.STORAGE, ItemBlockStorage.class, "storage");
|
||||||
|
GameRegistry.registerBlock(StorageCraftBlocks.CRAFTER, "crafter");
|
||||||
|
|
||||||
GameRegistry.registerItem(StorageCraftItems.STORAGE_CELL, "storage_cell");
|
GameRegistry.registerItem(StorageCraftItems.STORAGE_CELL, "storage_cell");
|
||||||
GameRegistry.registerItem(StorageCraftItems.WIRELESS_GRID, "wireless_grid");
|
GameRegistry.registerItem(StorageCraftItems.WIRELESS_GRID, "wireless_grid");
|
||||||
|
48
src/main/java/storagecraft/tile/crafting/CraftingTask.java
Normal file
48
src/main/java/storagecraft/tile/crafting/CraftingTask.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package storagecraft.tile.crafting;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import storagecraft.storage.StorageItem;
|
||||||
|
import storagecraft.tile.TileController;
|
||||||
|
|
||||||
|
public class CraftingTask
|
||||||
|
{
|
||||||
|
private ItemStack result;
|
||||||
|
private ItemStack[] requirements;
|
||||||
|
private List<CraftingTask> subTasks;
|
||||||
|
|
||||||
|
private TileController controller;
|
||||||
|
|
||||||
|
public CraftingTask(TileController controller)
|
||||||
|
{
|
||||||
|
this.controller = controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean craft()
|
||||||
|
{
|
||||||
|
for (ItemStack requirement : requirements)
|
||||||
|
{
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
|
for (StorageItem item : controller.getItems())
|
||||||
|
{
|
||||||
|
if (item.compareNoQuantity(requirement))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
|
||||||
|
controller.take(requirement);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
// now look for a crafter for requirement and craft it.
|
||||||
|
// if not found, return false.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
150
src/main/java/storagecraft/tile/crafting/TileCrafter.java
Normal file
150
src/main/java/storagecraft/tile/crafting/TileCrafter.java
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
package storagecraft.tile.crafting;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
|
import storagecraft.inventory.InventorySimple;
|
||||||
|
import storagecraft.tile.TileMachine;
|
||||||
|
import storagecraft.util.InventoryUtils;
|
||||||
|
|
||||||
|
public class TileCrafter extends TileMachine implements IInventory
|
||||||
|
{
|
||||||
|
private InventorySimple inventory = new InventorySimple("crafter", 9);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnergyUsage()
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMachine()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
|
InventoryUtils.restoreInventory(this, 0, nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
|
InventoryUtils.saveInventory(this, 0, nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSizeInventory()
|
||||||
|
{
|
||||||
|
return inventory.getSizeInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot)
|
||||||
|
{
|
||||||
|
return inventory.getStackInSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int slot, int count)
|
||||||
|
{
|
||||||
|
return inventory.decrStackSize(slot, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack removeStackFromSlot(int slot)
|
||||||
|
{
|
||||||
|
return inventory.removeStackFromSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||||
|
{
|
||||||
|
inventory.setInventorySlotContents(slot, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventoryStackLimit()
|
||||||
|
{
|
||||||
|
return inventory.getInventoryStackLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUseableByPlayer(EntityPlayer player)
|
||||||
|
{
|
||||||
|
return inventory.isUseableByPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openInventory(EntityPlayer player)
|
||||||
|
{
|
||||||
|
inventory.openInventory(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeInventory(EntityPlayer player)
|
||||||
|
{
|
||||||
|
inventory.closeInventory(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValidForSlot(int slot, ItemStack stack)
|
||||||
|
{
|
||||||
|
return inventory.isItemValidForSlot(slot, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getField(int id)
|
||||||
|
{
|
||||||
|
return inventory.getField(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setField(int id, int value)
|
||||||
|
{
|
||||||
|
inventory.setField(id, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFieldCount()
|
||||||
|
{
|
||||||
|
return inventory.getFieldCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear()
|
||||||
|
{
|
||||||
|
inventory.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return inventory.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomName()
|
||||||
|
{
|
||||||
|
return inventory.hasCustomName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IChatComponent getDisplayName()
|
||||||
|
{
|
||||||
|
return inventory.getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IInventory getDroppedInventory()
|
||||||
|
{
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
}
|
@@ -13,6 +13,7 @@ gui.storagecraft:solderer=Solderer
|
|||||||
gui.storagecraft:wireless_transmitter=Wireless Transmitter
|
gui.storagecraft:wireless_transmitter=Wireless Transmitter
|
||||||
gui.storagecraft:destructor=Destructor
|
gui.storagecraft:destructor=Destructor
|
||||||
gui.storagecraft:constructor=Constructor
|
gui.storagecraft:constructor=Constructor
|
||||||
|
gui.storagecraft:crafter=Crafter
|
||||||
|
|
||||||
misc.storagecraft:energy_stored=%d / %d RF
|
misc.storagecraft:energy_stored=%d / %d RF
|
||||||
misc.storagecraft:energy_usage=Usage: %d RF/t
|
misc.storagecraft:energy_usage=Usage: %d RF/t
|
||||||
@@ -85,6 +86,7 @@ block.storagecraft:storage.1.name=4k Storage Block
|
|||||||
block.storagecraft:storage.2.name=16k Storage Block
|
block.storagecraft:storage.2.name=16k Storage Block
|
||||||
block.storagecraft:storage.3.name=64k Storage Block
|
block.storagecraft:storage.3.name=64k Storage Block
|
||||||
block.storagecraft:storage.4.name=Creative Storage Block
|
block.storagecraft:storage.4.name=Creative Storage Block
|
||||||
|
block.storagecraft:crafter.name=Crafter
|
||||||
|
|
||||||
item.storagecraft:storage_cell.0.name=1k Storage Cell
|
item.storagecraft:storage_cell.0.name=1k Storage Cell
|
||||||
item.storagecraft:storage_cell.1.name=4k Storage Cell
|
item.storagecraft:storage_cell.1.name=4k Storage Cell
|
||||||
|
@@ -13,6 +13,7 @@ gui.storagecraft:solderer=Soldeerder
|
|||||||
gui.storagecraft:wireless_transmitter=Draadloze Zender
|
gui.storagecraft:wireless_transmitter=Draadloze Zender
|
||||||
gui.storagecraft:destructor=Destructor
|
gui.storagecraft:destructor=Destructor
|
||||||
gui.storagecraft:constructor=Constructor
|
gui.storagecraft:constructor=Constructor
|
||||||
|
gui.storagecraft:crafter=Crafter
|
||||||
|
|
||||||
misc.storagecraft:energy_stored=%d / %d RF
|
misc.storagecraft:energy_stored=%d / %d RF
|
||||||
misc.storagecraft:energy_usage=Vebruik: %d RF/t
|
misc.storagecraft:energy_usage=Vebruik: %d RF/t
|
||||||
@@ -85,6 +86,7 @@ block.storagecraft:storage.1.name=4k Opslag Blok
|
|||||||
block.storagecraft:storage.2.name=16k Opslag Blok
|
block.storagecraft:storage.2.name=16k Opslag Blok
|
||||||
block.storagecraft:storage.3.name=64k Opslag Blok
|
block.storagecraft:storage.3.name=64k Opslag Blok
|
||||||
block.storagecraft:storage.4.name=Creative Opslag Blok
|
block.storagecraft:storage.4.name=Creative Opslag Blok
|
||||||
|
block.storagecraft:crafter.name=Crafter
|
||||||
|
|
||||||
item.storagecraft:storage_cell.0.name=1k Opslagcel
|
item.storagecraft:storage_cell.0.name=1k Opslagcel
|
||||||
item.storagecraft:storage_cell.1.name=4k Opslagcel
|
item.storagecraft:storage_cell.1.name=4k Opslagcel
|
||||||
|
BIN
src/main/resources/assets/storagecraft/textures/gui/crafter.png
Normal file
BIN
src/main/resources/assets/storagecraft/textures/gui/crafter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Reference in New Issue
Block a user