basic pattern stuff
This commit is contained in:
@@ -12,4 +12,5 @@ public final class StorageCraftItems
|
||||
public static final ItemSilicon SILICON = new ItemSilicon();
|
||||
public static final ItemProcessor PROCESSOR = new ItemProcessor();
|
||||
public static final ItemStoragePart STORAGE_PART = new ItemStoragePart();
|
||||
public static final ItemPattern PATTERN = new ItemPattern();
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class BlockGrid extends BlockMachine
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List subItems)
|
||||
{
|
||||
for (int i = 0; i <= 1; i++)
|
||||
for (int i = 0; i <= 2; i++)
|
||||
{
|
||||
subItems.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
@@ -55,13 +55,13 @@ public class BlockGrid extends BlockMachine
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return getDefaultState().withProperty(TYPE, meta == 0 ? EnumGridType.NORMAL : EnumGridType.CRAFTING);
|
||||
return getDefaultState().withProperty(TYPE, meta == 0 ? EnumGridType.NORMAL : (meta == 1 ? EnumGridType.CRAFTING : EnumGridType.PATTERN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(TYPE) == EnumGridType.NORMAL ? 0 : 1;
|
||||
return state.getValue(TYPE) == EnumGridType.NORMAL ? 0 : (state.getValue(TYPE) == EnumGridType.CRAFTING ? 1 : 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -5,7 +5,8 @@ import net.minecraft.util.IStringSerializable;
|
||||
public enum EnumGridType implements IStringSerializable
|
||||
{
|
||||
NORMAL(0, "normal"),
|
||||
CRAFTING(1, "crafting");
|
||||
CRAFTING(1, "crafting"),
|
||||
PATTERN(2, "pattern");
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
|
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import storagecraft.container.slot.SlotDisabled;
|
||||
import storagecraft.container.slot.SlotSpecimen;
|
||||
|
||||
public abstract class ContainerBase extends Container
|
||||
@@ -72,6 +73,10 @@ public abstract class ContainerBase extends Container
|
||||
|
||||
return player.inventory.getItemStack();
|
||||
}
|
||||
else if (slot instanceof SlotDisabled)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.slotClick(id, clickedButton, mode, player);
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import storagecraft.StorageCraftItems;
|
||||
import storagecraft.container.slot.SlotItemFilter;
|
||||
import storagecraft.container.slot.SlotFiltered;
|
||||
import storagecraft.tile.TileDrive;
|
||||
|
||||
public class ContainerDrive extends ContainerBase
|
||||
@@ -18,7 +18,7 @@ public class ContainerDrive extends ContainerBase
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
addSlotToContainer(new SlotItemFilter(drive, i, x, y, StorageCraftItems.STORAGE_CELL));
|
||||
addSlotToContainer(new SlotFiltered(drive, i, x, y, StorageCraftItems.STORAGE_CELL));
|
||||
|
||||
if ((i + 1) % 2 == 0)
|
||||
{
|
||||
|
@@ -2,8 +2,13 @@ package storagecraft.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import storagecraft.StorageCraftItems;
|
||||
import storagecraft.block.EnumGridType;
|
||||
import storagecraft.container.slot.SlotDisabled;
|
||||
import storagecraft.container.slot.SlotFiltered;
|
||||
import storagecraft.container.slot.SlotGridCraftingResult;
|
||||
import storagecraft.container.slot.SlotOutput;
|
||||
import storagecraft.container.slot.SlotSpecimen;
|
||||
import storagecraft.tile.TileGrid;
|
||||
|
||||
public class ContainerGrid extends ContainerBase
|
||||
@@ -12,7 +17,7 @@ public class ContainerGrid extends ContainerBase
|
||||
{
|
||||
super(player);
|
||||
|
||||
addPlayerInventory(8, grid.getType() == EnumGridType.CRAFTING ? 174 : 108);
|
||||
addPlayerInventory(8, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 174 : 108);
|
||||
|
||||
if (grid.getType() == EnumGridType.CRAFTING)
|
||||
{
|
||||
@@ -21,7 +26,7 @@ public class ContainerGrid extends ContainerBase
|
||||
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(grid.getCraftingMatrix(), i, x, y));
|
||||
addSlotToContainer(new Slot(grid.getCraftingInventory(), i, x, y));
|
||||
|
||||
x += 18;
|
||||
|
||||
@@ -32,7 +37,30 @@ public class ContainerGrid extends ContainerBase
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotGridCraftingResult(player, grid.getCraftingMatrix(), grid.getCraftingResult(), grid, 0, 137, 124));
|
||||
addSlotToContainer(new SlotGridCraftingResult(player, grid.getCraftingInventory(), grid.getCraftingResultInventory(), grid, 0, 133 + 4, 120 + 4));
|
||||
}
|
||||
else if (grid.getType() == EnumGridType.PATTERN)
|
||||
{
|
||||
int x = 8;
|
||||
int y = 106;
|
||||
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new SlotSpecimen(grid.getPatternCraftingInventory(), i, x, y));
|
||||
|
||||
x += 18;
|
||||
|
||||
if ((i + 1) % 3 == 0)
|
||||
{
|
||||
y += 18;
|
||||
x = 8;
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotDisabled(grid.getPatternCraftingResultInventory(), 0, 116 + 4, 120 + 4));
|
||||
|
||||
addSlotToContainer(new SlotFiltered(grid.getPatternInventory(), 0, 152, 105, StorageCraftItems.PATTERN));
|
||||
addSlotToContainer(new SlotOutput(grid.getPatternInventory(), 1, 152, 142));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +0,0 @@
|
||||
package storagecraft.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import storagecraft.tile.TileGrid;
|
||||
|
||||
public class ContainerGridCrafting extends Container
|
||||
{
|
||||
private TileGrid grid;
|
||||
|
||||
public ContainerGridCrafting(TileGrid grid)
|
||||
{
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory)
|
||||
{
|
||||
grid.onCraftingMatrixChanged();
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import storagecraft.StorageCraftItems;
|
||||
import storagecraft.container.slot.SlotItemFilter;
|
||||
import storagecraft.container.slot.SlotFiltered;
|
||||
import storagecraft.container.slot.SlotOutput;
|
||||
import storagecraft.tile.TileWirelessTransmitter;
|
||||
|
||||
@@ -15,8 +15,8 @@ public class ContainerWirelessTransmitter extends ContainerBase
|
||||
{
|
||||
super(player);
|
||||
|
||||
addSlotToContainer(new SlotItemFilter(wirelessTransmitter, 0, 8, 20, Items.ender_pearl));
|
||||
addSlotToContainer(new SlotItemFilter(wirelessTransmitter, 1, 101, 20, StorageCraftItems.WIRELESS_GRID));
|
||||
addSlotToContainer(new SlotFiltered(wirelessTransmitter, 0, 8, 20, Items.ender_pearl));
|
||||
addSlotToContainer(new SlotFiltered(wirelessTransmitter, 1, 101, 20, StorageCraftItems.WIRELESS_GRID));
|
||||
addSlotToContainer(new SlotOutput(wirelessTransmitter, 2, 152, 20));
|
||||
|
||||
addPlayerInventory(8, 55);
|
||||
|
19
src/main/java/storagecraft/container/slot/SlotDisabled.java
Normal file
19
src/main/java/storagecraft/container/slot/SlotDisabled.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package storagecraft.container.slot;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotDisabled extends Slot
|
||||
{
|
||||
public SlotDisabled(IInventory inventory, int id, int x, int y)
|
||||
{
|
||||
super(inventory, id, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -5,11 +5,11 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotItemFilter extends Slot
|
||||
public class SlotFiltered extends Slot
|
||||
{
|
||||
private Item item;
|
||||
|
||||
public SlotItemFilter(IInventory inventory, int id, int x, int y, Item item)
|
||||
public SlotFiltered(IInventory inventory, int id, int x, int y, Item item)
|
||||
{
|
||||
super(inventory, id, x, y);
|
||||
|
@@ -40,7 +40,7 @@ public class GuiGrid extends GuiBase
|
||||
|
||||
public GuiGrid(ContainerGrid container, TileGrid grid)
|
||||
{
|
||||
super(container, 176, grid.getType() == EnumGridType.CRAFTING ? 256 : 190);
|
||||
super(container, 176, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 256 : 190);
|
||||
|
||||
this.container = container;
|
||||
this.grid = grid;
|
||||
@@ -114,7 +114,16 @@ public class GuiGrid extends GuiBase
|
||||
|
||||
public boolean isHoveringOverClear(int mouseX, int mouseY)
|
||||
{
|
||||
return inBounds(81, 105, 7, 7, mouseX, mouseY);
|
||||
if (grid.getType() == EnumGridType.CRAFTING)
|
||||
{
|
||||
return inBounds(81, 105, 7, 7, mouseX, mouseY);
|
||||
}
|
||||
else if (grid.getType() == EnumGridType.PATTERN)
|
||||
{
|
||||
return inBounds(64, 105, 7, 7, mouseX, mouseY);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,6 +133,10 @@ public class GuiGrid extends GuiBase
|
||||
{
|
||||
bindTexture("gui/crafting_grid.png");
|
||||
}
|
||||
else if (grid.getType() == EnumGridType.PATTERN)
|
||||
{
|
||||
bindTexture("gui/pattern_grid.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
bindTexture("gui/grid.png");
|
||||
@@ -143,8 +156,12 @@ public class GuiGrid extends GuiBase
|
||||
{
|
||||
drawString(7, 94, t("container.crafting"));
|
||||
}
|
||||
else if (grid.getType() == EnumGridType.PATTERN)
|
||||
{
|
||||
drawString(7, 94, t("gui.storagecraft:grid.pattern"));
|
||||
}
|
||||
|
||||
drawString(7, grid.getType() == EnumGridType.CRAFTING ? 163 : 96, t("container.inventory"));
|
||||
drawString(7, (grid.getType() == EnumGridType.CRAFTING || grid.getType() == EnumGridType.PATTERN) ? 163 : 96, t("container.inventory"));
|
||||
|
||||
int x = 8;
|
||||
int y = 20;
|
||||
@@ -204,7 +221,7 @@ public class GuiGrid extends GuiBase
|
||||
drawTooltip(mouseX, mouseY, items.get(hoveringSlotId).toItemStack());
|
||||
}
|
||||
|
||||
if (grid.getType() == EnumGridType.CRAFTING && isHoveringOverClear(mouseX, mouseY))
|
||||
if (isHoveringOverClear(mouseX, mouseY))
|
||||
{
|
||||
drawTooltip(mouseX, mouseY, t("misc.storagecraft:clear"));
|
||||
}
|
||||
@@ -285,7 +302,7 @@ public class GuiGrid extends GuiBase
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||
|
||||
boolean clickedClear = grid.getType() == EnumGridType.CRAFTING && clickedButton == 0 && isHoveringOverClear(mouseX - guiLeft, mouseY - guiTop);
|
||||
boolean clickedClear = clickedButton == 0 && isHoveringOverClear(mouseX - guiLeft, mouseY - guiTop);
|
||||
|
||||
if (grid.isConnected())
|
||||
{
|
||||
|
10
src/main/java/storagecraft/item/ItemPattern.java
Normal file
10
src/main/java/storagecraft/item/ItemPattern.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package storagecraft.item;
|
||||
|
||||
// @TODO: Other texture when there is an item assigned
|
||||
public class ItemPattern extends ItemBase
|
||||
{
|
||||
public ItemPattern()
|
||||
{
|
||||
super("pattern");
|
||||
}
|
||||
}
|
@@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import storagecraft.block.EnumGridType;
|
||||
import storagecraft.tile.TileGrid;
|
||||
|
||||
public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<MessageGridCraftingClear> implements IMessage
|
||||
@@ -50,17 +51,24 @@ public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<Messa
|
||||
{
|
||||
TileGrid grid = (TileGrid) tile;
|
||||
|
||||
if (grid.isConnected())
|
||||
if (grid.getType() == EnumGridType.PATTERN)
|
||||
{
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i)
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
ItemStack slot = grid.getCraftingMatrix().getStackInSlot(i);
|
||||
grid.getPatternCraftingInventory().setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
else if (grid.isConnected() && grid.getType() == EnumGridType.CRAFTING)
|
||||
{
|
||||
for (int i = 0; i < grid.getCraftingInventory().getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack slot = grid.getCraftingInventory().getStackInSlot(i);
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
if (grid.getController().push(slot))
|
||||
{
|
||||
grid.getCraftingMatrix().setInventorySlotContents(i, null);
|
||||
grid.getCraftingInventory().setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ public class MessageGridCraftingUpdate implements IMessage, IMessageHandler<Mess
|
||||
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
craftingMatrix[i] = grid.getCraftingMatrix().getStackInSlot(i);
|
||||
craftingMatrix[i] = grid.getCraftingInventory().getStackInSlot(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class MessageGridCraftingUpdate implements IMessage, IMessageHandler<Mess
|
||||
{
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
((TileGrid) tile).getCraftingMatrix().setInventorySlotContents(i, message.craftingMatrix[i]);
|
||||
((TileGrid) tile).getCraftingInventory().setInventorySlotContents(i, message.craftingMatrix[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -91,6 +91,8 @@ public class ClientProxy extends CommonProxy
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(StorageCraftItems.SILICON, 0, new ModelResourceLocation("storagecraft:silicon", "inventory"));
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(StorageCraftItems.PATTERN, 0, new ModelResourceLocation("storagecraft:pattern", "inventory"));
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(StorageCraftItems.QUARTZ_ENRICHED_IRON, 0, new ModelResourceLocation("storagecraft:quartz_enriched_iron", "inventory"));
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(StorageCraftItems.CORE, ItemCore.TYPE_CONSTRUCTION, new ModelResourceLocation("storagecraft:construction_core", "inventory"));
|
||||
@@ -109,6 +111,7 @@ public class ClientProxy extends CommonProxy
|
||||
// Blocks
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.GRID), EnumGridType.NORMAL.getId(), new ModelResourceLocation("storagecraft:grid", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.GRID), EnumGridType.CRAFTING.getId(), new ModelResourceLocation("storagecraft:grid", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.GRID), EnumGridType.PATTERN.getId(), new ModelResourceLocation("storagecraft:grid", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.MACHINE_CASING), 0, new ModelResourceLocation("storagecraft:machine_casing", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.EXPORTER), 0, new ModelResourceLocation("storagecraft:exporter", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.IMPORTER), 0, new ModelResourceLocation("storagecraft:importer", "inventory"));
|
||||
|
@@ -78,6 +78,7 @@ public class CommonProxy
|
||||
GameRegistry.registerItem(StorageCraftItems.SILICON, "silicon");
|
||||
GameRegistry.registerItem(StorageCraftItems.PROCESSOR, "processor");
|
||||
GameRegistry.registerItem(StorageCraftItems.STORAGE_PART, "storage_part");
|
||||
GameRegistry.registerItem(StorageCraftItems.PATTERN, "pattern");
|
||||
|
||||
// Processors
|
||||
SoldererRegistry.addRecipe(new SoldererRecipePrintedProcessor(ItemProcessor.TYPE_PRINTED_BASIC));
|
||||
@@ -345,6 +346,16 @@ public class CommonProxy
|
||||
SoldererRegistry.addRecipe(new SoldererRecipeStorage(EnumStorageType.TYPE_4K, ItemStoragePart.TYPE_4K));
|
||||
SoldererRegistry.addRecipe(new SoldererRecipeStorage(EnumStorageType.TYPE_16K, ItemStoragePart.TYPE_16K));
|
||||
SoldererRegistry.addRecipe(new SoldererRecipeStorage(EnumStorageType.TYPE_64K, ItemStoragePart.TYPE_64K));
|
||||
|
||||
// Pattern
|
||||
GameRegistry.addRecipe(new ItemStack(StorageCraftItems.PATTERN),
|
||||
"LGL",
|
||||
"GLG",
|
||||
"EEE",
|
||||
'E', new ItemStack(StorageCraftItems.QUARTZ_ENRICHED_IRON),
|
||||
'L', new ItemStack(Blocks.glass),
|
||||
'G', new ItemStack(Items.glowstone_dust)
|
||||
);
|
||||
}
|
||||
|
||||
public void init(FMLInitializationEvent e)
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package storagecraft.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -10,7 +12,6 @@ import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import storagecraft.StorageCraft;
|
||||
import storagecraft.block.BlockGrid;
|
||||
import storagecraft.block.EnumGridType;
|
||||
import storagecraft.container.ContainerGridCrafting;
|
||||
import storagecraft.inventory.InventorySimple;
|
||||
import storagecraft.network.MessageGridCraftingUpdate;
|
||||
import storagecraft.storage.StorageItem;
|
||||
@@ -27,9 +28,40 @@ public class TileGrid extends TileMachine
|
||||
public static final int SORTING_TYPE_QUANTITY = 0;
|
||||
public static final int SORTING_TYPE_NAME = 1;
|
||||
|
||||
private ContainerGridCrafting craftingMatrixContainer = new ContainerGridCrafting(this);
|
||||
private InventoryCrafting craftingMatrix = new InventoryCrafting(craftingMatrixContainer, 3, 3);
|
||||
private InventorySimple craftingResult = new InventorySimple("crafting_result", 1);
|
||||
private Container craftingContainer = new Container()
|
||||
{
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory)
|
||||
{
|
||||
onCraftingMatrixChanged();
|
||||
}
|
||||
};
|
||||
private InventoryCrafting craftingInventory = new InventoryCrafting(craftingContainer, 3, 3);
|
||||
private InventorySimple craftingResultInventory = new InventorySimple("crafting_result", 1);
|
||||
|
||||
private Container patternCraftingContainer = new Container()
|
||||
{
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory)
|
||||
{
|
||||
onPatternCraftingMatrixChanged();
|
||||
}
|
||||
};
|
||||
private InventoryCrafting patternCraftingInventory = new InventoryCrafting(patternCraftingContainer, 3, 3);
|
||||
private InventorySimple patternCraftingResultInventory = new InventorySimple("pattern_crafting_result", 1, this);
|
||||
private InventorySimple patternInventory = new InventorySimple("pattern", 2, this);
|
||||
|
||||
private int sortingDirection = 0;
|
||||
private int sortingType = 0;
|
||||
@@ -50,25 +82,37 @@ public class TileGrid extends TileMachine
|
||||
return (EnumGridType) worldObj.getBlockState(pos).getValue(BlockGrid.TYPE);
|
||||
}
|
||||
|
||||
public InventoryCrafting getCraftingMatrix()
|
||||
public InventoryCrafting getCraftingInventory()
|
||||
{
|
||||
return craftingMatrix;
|
||||
return craftingInventory;
|
||||
}
|
||||
|
||||
public InventorySimple getCraftingResultInventory()
|
||||
{
|
||||
return craftingResultInventory;
|
||||
}
|
||||
|
||||
public void onCraftingMatrixChanged()
|
||||
{
|
||||
markDirty();
|
||||
|
||||
craftingResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftingMatrix, worldObj));
|
||||
craftingResultInventory.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftingInventory, worldObj));
|
||||
}
|
||||
|
||||
public void onPatternCraftingMatrixChanged()
|
||||
{
|
||||
markDirty();
|
||||
|
||||
patternCraftingResultInventory.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(patternCraftingInventory, worldObj));
|
||||
}
|
||||
|
||||
public void onCrafted(ItemStack[] matrixSlots)
|
||||
{
|
||||
if (isConnected() && !worldObj.isRemote)
|
||||
{
|
||||
for (int i = 0; i < craftingMatrix.getSizeInventory(); ++i)
|
||||
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack slot = craftingMatrix.getStackInSlot(i);
|
||||
ItemStack slot = craftingInventory.getStackInSlot(i);
|
||||
|
||||
if (slot == null && matrixSlots[i] != null)
|
||||
{
|
||||
@@ -76,7 +120,7 @@ public class TileGrid extends TileMachine
|
||||
{
|
||||
if (item.compareNoQuantity(matrixSlots[i].copy()))
|
||||
{
|
||||
craftingMatrix.setInventorySlotContents(i, getController().take(matrixSlots[i].copy()));
|
||||
craftingInventory.setInventorySlotContents(i, getController().take(matrixSlots[i].copy()));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -93,9 +137,19 @@ public class TileGrid extends TileMachine
|
||||
}
|
||||
}
|
||||
|
||||
public InventorySimple getCraftingResult()
|
||||
public InventoryCrafting getPatternCraftingInventory()
|
||||
{
|
||||
return craftingResult;
|
||||
return patternCraftingInventory;
|
||||
}
|
||||
|
||||
public InventorySimple getPatternCraftingResultInventory()
|
||||
{
|
||||
return patternCraftingResultInventory;
|
||||
}
|
||||
|
||||
public InventorySimple getPatternInventory()
|
||||
{
|
||||
return patternInventory;
|
||||
}
|
||||
|
||||
public int getSortingDirection()
|
||||
@@ -127,7 +181,10 @@ public class TileGrid extends TileMachine
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
InventoryUtils.restoreInventory(craftingMatrix, nbt);
|
||||
InventoryUtils.restoreInventory(craftingInventory, nbt);
|
||||
InventoryUtils.restoreInventory(patternCraftingInventory, nbt);
|
||||
InventoryUtils.restoreInventory(patternCraftingResultInventory, nbt);
|
||||
InventoryUtils.restoreInventory(patternInventory, nbt);
|
||||
|
||||
if (nbt.hasKey(NBT_SORTING_DIRECTION))
|
||||
{
|
||||
@@ -145,7 +202,10 @@ public class TileGrid extends TileMachine
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
InventoryUtils.saveInventory(craftingMatrix, nbt);
|
||||
InventoryUtils.saveInventory(craftingInventory, nbt);
|
||||
InventoryUtils.saveInventory(patternCraftingInventory, nbt);
|
||||
InventoryUtils.saveInventory(patternCraftingResultInventory, nbt);
|
||||
InventoryUtils.saveInventory(patternInventory, nbt);
|
||||
|
||||
nbt.setInteger(NBT_SORTING_DIRECTION, sortingDirection);
|
||||
nbt.setInteger(NBT_SORTING_TYPE, sortingType);
|
||||
@@ -172,6 +232,15 @@ public class TileGrid extends TileMachine
|
||||
@Override
|
||||
public IInventory getDroppedInventory()
|
||||
{
|
||||
return craftingMatrix;
|
||||
if (getType() == EnumGridType.CRAFTING)
|
||||
{
|
||||
return craftingInventory;
|
||||
}
|
||||
else if (getType() == EnumGridType.PATTERN)
|
||||
{
|
||||
return patternInventory;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ public class InventoryUtils
|
||||
public static final int COMPARE_NBT = 2;
|
||||
public static final int COMPARE_QUANTITY = 4;
|
||||
|
||||
// @TODO: Save multiple inventories
|
||||
public static void saveInventory(IInventory inventory, NBTTagCompound nbt)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
@@ -38,6 +39,7 @@ public class InventoryUtils
|
||||
nbt.setTag(NBT_INVENTORY, tagList);
|
||||
}
|
||||
|
||||
// @TODO: Restore multiple inventories
|
||||
public static void restoreInventory(IInventory inventory, NBTTagCompound nbt)
|
||||
{
|
||||
if (nbt.hasKey(NBT_INVENTORY))
|
||||
|
@@ -9,13 +9,6 @@
|
||||
},
|
||||
"variants": {
|
||||
"inventory": [
|
||||
{
|
||||
"textures": {
|
||||
"front": "storagecraft:blocks/grid_disconnected"
|
||||
},
|
||||
"transform": "forge:default-block",
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"textures": {
|
||||
"front": "storagecraft:blocks/grid_disconnected"
|
||||
@@ -28,6 +21,8 @@
|
||||
"normal": {
|
||||
},
|
||||
"crafting": {
|
||||
},
|
||||
"pattern": {
|
||||
}
|
||||
},
|
||||
"connected": {
|
||||
|
@@ -3,6 +3,7 @@ itemGroup.storagecraft=StorageCraft
|
||||
gui.storagecraft:controller.0=Controller
|
||||
gui.storagecraft:controller.1=Creative Controller
|
||||
gui.storagecraft:grid=Grid
|
||||
gui.storagecraft:grid.pattern=Pattern
|
||||
gui.storagecraft:drive=Drive
|
||||
gui.storagecraft:external_storage=External Storage
|
||||
gui.storagecraft:importer=Importer
|
||||
@@ -66,6 +67,7 @@ block.storagecraft:controller.1.name=Creative Controller
|
||||
block.storagecraft:cable.name=Cable
|
||||
block.storagecraft:grid.0.name=Grid
|
||||
block.storagecraft:grid.1.name=Crafting Grid
|
||||
block.storagecraft:grid.2.name=Pattern Grid
|
||||
block.storagecraft:drive.name=Drive
|
||||
block.storagecraft:external_storage.name=External Storage
|
||||
block.storagecraft:importer.name=Importer
|
||||
@@ -104,4 +106,5 @@ item.storagecraft:processor.6.name=Printed Silicon
|
||||
item.storagecraft:storage_part.0.name=1k Storage Part
|
||||
item.storagecraft:storage_part.1.name=4k Storage Part
|
||||
item.storagecraft:storage_part.2.name=16k Storage Part
|
||||
item.storagecraft:storage_part.3.name=64k Storage Part
|
||||
item.storagecraft:storage_part.3.name=64k Storage Part
|
||||
item.storagecraft:pattern.name=Pattern
|
@@ -3,6 +3,7 @@ itemGroup.storagecraft=StorageCraft
|
||||
gui.storagecraft:controller.0=Controller
|
||||
gui.storagecraft:controller.1=Creative Controller
|
||||
gui.storagecraft:grid=Rooster
|
||||
gui.storagecraft:grid.pattern=Patroon
|
||||
gui.storagecraft:drive=Schijf
|
||||
gui.storagecraft:external_storage=Externe Opslag
|
||||
gui.storagecraft:importer=Importeur
|
||||
@@ -66,6 +67,7 @@ block.storagecraft:controller.1.name=Creative Controller
|
||||
block.storagecraft:cable.name=Kabel
|
||||
block.storagecraft:grid.0.name=Rooster
|
||||
block.storagecraft:grid.1.name=Crafting Rooster
|
||||
block.storagecraft:grid.2.name=Patroon Raster
|
||||
block.storagecraft:drive.name=Schijf
|
||||
block.storagecraft:external_storage.name=Externe Opslag
|
||||
block.storagecraft:importer.name=Importeur
|
||||
@@ -104,4 +106,5 @@ item.storagecraft:processor.6.name=Gedrukte Silicon
|
||||
item.storagecraft:storage_part.0.name=1k Opslagdeel
|
||||
item.storagecraft:storage_part.1.name=4k Opslagdeel
|
||||
item.storagecraft:storage_part.2.name=16k Opslagdeel
|
||||
item.storagecraft:storage_part.3.name=64k Opslagdeel
|
||||
item.storagecraft:storage_part.3.name=64k Opslagdeel
|
||||
item.storagecraft:pattern.name=Patroon
|
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"parent": "builtin/generated",
|
||||
"textures": {
|
||||
"layer0": "storagecraft:items/pattern"
|
||||
},
|
||||
"display": {
|
||||
"thirdperson": {
|
||||
"rotation": [-90, 0, 0],
|
||||
"translation": [0, 1, -3],
|
||||
"scale": [0.55, 0.55, 0.55]
|
||||
},
|
||||
"firstperson": {
|
||||
"rotation": [0, -135, 25],
|
||||
"translation": [0, 4, 2],
|
||||
"scale": [1.7, 1.7, 1.7]
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 270 B |
Reference in New Issue
Block a user