Engineering table can be configured to not autocraft
This commit is contained in:
parent
c029993500
commit
5888877b0d
4 changed files with 202 additions and 291 deletions
|
@ -8,7 +8,6 @@ import resonantinduction.archaic.blocks.BlockTurntable;
|
||||||
import resonantinduction.archaic.crate.BlockCrate;
|
import resonantinduction.archaic.crate.BlockCrate;
|
||||||
import resonantinduction.archaic.crate.ItemBlockCrate;
|
import resonantinduction.archaic.crate.ItemBlockCrate;
|
||||||
import resonantinduction.archaic.crate.TileCrate;
|
import resonantinduction.archaic.crate.TileCrate;
|
||||||
import resonantinduction.archaic.engineering.BlockEngineeringTable;
|
|
||||||
import resonantinduction.archaic.engineering.ItemHammer;
|
import resonantinduction.archaic.engineering.ItemHammer;
|
||||||
import resonantinduction.archaic.engineering.TileEngineeringTable;
|
import resonantinduction.archaic.engineering.TileEngineeringTable;
|
||||||
import resonantinduction.archaic.filter.BlockFilter;
|
import resonantinduction.archaic.filter.BlockFilter;
|
||||||
|
@ -37,7 +36,6 @@ import calclavia.lib.content.ContentRegistry;
|
||||||
import calclavia.lib.network.PacketAnnotation;
|
import calclavia.lib.network.PacketAnnotation;
|
||||||
import calclavia.lib.network.PacketHandler;
|
import calclavia.lib.network.PacketHandler;
|
||||||
import calclavia.lib.prefab.item.ItemBlockMetadata;
|
import calclavia.lib.prefab.item.ItemBlockMetadata;
|
||||||
import calclavia.lib.prefab.item.ItemBlockSaved;
|
|
||||||
import calclavia.lib.recipe.UniversalRecipe;
|
import calclavia.lib.recipe.UniversalRecipe;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.Mod.EventHandler;
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
|
@ -100,7 +98,7 @@ public class Archaic
|
||||||
{
|
{
|
||||||
Settings.load();
|
Settings.load();
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
||||||
blockEngineeringTable = contentRegistry.createBlock(BlockEngineeringTable.class, ItemBlockSaved.class, TileEngineeringTable.class);
|
blockEngineeringTable = contentRegistry.newBlock(TileEngineeringTable.class);
|
||||||
blockCrate = contentRegistry.createBlock(BlockCrate.class, ItemBlockCrate.class, TileCrate.class);
|
blockCrate = contentRegistry.createBlock(BlockCrate.class, ItemBlockCrate.class, TileCrate.class);
|
||||||
blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class);
|
blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class);
|
||||||
blockTurntable = contentRegistry.createBlock(BlockTurntable.class);
|
blockTurntable = contentRegistry.createBlock(BlockTurntable.class);
|
||||||
|
|
|
@ -1,281 +0,0 @@
|
||||||
package resonantinduction.archaic.engineering;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import universalelectricity.api.vector.Vector2;
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import calclavia.lib.prefab.block.BlockRotatable;
|
|
||||||
import calclavia.lib.prefab.item.ItemBlockSaved;
|
|
||||||
import calclavia.lib.utility.WorldUtility;
|
|
||||||
import calclavia.lib.utility.inventory.InventoryUtility;
|
|
||||||
import codechicken.multipart.ControlKeyModifer;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A world-based crafting table.
|
|
||||||
*
|
|
||||||
* TODO: Filter support, inventory seek support.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*/
|
|
||||||
public class BlockEngineeringTable extends BlockRotatable
|
|
||||||
{
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private Icon iconTop;
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private Icon iconFront;
|
|
||||||
|
|
||||||
public BlockEngineeringTable(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.wood);
|
|
||||||
setBlockBounds(0, 0, 0, 1, 0.9f, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
|
|
||||||
{
|
|
||||||
if (!world.isRemote && isControlDown(player))
|
|
||||||
{
|
|
||||||
dropInventory(world, x, y, z, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dropEntireInventory(World world, int x, int y, int z, int par5, int par6)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dropInventory(World world, int x, int y, int z, int par5, int par6)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity != null)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof IInventory)
|
|
||||||
{
|
|
||||||
IInventory inventory = (IInventory) tileEntity;
|
|
||||||
|
|
||||||
// Don't drop the output, so subtract by one.
|
|
||||||
for (int i = 0; i < inventory.getSizeInventory() - 1; ++i)
|
|
||||||
{
|
|
||||||
ItemStack var7 = inventory.getStackInSlot(i);
|
|
||||||
|
|
||||||
if (var7 != null)
|
|
||||||
{
|
|
||||||
Random random = new Random();
|
|
||||||
float var8 = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float var9 = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float var10 = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
|
|
||||||
while (var7.stackSize > 0)
|
|
||||||
{
|
|
||||||
int var11 = random.nextInt(21) + 10;
|
|
||||||
|
|
||||||
if (var11 > var7.stackSize)
|
|
||||||
{
|
|
||||||
var11 = var7.stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
var7.stackSize -= var11;
|
|
||||||
EntityItem var12 = new EntityItem(world, (x + var8), (y + var9), (z + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage()));
|
|
||||||
|
|
||||||
if (var7.hasTagCompound())
|
|
||||||
{
|
|
||||||
var12.getEntityItem().setTagCompound((NBTTagCompound) var7.getTagCompound().copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
float var13 = 0.05F;
|
|
||||||
var12.motionX = ((float) random.nextGaussian() * var13);
|
|
||||||
var12.motionY = ((float) random.nextGaussian() * var13 + 0.2F);
|
|
||||||
var12.motionZ = ((float) random.nextGaussian() * var13);
|
|
||||||
world.spawnEntityInWorld(var12);
|
|
||||||
|
|
||||||
if (var7.stackSize <= 0)
|
|
||||||
{
|
|
||||||
inventory.setInventorySlotContents(i, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inventory.setInventorySlotContents(i, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
inventory.onInventoryChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemHammer)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (te instanceof TileEngineeringTable)
|
|
||||||
{
|
|
||||||
TileEngineeringTable tile = (TileEngineeringTable) te;
|
|
||||||
|
|
||||||
if (hitSide == 1)
|
|
||||||
{
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
Vector3 hitVector = new Vector3(hitX, 0, hitZ);
|
|
||||||
final double regionLength = 1d / 3d;
|
|
||||||
|
|
||||||
// Rotate the hit vector baed on direction of the tile.
|
|
||||||
hitVector.translate(new Vector3(-0.5, 0, -0.5));
|
|
||||||
hitVector.rotate(WorldUtility.getAngleFromForgeDirection(tile.getDirection()), Vector3.UP());
|
|
||||||
hitVector.translate(new Vector3(0.5, 0, 0.5));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Crafting Matrix
|
|
||||||
*/
|
|
||||||
matrix:
|
|
||||||
for (int j = 0; j < 3; j++)
|
|
||||||
{
|
|
||||||
for (int k = 0; k < 3; k++)
|
|
||||||
{
|
|
||||||
Vector2 check = new Vector2(j, k).scale(regionLength);
|
|
||||||
|
|
||||||
if (check.distance(hitVector.toVector2()) < regionLength)
|
|
||||||
{
|
|
||||||
int slotID = j * 3 + k;
|
|
||||||
interactCurrentItem(tile, slotID, player);
|
|
||||||
break matrix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tile.onInventoryChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (hitSide != 0)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Take out of engineering table.
|
|
||||||
*/
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
tile.setPlayerInventory(player.inventory);
|
|
||||||
|
|
||||||
ItemStack output = tile.getStackInSlot(9);
|
|
||||||
boolean firstLoop = true;
|
|
||||||
|
|
||||||
while (output != null && (firstLoop || ControlKeyModifer.isControlDown(player)))
|
|
||||||
{
|
|
||||||
tile.onPickUpFromSlot(player, 9, output);
|
|
||||||
|
|
||||||
if (output.stackSize > 0)
|
|
||||||
{
|
|
||||||
InventoryUtility.dropItemStack(world, new Vector3(player), output, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
tile.setInventorySlotContents(9, null);
|
|
||||||
tile.onInventoryChanged();
|
|
||||||
|
|
||||||
output = tile.getStackInSlot(9);
|
|
||||||
firstLoop = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
tile.setPlayerInventory(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity instanceof TileEngineeringTable)
|
|
||||||
{
|
|
||||||
TileEngineeringTable tile = (TileEngineeringTable) tileEntity;
|
|
||||||
tile.searchInventories = !tile.searchInventories;
|
|
||||||
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
if (tile.searchInventories)
|
|
||||||
player.addChatMessage("Engineering table will now search for nearby inventories for resources.");
|
|
||||||
else
|
|
||||||
player.addChatMessage("Engineering table will not search for nearby inventories for resources.");
|
|
||||||
}
|
|
||||||
|
|
||||||
world.markBlockForUpdate(x, y, z);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int side, int meta)
|
|
||||||
{
|
|
||||||
return side == 1 ? this.iconTop : (side == meta ? this.iconFront : this.blockIcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister par1IconRegister)
|
|
||||||
{
|
|
||||||
this.iconTop = par1IconRegister.registerIcon(this.getTextureName() + "_top");
|
|
||||||
this.iconFront = par1IconRegister.registerIcon(this.getTextureName() + "_front");
|
|
||||||
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileEngineeringTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
|
|
||||||
{
|
|
||||||
ItemBlockSaved.dropBlockWithNBT(this, world, x, y, z);
|
|
||||||
super.breakBlock(world, x, y, z, par5, par6);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** To cancel the vanilla method of dropping the itemEntity */
|
|
||||||
@Override
|
|
||||||
protected void dropBlockAsItem_do(World world, int x, int y, int z, ItemStack stack)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,10 @@
|
||||||
package resonantinduction.archaic.engineering;
|
package resonantinduction.archaic.engineering;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.client.renderer.texture.IconRegister;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
@ -14,26 +17,39 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.network.packet.Packet;
|
import net.minecraft.network.packet.Packet;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Icon;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
|
import resonantinduction.core.Settings;
|
||||||
import resonantinduction.core.prefab.imprint.ItemImprint;
|
import resonantinduction.core.prefab.imprint.ItemImprint;
|
||||||
|
import universalelectricity.api.vector.Vector2;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
import calclavia.lib.content.module.TileBlock;
|
||||||
|
import calclavia.lib.content.module.prefab.TileInventory;
|
||||||
import calclavia.lib.gui.ContainerDummy;
|
import calclavia.lib.gui.ContainerDummy;
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
import calclavia.lib.network.IPacketReceiver;
|
||||||
import calclavia.lib.network.PacketHandler;
|
import calclavia.lib.network.PacketHandler;
|
||||||
|
import calclavia.lib.prefab.item.ItemBlockSaved;
|
||||||
import calclavia.lib.prefab.slot.ISlotPickResult;
|
import calclavia.lib.prefab.slot.ISlotPickResult;
|
||||||
import calclavia.lib.prefab.tile.IRotatable;
|
import calclavia.lib.prefab.tile.IRotatable;
|
||||||
import calclavia.lib.prefab.tile.TileAdvanced;
|
import calclavia.lib.prefab.vector.Cuboid;
|
||||||
|
import calclavia.lib.utility.WorldUtility;
|
||||||
import calclavia.lib.utility.inventory.AutoCraftingManager;
|
import calclavia.lib.utility.inventory.AutoCraftingManager;
|
||||||
|
import calclavia.lib.utility.inventory.InventoryUtility;
|
||||||
import calclavia.lib.utility.inventory.AutoCraftingManager.IAutoCrafter;
|
import calclavia.lib.utility.inventory.AutoCraftingManager.IAutoCrafter;
|
||||||
|
import codechicken.multipart.ControlKeyModifer;
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
import com.builtbroken.common.Pair;
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
public class TileEngineeringTable extends TileAdvanced implements IPacketReceiver, IRotatable, ISidedInventory, ISlotPickResult, IAutoCrafter
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
public class TileEngineeringTable extends TileInventory implements IPacketReceiver, IRotatable, ISidedInventory, ISlotPickResult, IAutoCrafter
|
||||||
{
|
{
|
||||||
public static final int CRAFTING_MATRIX_END = 9;
|
public static final int CRAFTING_MATRIX_END = 9;
|
||||||
public static final int CRAFTING_OUTPUT_END = CRAFTING_MATRIX_END + 1;
|
public static final int CRAFTING_OUTPUT_END = CRAFTING_MATRIX_END + 1;
|
||||||
|
@ -47,11 +63,11 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
|
||||||
private AutoCraftingManager craftManager;
|
private AutoCraftingManager craftManager;
|
||||||
|
|
||||||
/** 9 slots for crafting, 1 slot for a output. */
|
/** 9 slots for crafting, 1 slot for a output. */
|
||||||
public static final int CRAFTING_MATRIX_SIZE=9;
|
public static final int CRAFTING_MATRIX_SIZE = 9;
|
||||||
public ItemStack[] craftingMatrix = new ItemStack[CRAFTING_MATRIX_SIZE];
|
public ItemStack[] craftingMatrix = new ItemStack[CRAFTING_MATRIX_SIZE];
|
||||||
public static final int[] craftingSlots = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
public static final int[] craftingSlots = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||||
|
|
||||||
/** The output inventory containing slots.*/
|
/** The output inventory containing slots. */
|
||||||
public ItemStack[] outputInventory = new ItemStack[1];
|
public ItemStack[] outputInventory = new ItemStack[1];
|
||||||
|
|
||||||
/** The ability for the engineering table to search nearby inventories. */
|
/** The ability for the engineering table to search nearby inventories. */
|
||||||
|
@ -63,6 +79,181 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
|
||||||
private InventoryPlayer invPlayer = null;
|
private InventoryPlayer invPlayer = null;
|
||||||
private int[] playerSlots;
|
private int[] playerSlots;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private Icon iconTop;
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
private Icon iconFront;
|
||||||
|
|
||||||
|
public TileEngineeringTable()
|
||||||
|
{
|
||||||
|
super(Material.wood);
|
||||||
|
bounds = new Cuboid(0, 0, 0, 1, 0.9f, 1);
|
||||||
|
isOpaqueCube = false;
|
||||||
|
normalRender = false;
|
||||||
|
itemBlock = ItemBlockSaved.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public Icon getIcon(int side, int meta)
|
||||||
|
{
|
||||||
|
return side == 1 ? iconTop : (side == meta ? iconFront : icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerIcons(IconRegister iconRegister)
|
||||||
|
{
|
||||||
|
iconTop = iconRegister.registerIcon(this.getTextureName() + "_top");
|
||||||
|
iconFront = iconRegister.registerIcon(this.getTextureName() + "_front");
|
||||||
|
icon = iconRegister.registerIcon(this.getTextureName() + "_side");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void click(EntityPlayer player)
|
||||||
|
{
|
||||||
|
if (!world().isRemote && ControlKeyModifer.isControlDown(player))
|
||||||
|
{
|
||||||
|
if (this instanceof IInventory)
|
||||||
|
{
|
||||||
|
IInventory inventory = (IInventory) this;
|
||||||
|
|
||||||
|
// Don't drop the output, so subtract by one.
|
||||||
|
for (int i = 0; i < inventory.getSizeInventory() - 1; ++i)
|
||||||
|
{
|
||||||
|
ItemStack dropStack = inventory.getStackInSlot(i);
|
||||||
|
|
||||||
|
if (dropStack != null)
|
||||||
|
{
|
||||||
|
int var11 = dropStack.stackSize;
|
||||||
|
dropStack.stackSize -= var11;
|
||||||
|
InventoryUtility.dropItemStack(world(), center(), dropStack);
|
||||||
|
|
||||||
|
if (dropStack.stackSize <= 0)
|
||||||
|
inventory.setInventorySlotContents(i, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inventory.onInventoryChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean use(EntityPlayer player, int hitSide, Vector3 hit)
|
||||||
|
{
|
||||||
|
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemHammer)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hitSide == 1)
|
||||||
|
{
|
||||||
|
if (!world().isRemote)
|
||||||
|
{
|
||||||
|
Vector3 hitVector = new Vector3(hit.x, 0, hit.z);
|
||||||
|
final double regionLength = 1d / 3d;
|
||||||
|
|
||||||
|
// Rotate the hit vector baed on direction of the tile.
|
||||||
|
hitVector.translate(new Vector3(-0.5, 0, -0.5));
|
||||||
|
hitVector.rotate(WorldUtility.getAngleFromForgeDirection(getDirection()), Vector3.UP());
|
||||||
|
hitVector.translate(new Vector3(0.5, 0, 0.5));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crafting Matrix
|
||||||
|
*/
|
||||||
|
matrix:
|
||||||
|
for (int j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < 3; k++)
|
||||||
|
{
|
||||||
|
Vector2 check = new Vector2(j, k).scale(regionLength);
|
||||||
|
|
||||||
|
if (check.distance(hitVector.toVector2()) < regionLength)
|
||||||
|
{
|
||||||
|
int slotID = j * 3 + k;
|
||||||
|
interactCurrentItem(this, slotID, player);
|
||||||
|
break matrix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onInventoryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (hitSide != 0)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Take out of engineering table.
|
||||||
|
*/
|
||||||
|
if (!world().isRemote)
|
||||||
|
{
|
||||||
|
setPlayerInventory(player.inventory);
|
||||||
|
|
||||||
|
ItemStack output = getStackInSlot(9);
|
||||||
|
boolean firstLoop = true;
|
||||||
|
|
||||||
|
while (output != null && (firstLoop || ControlKeyModifer.isControlDown(player)))
|
||||||
|
{
|
||||||
|
onPickUpFromSlot(player, 9, output);
|
||||||
|
|
||||||
|
if (output.stackSize > 0)
|
||||||
|
{
|
||||||
|
InventoryUtility.dropItemStack(world(), new Vector3(player), output, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
setInventorySlotContents(9, null);
|
||||||
|
onInventoryChanged();
|
||||||
|
|
||||||
|
output = getStackInSlot(9);
|
||||||
|
firstLoop = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPlayerInventory(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean configure(EntityPlayer player, int hitSide, Vector3 hit)
|
||||||
|
{
|
||||||
|
searchInventories = !searchInventories;
|
||||||
|
|
||||||
|
if (!world().isRemote)
|
||||||
|
{
|
||||||
|
if (searchInventories)
|
||||||
|
player.addChatMessage("Engineering table will now search for nearby inventories for resources.");
|
||||||
|
else
|
||||||
|
player.addChatMessage("Engineering table will not search for nearby inventories for resources.");
|
||||||
|
}
|
||||||
|
|
||||||
|
markUpdate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemove(int par5, int par6)
|
||||||
|
{
|
||||||
|
ItemBlockSaved.dropBlockWithNBT(getBlockType(), world(), x(), y(), z());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int quantityDropped(int meta, int fortune)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dropEntireInventory(int par5, int par6)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a "fake inventory" and hook the player up to the crafter to use the player's items.
|
* Creates a "fake inventory" and hook the player up to the crafter to use the player's items.
|
||||||
*/
|
*/
|
||||||
|
@ -470,7 +661,10 @@ public class TileEngineeringTable extends TileAdvanced implements IPacketReceive
|
||||||
@Override
|
@Override
|
||||||
public int[] getAccessibleSlotsFromSide(int side)
|
public int[] getAccessibleSlotsFromSide(int side)
|
||||||
{
|
{
|
||||||
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
if (Settings.ALLOW_ENGINEERING_AUTOCRAFT)
|
||||||
|
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
|
|
||||||
|
return new int[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class Settings
|
||||||
|
|
||||||
/** Settings */
|
/** Settings */
|
||||||
private static boolean didLoad = false;
|
private static boolean didLoad = false;
|
||||||
public static int FURNACE_WATTAGE = 50000;
|
public static boolean ALLOW_ENGINEERING_AUTOCRAFT = true;
|
||||||
public static boolean SOUND_FXS = true;
|
public static boolean SOUND_FXS = true;
|
||||||
public static boolean SHINY_SILVER = true;
|
public static boolean SHINY_SILVER = true;
|
||||||
public static int MAX_CONTRACTOR_DISTANCE = 200;
|
public static int MAX_CONTRACTOR_DISTANCE = 200;
|
||||||
|
@ -65,7 +65,7 @@ public class Settings
|
||||||
if (!didLoad)
|
if (!didLoad)
|
||||||
{
|
{
|
||||||
// Config
|
// Config
|
||||||
FURNACE_WATTAGE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Furnace Wattage Per Tick", FURNACE_WATTAGE).getInt(FURNACE_WATTAGE);
|
ALLOW_ENGINEERING_AUTOCRAFT = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Engineering Table Autocraft", ALLOW_ENGINEERING_AUTOCRAFT).getBoolean(ALLOW_ENGINEERING_AUTOCRAFT);
|
||||||
SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS);
|
SOUND_FXS = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Tesla Sound FXs", SOUND_FXS).getBoolean(SOUND_FXS);
|
||||||
SHINY_SILVER = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Shiny silver wires", SHINY_SILVER).getBoolean(SHINY_SILVER);
|
SHINY_SILVER = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Shiny silver wires", SHINY_SILVER).getBoolean(SHINY_SILVER);
|
||||||
MAX_CONTRACTOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE);
|
MAX_CONTRACTOR_DISTANCE = CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Max EM Contractor Path", MAX_CONTRACTOR_DISTANCE).getInt(MAX_CONTRACTOR_DISTANCE);
|
||||||
|
|
Loading…
Reference in a new issue