basic crafting grid gui stuff (no functionality yet)
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
package storagecraft.block;
|
package storagecraft.block;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
@@ -27,6 +31,15 @@ public class BlockGrid extends BlockBase implements ITileEntityProvider
|
|||||||
return new TileGrid();
|
return new TileGrid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getSubBlocks(Item item, CreativeTabs tab, List subItems)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
subItems.add(new ItemStack(item, 1, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
|
@@ -1,13 +1,36 @@
|
|||||||
package storagecraft.container;
|
package storagecraft.container;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import storagecraft.tile.TileGrid;
|
||||||
|
|
||||||
public class ContainerGrid extends ContainerBase
|
public class ContainerGrid extends ContainerBase
|
||||||
{
|
{
|
||||||
public ContainerGrid(EntityPlayer player)
|
public ContainerGrid(EntityPlayer player, TileGrid grid)
|
||||||
{
|
{
|
||||||
super(player);
|
super(player);
|
||||||
|
|
||||||
addPlayerInventory(8, 108);
|
if (grid.isCrafting())
|
||||||
|
{
|
||||||
|
int x = 44;
|
||||||
|
int y = 106;
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; ++i)
|
||||||
|
{
|
||||||
|
addSlotToContainer(new Slot(grid.getCraftingInventory(), i, x, y));
|
||||||
|
|
||||||
|
x += 18;
|
||||||
|
|
||||||
|
if ((i + 1) % 3 == 0)
|
||||||
|
{
|
||||||
|
y += 18;
|
||||||
|
x = 44;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addSlotToContainer(new Slot(grid.getCraftingInventory(), 9, 125, 124));
|
||||||
|
}
|
||||||
|
|
||||||
|
addPlayerInventory(8, grid.isCrafting() ? 174 : 108);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ public class GuiGrid extends GuiBase
|
|||||||
|
|
||||||
public GuiGrid(ContainerGrid container, TileGrid grid)
|
public GuiGrid(ContainerGrid container, TileGrid grid)
|
||||||
{
|
{
|
||||||
super(container, 176, 190);
|
super(container, 176, grid.isCrafting() ? 256 : 190);
|
||||||
|
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
@@ -116,8 +116,15 @@ public class GuiGrid extends GuiBase
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawBackground(int x, int y, int mouseX, int mouseY)
|
public void drawBackground(int x, int y, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
if (grid.isCrafting())
|
||||||
|
{
|
||||||
|
bindTexture("gui/craftingGrid.png");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
bindTexture("gui/grid.png");
|
bindTexture("gui/grid.png");
|
||||||
|
}
|
||||||
|
|
||||||
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
|
||||||
|
|
||||||
@@ -128,7 +135,13 @@ public class GuiGrid extends GuiBase
|
|||||||
public void drawForeground(int mouseX, int mouseY)
|
public void drawForeground(int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
drawString(7, 7, t("gui.storagecraft:grid"));
|
drawString(7, 7, t("gui.storagecraft:grid"));
|
||||||
drawString(7, 96, t("container.inventory"));
|
|
||||||
|
if (grid.isCrafting())
|
||||||
|
{
|
||||||
|
drawString(7, 94, t("container.crafting"));
|
||||||
|
}
|
||||||
|
|
||||||
|
drawString(7, grid.isCrafting() ? 163 : 96, t("container.inventory"));
|
||||||
|
|
||||||
int x = 8;
|
int x = 8;
|
||||||
int y = 20;
|
int y = 20;
|
||||||
|
@@ -30,7 +30,7 @@ public class GuiHandler implements IGuiHandler
|
|||||||
case StorageCraft.GUI.CONTROLLER:
|
case StorageCraft.GUI.CONTROLLER:
|
||||||
return new ContainerController(player);
|
return new ContainerController(player);
|
||||||
case StorageCraft.GUI.GRID:
|
case StorageCraft.GUI.GRID:
|
||||||
return new ContainerGrid(player);
|
return new ContainerGrid(player, (TileGrid) tile);
|
||||||
case StorageCraft.GUI.DRIVE:
|
case StorageCraft.GUI.DRIVE:
|
||||||
return new ContainerDrive(player, (TileDrive) tile);
|
return new ContainerDrive(player, (TileDrive) tile);
|
||||||
case StorageCraft.GUI.STORAGE_PROXY:
|
case StorageCraft.GUI.STORAGE_PROXY:
|
||||||
|
11
src/main/java/storagecraft/item/ItemBlockGrid.java
Normal file
11
src/main/java/storagecraft/item/ItemBlockGrid.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package storagecraft.item;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
|
||||||
|
public class ItemBlockGrid extends ItemBlockBase
|
||||||
|
{
|
||||||
|
public ItemBlockGrid(Block block)
|
||||||
|
{
|
||||||
|
super(block);
|
||||||
|
}
|
||||||
|
}
|
@@ -11,6 +11,7 @@ import storagecraft.StorageCraftBlocks;
|
|||||||
import storagecraft.StorageCraftItems;
|
import storagecraft.StorageCraftItems;
|
||||||
import storagecraft.gui.GuiHandler;
|
import storagecraft.gui.GuiHandler;
|
||||||
import storagecraft.item.ItemBlockCable;
|
import storagecraft.item.ItemBlockCable;
|
||||||
|
import storagecraft.item.ItemBlockGrid;
|
||||||
import storagecraft.network.MessageCompareUpdate;
|
import storagecraft.network.MessageCompareUpdate;
|
||||||
import storagecraft.network.MessageDetectorAmountUpdate;
|
import storagecraft.network.MessageDetectorAmountUpdate;
|
||||||
import storagecraft.network.MessageDetectorModeUpdate;
|
import storagecraft.network.MessageDetectorModeUpdate;
|
||||||
@@ -54,7 +55,7 @@ public class CommonProxy
|
|||||||
|
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.CONTROLLER, "controller");
|
GameRegistry.registerBlock(StorageCraftBlocks.CONTROLLER, "controller");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.CABLE, ItemBlockCable.class, "cable");
|
GameRegistry.registerBlock(StorageCraftBlocks.CABLE, ItemBlockCable.class, "cable");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.GRID, "grid");
|
GameRegistry.registerBlock(StorageCraftBlocks.GRID, ItemBlockGrid.class, "grid");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.DRIVE, "drive");
|
GameRegistry.registerBlock(StorageCraftBlocks.DRIVE, "drive");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.STORAGE_PROXY, "storageProxy");
|
GameRegistry.registerBlock(StorageCraftBlocks.STORAGE_PROXY, "storageProxy");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.IMPORTER, "importer");
|
GameRegistry.registerBlock(StorageCraftBlocks.IMPORTER, "importer");
|
||||||
|
@@ -1,7 +1,13 @@
|
|||||||
package storagecraft.tile;
|
package storagecraft.tile;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import storagecraft.inventory.InventorySimple;
|
||||||
|
import storagecraft.util.InventoryUtils;
|
||||||
|
|
||||||
public class TileGrid extends TileMachine
|
public class TileGrid extends TileMachine
|
||||||
{
|
{
|
||||||
|
private InventorySimple craftingInventory = new InventorySimple("crafting", 10);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage()
|
public int getEnergyUsage()
|
||||||
{
|
{
|
||||||
@@ -12,4 +18,35 @@ public class TileGrid extends TileMachine
|
|||||||
public void updateMachine()
|
public void updateMachine()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getType()
|
||||||
|
{
|
||||||
|
return worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCrafting()
|
||||||
|
{
|
||||||
|
return getType() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventorySimple getCraftingInventory()
|
||||||
|
{
|
||||||
|
return craftingInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
|
InventoryUtils.restoreInventory(craftingInventory, nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
|
InventoryUtils.saveInventory(craftingInventory, nbt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,8 @@ misc.storagecraft:no=No
|
|||||||
block.storagecraft:controller.name=Controller
|
block.storagecraft:controller.name=Controller
|
||||||
block.storagecraft:cable.0.name=Cable
|
block.storagecraft:cable.0.name=Cable
|
||||||
block.storagecraft:cable.1.name=Sensitive Cable
|
block.storagecraft:cable.1.name=Sensitive Cable
|
||||||
block.storagecraft:grid.name=Grid
|
block.storagecraft:grid.0.name=Grid
|
||||||
|
block.storagecraft:grid.1.name=Crafting Grid
|
||||||
block.storagecraft:drive.name=Drive
|
block.storagecraft:drive.name=Drive
|
||||||
block.storagecraft:storageProxy.name=Storage Proxy
|
block.storagecraft:storageProxy.name=Storage Proxy
|
||||||
block.storagecraft:importer.name=Importer
|
block.storagecraft:importer.name=Importer
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user