Added engineering table
This commit is contained in:
parent
699788b19b
commit
518643b438
15 changed files with 632 additions and 133 deletions
|
@ -3,6 +3,8 @@ package resonantinduction.archaic;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import resonantinduction.archaic.crate.BlockCrate;
|
import resonantinduction.archaic.crate.BlockCrate;
|
||||||
import resonantinduction.archaic.crate.TileCrate;
|
import resonantinduction.archaic.crate.TileCrate;
|
||||||
|
import resonantinduction.archaic.engineering.BlockEngineeringTable;
|
||||||
|
import resonantinduction.archaic.engineering.TileEngineeringTable;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.core.Settings;
|
import resonantinduction.core.Settings;
|
||||||
|
@ -43,12 +45,14 @@ public class Archaic
|
||||||
|
|
||||||
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, ID);
|
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, ID);
|
||||||
|
|
||||||
|
public static Block blockEngineeringTable;
|
||||||
public static Block blockCrate;
|
public static Block blockCrate;
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent evt)
|
public void preInit(FMLPreInitializationEvent evt)
|
||||||
{
|
{
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
||||||
|
blockEngineeringTable = contentRegistry.createTile(BlockEngineeringTable.class, TileEngineeringTable.class);
|
||||||
blockCrate = contentRegistry.createTile(BlockCrate.class, TileCrate.class);
|
blockCrate = contentRegistry.createTile(BlockCrate.class, TileCrate.class);
|
||||||
proxy.preInit();
|
proxy.preInit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
package resonantinduction.archaic.crafting;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import resonantinduction.core.prefab.block.BlockRI;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Advanced tiering of a crafting table adding advanced features such as visual crafting, and auto
|
|
||||||
* crafting. Original idea by Infinite
|
|
||||||
*
|
|
||||||
* @author DarkGuardsman
|
|
||||||
*/
|
|
||||||
public class BlockEngineeringTable extends BlockRI
|
|
||||||
{
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private Icon workbenchIconTop;
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private Icon workbenchIconFront;
|
|
||||||
|
|
||||||
public BlockEngineeringTable()
|
|
||||||
{
|
|
||||||
super("craftingDesk");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int par1, int par2)
|
|
||||||
{
|
|
||||||
return par1 == 1 ? this.workbenchIconTop : (par1 == 0 ? Block.planks.getBlockTextureFromSide(par1) : (par1 != 2 && par1 != 4 ? this.blockIcon : this.workbenchIconFront));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister par1IconRegister)
|
|
||||||
{
|
|
||||||
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
|
|
||||||
this.workbenchIconTop = par1IconRegister.registerIcon(this.getTextureName() + "_top");
|
|
||||||
this.workbenchIconFront = par1IconRegister.registerIcon(this.getTextureName() + "_front");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileEngineeringTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(World world, int metadata)
|
|
||||||
{
|
|
||||||
if (metadata >= 0 && metadata < CraftingTables.values().length)
|
|
||||||
{
|
|
||||||
CraftingTables table = CraftingTables.values()[metadata];
|
|
||||||
if (table.enabled && table.tileClass != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return table.tileClass.newInstance();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.createTileEntity(world, metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum CraftingTables
|
|
||||||
{
|
|
||||||
/** Upgraded wooden crafting table, stores items, and contains a small inventory */
|
|
||||||
ADVANCED(),
|
|
||||||
/** Stone version of the advanced, renders end result of crafting on surface */
|
|
||||||
STONE(),
|
|
||||||
/** Iron version of stone adding ability to repair armor */
|
|
||||||
IRON(),
|
|
||||||
/** Upgraded version of the iron allowing repair of tools, as well upgrades of tools */
|
|
||||||
STEEL(),
|
|
||||||
/** First work bench that can be combined with robotics to auto craft items */
|
|
||||||
AUTOMATED(),
|
|
||||||
/** Crafting table that allows large long term projects to be made one item at a time */
|
|
||||||
PROJECT(),
|
|
||||||
/** Crafting table that allows industrial machines to be crafted */
|
|
||||||
INDUSTRIAL(),
|
|
||||||
/**
|
|
||||||
* Crafting table that allows advanced electronics to be crafted, also allows electronic
|
|
||||||
* devices to be designed
|
|
||||||
*/
|
|
||||||
ELECTRONICS(),
|
|
||||||
/** Upgraded auto table that can use blueprints, works faster, and do some cool tricks */
|
|
||||||
INDUSTRIAL_AUTOMATED(),
|
|
||||||
/** Auto crafting version of the electronics table, allows autocrafting of custom devices */
|
|
||||||
ELECTRONICS_AUTOMATED(),
|
|
||||||
/** Auto crafting table that allows long term projects to be made one item at a time */
|
|
||||||
AUTOMATED_PROJECT();
|
|
||||||
|
|
||||||
public final boolean enabled;
|
|
||||||
public Class<? extends TileEntity> tileClass = null;
|
|
||||||
|
|
||||||
private CraftingTables()
|
|
||||||
{
|
|
||||||
this(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CraftingTables(boolean enabled)
|
|
||||||
{
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package resonantinduction.archaic.crafting;
|
|
||||||
|
|
||||||
import resonantinduction.core.prefab.tile.TileEntityInv;
|
|
||||||
|
|
||||||
public class TileEngineeringTable extends TileEntityInv
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package resonantinduction.archaic.engineering;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.renderer.texture.IconRegister;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Icon;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import resonantinduction.core.prefab.block.BlockRI;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Advanced tiering of a crafting table adding advanced features such as visual crafting, and auto
|
||||||
|
* crafting. Original idea by Infinite
|
||||||
|
*
|
||||||
|
* @author DarkGuardsman
|
||||||
|
*/
|
||||||
|
public class BlockEngineeringTable extends BlockRI
|
||||||
|
{
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private Icon workbenchIconTop;
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private Icon workbenchIconFront;
|
||||||
|
|
||||||
|
public BlockEngineeringTable()
|
||||||
|
{
|
||||||
|
super("engineeringTable");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public Icon getIcon(int par1, int par2)
|
||||||
|
{
|
||||||
|
return par1 == 1 ? this.workbenchIconTop : (par1 == 0 ? Block.planks.getBlockTextureFromSide(par1) : (par1 != 2 && par1 != 4 ? this.blockIcon : this.workbenchIconFront));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerIcons(IconRegister par1IconRegister)
|
||||||
|
{
|
||||||
|
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
|
||||||
|
this.workbenchIconTop = par1IconRegister.registerIcon(this.getTextureName() + "_top");
|
||||||
|
this.workbenchIconFront = par1IconRegister.registerIcon(this.getTextureName() + "_front");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world)
|
||||||
|
{
|
||||||
|
return new TileEngineeringTable();
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,8 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import resonantinduction.archaic.imprint.ItemBlockFilter;
|
||||||
|
import resonantinduction.archaic.imprint.TileImprinter;
|
||||||
import calclavia.lib.prefab.slot.ISlotWatcher;
|
import calclavia.lib.prefab.slot.ISlotWatcher;
|
||||||
import calclavia.lib.prefab.slot.SlotCraftingResult;
|
import calclavia.lib.prefab.slot.SlotCraftingResult;
|
||||||
import calclavia.lib.prefab.slot.SlotSpecific;
|
import calclavia.lib.prefab.slot.SlotSpecific;
|
||||||
|
@ -13,9 +15,9 @@ import calclavia.lib.prefab.slot.SlotWatched;
|
||||||
public class ContainerEngineering extends Container implements ISlotWatcher
|
public class ContainerEngineering extends Container implements ISlotWatcher
|
||||||
{
|
{
|
||||||
public InventoryPlayer inventoryPlayer;
|
public InventoryPlayer inventoryPlayer;
|
||||||
public TileImprinter tileEntity;
|
public TileEngineeringTable tileEntity;
|
||||||
|
|
||||||
public ContainerEngineering(InventoryPlayer inventoryPlayer, TileImprinter tileEntity)
|
public ContainerEngineering(InventoryPlayer inventoryPlayer, TileEngineeringTable tileEntity)
|
||||||
{
|
{
|
||||||
this.tileEntity = tileEntity;
|
this.tileEntity = tileEntity;
|
||||||
this.tileEntity.container = this;
|
this.tileEntity.container = this;
|
||||||
|
|
|
@ -0,0 +1,412 @@
|
||||||
|
package resonantinduction.archaic.engineering;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.crafting.CraftingManager;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import resonantinduction.api.IArmbot;
|
||||||
|
import resonantinduction.api.IArmbotUseable;
|
||||||
|
import resonantinduction.api.events.AutoCraftEvent;
|
||||||
|
import resonantinduction.archaic.imprint.ItemBlockFilter;
|
||||||
|
import resonantinduction.archaic.imprint.TileImprinter;
|
||||||
|
import resonantinduction.electrical.encoder.coding.args.ArgumentData;
|
||||||
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
import calclavia.lib.prefab.slot.ISlotPickResult;
|
||||||
|
import calclavia.lib.prefab.tile.TileAdvanced;
|
||||||
|
import calclavia.lib.utility.AutoCraftingManager;
|
||||||
|
import calclavia.lib.utility.AutoCraftingManager.IAutoCrafter;
|
||||||
|
import calclavia.lib.utility.LanguageUtility;
|
||||||
|
|
||||||
|
import com.builtbroken.common.Pair;
|
||||||
|
|
||||||
|
public class TileEngineeringTable extends TileAdvanced implements ISidedInventory, IArmbotUseable, ISlotPickResult, IAutoCrafter
|
||||||
|
{
|
||||||
|
public static final int CRAFTING_MATRIX_END = 9;
|
||||||
|
|
||||||
|
private AutoCraftingManager craftManager;
|
||||||
|
|
||||||
|
/** 9 slots for crafting, 1 slot for a output. */
|
||||||
|
public ItemStack[] craftingMatrix = new ItemStack[9];
|
||||||
|
public static final int[] craftingSlots = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||||
|
|
||||||
|
/** The output inventory containing slots. */
|
||||||
|
public ItemStack[] output = new ItemStack[1];
|
||||||
|
public final int craftingOutputSlot = 0;
|
||||||
|
public static int[] inventorySlots;
|
||||||
|
|
||||||
|
/** The containing currently used by the imprinter. */
|
||||||
|
public ContainerEngineering container;
|
||||||
|
|
||||||
|
/** The ability for the imprinter to serach nearby inventories. */
|
||||||
|
public boolean searchInventories = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUpdate()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Gets the AutoCraftingManager that does all the crafting results */
|
||||||
|
public AutoCraftingManager getCraftingManager()
|
||||||
|
{
|
||||||
|
if (craftManager == null)
|
||||||
|
{
|
||||||
|
craftManager = new AutoCraftingManager(this);
|
||||||
|
}
|
||||||
|
return craftManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSizeInventory()
|
||||||
|
{
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor
|
||||||
|
* sections).
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int slot, ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if (slot < this.getSizeInventory())
|
||||||
|
{
|
||||||
|
if (slot < CRAFTING_MATRIX_END)
|
||||||
|
{
|
||||||
|
this.craftingMatrix[slot] = itemStack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.output[slot - CRAFTING_MATRIX_END] = itemStack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int i, int amount)
|
||||||
|
{
|
||||||
|
if (this.getStackInSlot(i) != null)
|
||||||
|
{
|
||||||
|
ItemStack stack;
|
||||||
|
|
||||||
|
if (this.getStackInSlot(i).stackSize <= amount)
|
||||||
|
{
|
||||||
|
stack = this.getStackInSlot(i);
|
||||||
|
this.setInventorySlotContents(i, null);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack = this.getStackInSlot(i).splitStack(amount);
|
||||||
|
|
||||||
|
if (this.getStackInSlot(i).stackSize == 0)
|
||||||
|
{
|
||||||
|
this.setInventorySlotContents(i, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot)
|
||||||
|
{
|
||||||
|
if (slot < CRAFTING_MATRIX_END)
|
||||||
|
{
|
||||||
|
return this.craftingMatrix[slot];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.output[slot - CRAFTING_MATRIX_END];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When some containers are closed they call this on each slot, then drop whatever it returns as
|
||||||
|
* an EntityItem - like when you close a workbench GUI.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlotOnClosing(int slot)
|
||||||
|
{
|
||||||
|
if (this.getStackInSlot(slot) != null)
|
||||||
|
{
|
||||||
|
ItemStack var2 = this.getStackInSlot(slot);
|
||||||
|
this.setInventorySlotContents(slot, null);
|
||||||
|
return var2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInvName()
|
||||||
|
{
|
||||||
|
return LanguageUtility.getLocal("tile.imprinter.name");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openChest()
|
||||||
|
{
|
||||||
|
this.onInventoryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeChest()
|
||||||
|
{
|
||||||
|
this.onInventoryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an InventoryCrafting Matrix on the fly.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public InventoryCrafting getCraftingMatrix()
|
||||||
|
{
|
||||||
|
if (this.container != null)
|
||||||
|
{
|
||||||
|
InventoryCrafting inventoryCrafting = new InventoryCrafting(this.container, 3, 3);
|
||||||
|
|
||||||
|
for (int i = 0; i < this.craftingMatrix.length; i++)
|
||||||
|
{
|
||||||
|
inventoryCrafting.setInventorySlotContents(i, this.craftingMatrix[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return inventoryCrafting;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void replaceCraftingMatrix(InventoryCrafting inventoryCrafting)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this.craftingMatrix.length; i++)
|
||||||
|
{
|
||||||
|
this.craftingMatrix[i] = inventoryCrafting.getStackInSlot(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMatrixEmpty()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
if (this.craftingMatrix[i] != null)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Updates all the output slots. Call this to update the Engineering Table. */
|
||||||
|
@Override
|
||||||
|
public void onInventoryChanged()
|
||||||
|
{
|
||||||
|
if (!this.worldObj.isRemote)
|
||||||
|
{
|
||||||
|
this.output[craftingOutputSlot] = null;
|
||||||
|
|
||||||
|
/** Try to craft from crafting grid. If not possible, then craft from imprint. */
|
||||||
|
boolean didCraft = false;
|
||||||
|
|
||||||
|
/** Simulate an Inventory Crafting Instance */
|
||||||
|
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
|
||||||
|
|
||||||
|
if (inventoryCrafting != null)
|
||||||
|
{
|
||||||
|
ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj);
|
||||||
|
|
||||||
|
if (matrixOutput != null && this.getCraftingManager().getIdealRecipe(matrixOutput) != null)
|
||||||
|
{
|
||||||
|
this.output[craftingOutputSlot] = matrixOutput;
|
||||||
|
didCraft = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (this.output[imprintInputSlot] != null && !didCraft)
|
||||||
|
{
|
||||||
|
if (this.output[imprintInputSlot].getItem() instanceof ItemBlockFilter)
|
||||||
|
{
|
||||||
|
ArrayList<ItemStack> filters = ItemBlockFilter.getFilters(this.output[0]);
|
||||||
|
|
||||||
|
for (ItemStack outputStack : filters)
|
||||||
|
{
|
||||||
|
if (outputStack != null)
|
||||||
|
{
|
||||||
|
Pair<ItemStack, ItemStack[]> idealRecipe = this.getCraftingManager().getIdealRecipe(outputStack);
|
||||||
|
|
||||||
|
if (idealRecipe != null)
|
||||||
|
{
|
||||||
|
ItemStack recipeOutput = idealRecipe.left();
|
||||||
|
if (recipeOutput != null & recipeOutput.stackSize > 0)
|
||||||
|
{
|
||||||
|
this.output[craftingOutputSlot] = recipeOutput;
|
||||||
|
didCraft = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPickUpFromSlot(EntityPlayer entityPlayer, int s, ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if (itemStack != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
Pair<ItemStack, ItemStack[]> idealRecipeItem = this.getCraftingManager().getIdealRecipe(itemStack);
|
||||||
|
|
||||||
|
if (idealRecipeItem != null)
|
||||||
|
{
|
||||||
|
this.getCraftingManager().consumeItems(idealRecipeItem.right().clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Tries to let the Armbot craft an item. */
|
||||||
|
@Override
|
||||||
|
public boolean onUse(IArmbot armbot, List<ArgumentData> data)
|
||||||
|
{
|
||||||
|
this.onInventoryChanged();
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (this.imprinterMatrix[craftingOutputSlot] != null)
|
||||||
|
{
|
||||||
|
AutoCraftEvent.PreCraft event = new AutoCraftEvent.PreCraft(this.worldObj, new Vector3(this), this, this.imprinterMatrix[craftingOutputSlot]);
|
||||||
|
MinecraftForge.EVENT_BUS.post(event);
|
||||||
|
|
||||||
|
if (!event.isCanceled())
|
||||||
|
{
|
||||||
|
armbot.grabObject(this.imprinterMatrix[craftingOutputSlot].copy());
|
||||||
|
this.onPickUpFromSlot(null, 2, this.imprinterMatrix[craftingOutputSlot]);
|
||||||
|
this.imprinterMatrix[craftingOutputSlot] = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ///////////////////////////////////////
|
||||||
|
// // Save And Data processing //////
|
||||||
|
// ///////////////////////////////////////
|
||||||
|
/** NBT Data */
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
|
NBTTagList var2 = nbt.getTagList("Items");
|
||||||
|
this.craftingMatrix = new ItemStack[9];
|
||||||
|
this.output = new ItemStack[1];
|
||||||
|
|
||||||
|
for (int i = 0; i < var2.tagCount(); ++i)
|
||||||
|
{
|
||||||
|
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(i);
|
||||||
|
byte var5 = var4.getByte("Slot");
|
||||||
|
|
||||||
|
if (var5 >= 0 && var5 < this.getSizeInventory())
|
||||||
|
{
|
||||||
|
this.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.searchInventories = nbt.getBoolean("searchInventories");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Writes a tile entity to NBT. */
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
|
NBTTagList var2 = new NBTTagList();
|
||||||
|
|
||||||
|
for (int i = 0; i < this.getSizeInventory(); ++i)
|
||||||
|
{
|
||||||
|
if (this.getStackInSlot(i) != null)
|
||||||
|
{
|
||||||
|
NBTTagCompound var4 = new NBTTagCompound();
|
||||||
|
var4.setByte("Slot", (byte) i);
|
||||||
|
this.getStackInSlot(i).writeToNBT(var4);
|
||||||
|
var2.appendTag(var4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nbt.setTag("Items", var2);
|
||||||
|
|
||||||
|
nbt.setBoolean("searchInventories", this.searchInventories);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ///////////////////////////////////////
|
||||||
|
// // Inventory Access side Methods //////
|
||||||
|
// ///////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInvNameLocalized()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventoryStackLimit()
|
||||||
|
{
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||||
|
{
|
||||||
|
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getAccessibleSlotsFromSide(int side)
|
||||||
|
{
|
||||||
|
return this.getCraftingInv();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
|
||||||
|
{
|
||||||
|
return this.isItemValidForSlot(slot, itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
|
||||||
|
{
|
||||||
|
return this.isItemValidForSlot(slot, itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getCraftingInv()
|
||||||
|
{
|
||||||
|
return craftingSlots;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.archaic.engineering;
|
package resonantinduction.archaic.imprint;
|
||||||
|
|
||||||
import resonantinduction.core.prefab.block.BlockRotatableBase;
|
import resonantinduction.core.prefab.block.BlockRotatableBase;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.archaic.engineering;
|
package resonantinduction.archaic.imprint;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
package resonantinduction.archaic.imprint;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import calclavia.lib.prefab.slot.ISlotWatcher;
|
||||||
|
import calclavia.lib.prefab.slot.SlotCraftingResult;
|
||||||
|
import calclavia.lib.prefab.slot.SlotSpecific;
|
||||||
|
import calclavia.lib.prefab.slot.SlotWatched;
|
||||||
|
|
||||||
|
public class ContainerImprinter extends Container implements ISlotWatcher
|
||||||
|
{
|
||||||
|
public InventoryPlayer inventoryPlayer;
|
||||||
|
public TileImprinter tileEntity;
|
||||||
|
|
||||||
|
public ContainerImprinter(InventoryPlayer inventoryPlayer, TileImprinter tileEntity)
|
||||||
|
{
|
||||||
|
this.tileEntity = tileEntity;
|
||||||
|
this.tileEntity.container = this;
|
||||||
|
this.inventoryPlayer = inventoryPlayer;
|
||||||
|
|
||||||
|
/** Crafting Matrix */
|
||||||
|
for (int x = 0; x < 3; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < 3; y++)
|
||||||
|
{
|
||||||
|
this.addSlotToContainer(new SlotWatched(this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Imprint Input for Imprinting
|
||||||
|
this.addSlotToContainer(new SlotSpecific(this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START, 68, 34, ItemBlockFilter.class));
|
||||||
|
// Item to be imprinted
|
||||||
|
this.addSlotToContainer(new SlotWatched(this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START + 1, 92, 34, this));
|
||||||
|
// Result of Crafting/Imprinting
|
||||||
|
this.addSlotToContainer(new SlotCraftingResult(this.tileEntity, this, this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START + 2, 148, 34));
|
||||||
|
|
||||||
|
// Imprinter Inventory
|
||||||
|
for (int ii = 0; ii < 2; ii++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
this.addSlotToContainer(new SlotWatched(this.tileEntity, (i + ii * 9) + TileImprinter.INVENTORY_START, 8 + i * 18, 80 + ii * 18, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player Inventory
|
||||||
|
int var3;
|
||||||
|
|
||||||
|
for (var3 = 0; var3 < 3; ++var3)
|
||||||
|
{
|
||||||
|
for (int var4 = 0; var4 < 9; ++var4)
|
||||||
|
{
|
||||||
|
this.addSlotToContainer(new SlotWatched(inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 120 + var3 * 18, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var3 = 0; var3 < 9; ++var3)
|
||||||
|
{
|
||||||
|
this.addSlotToContainer(new SlotWatched(inventoryPlayer, var3, 8 + var3 * 18, 178, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tileEntity.openChest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContainerClosed(EntityPlayer par1EntityPlayer)
|
||||||
|
{
|
||||||
|
super.onContainerClosed(par1EntityPlayer);
|
||||||
|
this.tileEntity.closeChest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteractWith(EntityPlayer player)
|
||||||
|
{
|
||||||
|
return this.tileEntity.isUseableByPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
|
||||||
|
@Override
|
||||||
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
|
||||||
|
{
|
||||||
|
ItemStack copyStack = null;
|
||||||
|
Slot slotObj = (Slot) this.inventorySlots.get(slot);
|
||||||
|
|
||||||
|
if (slotObj != null && slotObj.getHasStack())
|
||||||
|
{
|
||||||
|
ItemStack slotStack = slotObj.getStack();
|
||||||
|
copyStack = slotStack.copy();
|
||||||
|
|
||||||
|
if (slot == TileImprinter.INVENTORY_START - 1)
|
||||||
|
{
|
||||||
|
// Prevents filter from being duplicated
|
||||||
|
this.tileEntity.setInventorySlotContents(TileImprinter.INVENTORY_START - 1, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slot > this.tileEntity.getSizeInventory() - 1)
|
||||||
|
{
|
||||||
|
if (this.getSlot(TileImprinter.IMPRINTER_MATRIX_START).isItemValid(slotStack))
|
||||||
|
{
|
||||||
|
if (!this.mergeItemStack(slotStack, TileImprinter.IMPRINTER_MATRIX_START, TileImprinter.IMPRINTER_MATRIX_START + 1, true))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!this.mergeItemStack(slotStack, TileImprinter.INVENTORY_START, this.tileEntity.getSizeInventory(), false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), this.tileEntity.getSizeInventory() + 36, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slotStack.stackSize == 0)
|
||||||
|
{
|
||||||
|
slotObj.putStack(null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slotObj.onSlotChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slotStack.stackSize == copyStack.stackSize)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
slotObj.onPickupFromSlot(player, slotStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.slotContentsChanged(slot);
|
||||||
|
return copyStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void slotContentsChanged(int slot)
|
||||||
|
{
|
||||||
|
this.tileEntity.onInventoryChanged();
|
||||||
|
this.detectAndSendChanges();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.archaic.engineering;
|
package resonantinduction.archaic.imprint;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.archaic.engineering;
|
package resonantinduction.archaic.imprint;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -44,7 +44,7 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
public static int[] inventorySlots;
|
public static int[] inventorySlots;
|
||||||
|
|
||||||
/** The containing currently used by the imprinter. */
|
/** The containing currently used by the imprinter. */
|
||||||
public ContainerEngineering container;
|
public ContainerImprinter container;
|
||||||
|
|
||||||
/** Is the current crafting result a result of an imprint? */
|
/** Is the current crafting result a result of an imprint? */
|
||||||
private boolean isImprinting = false;
|
private boolean isImprinting = false;
|
|
@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import resonantinduction.api.IFilterable;
|
import resonantinduction.api.IFilterable;
|
||||||
import resonantinduction.archaic.engineering.ItemBlockFilter;
|
import resonantinduction.archaic.imprint.ItemBlockFilter;
|
||||||
import resonantinduction.core.prefab.tile.TileEntityFilterable;
|
import resonantinduction.core.prefab.tile.TileEntityFilterable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.api.IFilterable;
|
import resonantinduction.api.IFilterable;
|
||||||
import resonantinduction.archaic.engineering.ItemBlockFilter;
|
import resonantinduction.archaic.imprint.ItemBlockFilter;
|
||||||
import calclavia.lib.prefab.tile.IRotatable;
|
import calclavia.lib.prefab.tile.IRotatable;
|
||||||
|
|
||||||
public abstract class TileEntityFilterable extends TileAssembly implements IRotatable, IFilterable
|
public abstract class TileEntityFilterable extends TileAssembly implements IRotatable, IFilterable
|
||||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import resonantinduction.archaic.engineering.ItemBlockFilter;
|
import resonantinduction.archaic.imprint.ItemBlockFilter;
|
||||||
import resonantinduction.core.prefab.tile.TileEntityFilterable;
|
import resonantinduction.core.prefab.tile.TileEntityFilterable;
|
||||||
import calclavia.lib.render.RenderUtility;
|
import calclavia.lib.render.RenderUtility;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
|
|
@ -12,6 +12,7 @@ fluid.mixture=Mixture
|
||||||
### Archaic Module
|
### Archaic Module
|
||||||
## Transport
|
## Transport
|
||||||
tile.resonantinduction\:crate.name=Crate
|
tile.resonantinduction\:crate.name=Crate
|
||||||
|
tile.resonantinduction\:engineeringTable.name=Engineering Table
|
||||||
|
|
||||||
### Mechanical Module
|
### Mechanical Module
|
||||||
## Transport
|
## Transport
|
||||||
|
|
Loading…
Reference in a new issue