2016-02-17 09:21:22 -05:00
|
|
|
package WayofTime.bloodmagic.block;
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockContainer;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-02-17 16:31:11 -05:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-02-17 09:21:22 -05:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.BlockPos;
|
2016-02-17 16:31:11 -05:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-02-17 09:21:22 -05:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
2016-02-17 16:31:11 -05:00
|
|
|
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
|
|
|
import WayofTime.bloodmagic.api.soul.IDemonWillGem;
|
|
|
|
import WayofTime.bloodmagic.tile.TileDemonCrucible;
|
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
2016-02-17 09:21:22 -05:00
|
|
|
|
|
|
|
public class BlockDemonCrucible extends BlockContainer
|
|
|
|
{
|
|
|
|
public BlockDemonCrucible()
|
|
|
|
{
|
|
|
|
super(Material.rock);
|
|
|
|
|
|
|
|
setUnlocalizedName(Constants.Mod.MODID + ".demonCrucible");
|
|
|
|
setRegistryName(Constants.BloodMagicBlock.DEMON_CRUCIBLE.getRegName());
|
|
|
|
setCreativeTab(BloodMagic.tabBloodMagic);
|
|
|
|
setHardness(2.0F);
|
|
|
|
setResistance(5.0F);
|
|
|
|
setHarvestLevel("pickaxe", 0);
|
|
|
|
|
|
|
|
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isFullCube()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isVisuallyOpaque()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRenderType()
|
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TileEntity createNewTileEntity(World world, int meta)
|
|
|
|
{
|
2016-02-17 16:31:11 -05:00
|
|
|
return new TileDemonCrucible();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
|
|
|
|
{
|
|
|
|
TileDemonCrucible crucible = (TileDemonCrucible) world.getTileEntity(pos);
|
|
|
|
|
|
|
|
if (crucible == null || player.isSneaking())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ItemStack playerItem = player.getCurrentEquippedItem();
|
|
|
|
|
|
|
|
if (playerItem != null)
|
|
|
|
{
|
|
|
|
if (!(playerItem.getItem() instanceof IDemonWill) && !(playerItem.getItem() instanceof IDemonWillGem))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Utils.insertItemToTile(crucible, player);
|
|
|
|
|
|
|
|
world.markBlockForUpdate(pos);
|
|
|
|
return true;
|
2016-02-17 09:21:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState)
|
|
|
|
{
|
2016-02-17 16:31:11 -05:00
|
|
|
TileDemonCrucible tile = (TileDemonCrucible) world.getTileEntity(blockPos);
|
|
|
|
if (tile != null)
|
|
|
|
tile.dropItems();
|
2016-02-17 09:21:22 -05:00
|
|
|
|
|
|
|
super.breakBlock(world, blockPos, blockState);
|
|
|
|
}
|
|
|
|
}
|