2015-12-23 20:20:26 +00:00
|
|
|
package WayofTime.bloodmagic.block;
|
|
|
|
|
2016-03-18 17:16:38 +00:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
2015-12-23 20:20:26 +00:00
|
|
|
import net.minecraft.block.BlockContainer;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-02-05 01:32:21 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
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;
|
2016-03-18 17:16:38 +00:00
|
|
|
import net.minecraft.util.BlockRenderLayer;
|
|
|
|
import net.minecraft.util.EnumBlockRenderType;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraft.util.EnumHand;
|
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
2015-12-23 20:20:26 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2016-03-18 17:16:38 +00:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
|
|
|
import WayofTime.bloodmagic.registry.ModItems;
|
|
|
|
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
|
|
|
|
{
|
2016-03-18 17:16:38 +00:00
|
|
|
protected static final AxisAlignedBB ARRAY_AABB = new AxisAlignedBB(0, 0, 0, 1, 0.1, 1);
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
public BlockAlchemyArray()
|
|
|
|
{
|
|
|
|
super(Material.cloth);
|
|
|
|
|
|
|
|
setUnlocalizedName(Constants.Mod.MODID + ".alchemyArray");
|
2016-01-19 06:34:12 +00:00
|
|
|
setRegistryName(Constants.BloodMagicBlock.ALCHEMY_ARRAY.getRegName());
|
2016-02-05 01:32:21 +00:00
|
|
|
setHardness(0.1f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-18 17:16:38 +00:00
|
|
|
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
|
2016-02-05 01:32:21 +00:00
|
|
|
{
|
|
|
|
// No-op
|
2015-12-30 20:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-18 17:16:38 +00:00
|
|
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
2016-03-18 17:16:38 +00:00
|
|
|
return ARRAY_AABB;
|
2015-12-30 20:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2016-03-18 17:16:38 +00:00
|
|
|
public BlockRenderLayer getBlockLayer()
|
|
|
|
{
|
|
|
|
return BlockRenderLayer.CUTOUT;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
2016-03-18 17:16:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isFullCube(IBlockState state)
|
|
|
|
{
|
|
|
|
return false;
|
2015-12-30 20:34:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-18 17:16:38 +00:00
|
|
|
public boolean isVisuallyOpaque()
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-18 17:16:38 +00:00
|
|
|
public EnumBlockRenderType getRenderType(IBlockState state)
|
|
|
|
{
|
|
|
|
return EnumBlockRenderType.INVISIBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
|
|
|
TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos);
|
|
|
|
|
|
|
|
if (array == null || player.isSneaking())
|
|
|
|
return false;
|
|
|
|
|
2016-03-18 17:16:38 +00:00
|
|
|
ItemStack playerItem = player.getHeldItem(hand);
|
2015-12-30 20:34:40 +00:00
|
|
|
|
|
|
|
if (playerItem != null)
|
|
|
|
{
|
2016-01-05 19:52:04 +00:00
|
|
|
if (array.getStackInSlot(0) == null)
|
2015-12-30 20:34:40 +00:00
|
|
|
{
|
|
|
|
Utils.insertItemToTile(array, player, 0);
|
2016-01-05 19:52:04 +00:00
|
|
|
} else if (array.getStackInSlot(0) != 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 17:16:38 +00:00
|
|
|
world.notifyBlockUpdate(pos, state, state, 3);
|
2015-12-30 20:34:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-05 01:43:29 +00:00
|
|
|
@Override
|
2016-03-18 17:16:38 +00:00
|
|
|
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
|
2016-02-05 01:43:29 +00:00
|
|
|
{
|
|
|
|
return new ItemStack(ModItems.arcaneAshes);
|
|
|
|
}
|
|
|
|
|
2015-12-30 20:34:40 +00:00
|
|
|
@Override
|
|
|
|
public int quantityDropped(Random random)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
}
|