2015-12-23 20:20:26 +00:00
|
|
|
package WayofTime.bloodmagic.block;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockContainer;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-12-24 01:19:06 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-12-23 20:20:26 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.BlockPos;
|
2015-12-24 01:19:06 +00:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2015-12-23 20:20:26 +00:00
|
|
|
import net.minecraft.util.EnumWorldBlockLayer;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
2016-01-01 16:54:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.registry.AlchemyArrayRecipeRegistry;
|
2015-12-24 01:19:06 +00:00
|
|
|
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2015-12-23 20:20:26 +00:00
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public class BlockAlchemyArray extends BlockContainer
|
|
|
|
{
|
|
|
|
public BlockAlchemyArray()
|
|
|
|
{
|
|
|
|
super(Material.cloth);
|
|
|
|
|
|
|
|
setUnlocalizedName(Constants.Mod.MODID + ".alchemyArray");
|
|
|
|
setCreativeTab(BloodMagic.tabBloodMagic);
|
|
|
|
this.setHardness(0.1f);
|
2016-01-01 16:54:44 +00:00
|
|
|
this.setBlockBounds(0, 0, 0, 1, 0.1f, 1);
|
2015-12-30 20:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public EnumWorldBlockLayer getBlockLayer()
|
|
|
|
{
|
|
|
|
return EnumWorldBlockLayer.CUTOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isFullCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
|
|
|
{
|
|
|
|
TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos);
|
|
|
|
|
|
|
|
if (array == null || player.isSneaking())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ItemStack playerItem = player.getCurrentEquippedItem();
|
|
|
|
|
|
|
|
if (playerItem != null)
|
|
|
|
{
|
2016-01-01 16:54:44 +00:00
|
|
|
if (array.getStackInSlot(0) == null && AlchemyArrayRecipeRegistry.getRecipeForInput(playerItem) != null)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
|
|
|
Utils.insertItemToTile(array, player, 0);
|
2016-01-01 16:54:44 +00:00
|
|
|
} else if (array.getStackInSlot(0) != null && AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(array.getStackInSlot(0), playerItem) != null)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
|
|
|
Utils.insertItemToTile(array, player, 1);
|
|
|
|
array.attemptCraft();
|
2016-01-01 16:54:44 +00:00
|
|
|
} else
|
|
|
|
{
|
2016-01-03 23:40:58 +00:00
|
|
|
return true;
|
2015-12-30 20:34:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
world.markBlockForUpdate(pos);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int quantityDropped(Random random)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRenderType()
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TileEntity createNewTileEntity(World worldIn, int meta)
|
|
|
|
{
|
|
|
|
return new TileAlchemyArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState)
|
|
|
|
{
|
2015-12-24 01:19:06 +00:00
|
|
|
TileAlchemyArray alchemyArray = (TileAlchemyArray) world.getTileEntity(blockPos);
|
|
|
|
if (alchemyArray != null)
|
|
|
|
alchemyArray.dropItems();
|
|
|
|
|
|
|
|
super.breakBlock(world, blockPos, blockState);
|
|
|
|
}
|
2015-12-23 20:20:26 +00:00
|
|
|
}
|