use of mdc.voodoocraft.tile.TileDollPedestal in project VoodooCraft by Mod-DevCafeTeam.
the class BlockDollPedestal method onBlockActivated.
/**
* Puts dolls in and out of the pedestal.
* @return
*/
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if (hand == EnumHand.OFF_HAND || worldIn.getTileEntity(pos) == null)
return false;
TileDollPedestal tile = (TileDollPedestal) worldIn.getTileEntity(pos);
IItemHandler tileinv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (heldItem == null) {
if (tileinv.getStackInSlot(0) != null) {
playerIn.setHeldItem(hand, tileinv.getStackInSlot(0));
tileinv.extractItem(0, tileinv.getStackInSlot(0).stackSize, false);
return true;
}
} else {
if (tileinv.getStackInSlot(0) == null) {
tileinv.insertItem(0, heldItem, false);
playerIn.setHeldItem(hand, null);
return true;
}
}
return false;
}
use of mdc.voodoocraft.tile.TileDollPedestal in project VoodooCraft by Mod-DevCafeTeam.
the class BlockDollPedestal method breakBlock.
/**
* Drops item in the pedestal
* @param worldIn
* @param pos
* @param state
*/
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
if (!worldIn.isRemote) {
TileEntity te = worldIn.getTileEntity(pos);
if (te != null) {
TileDollPedestal tile = (TileDollPedestal) te;
IItemHandler tileinv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
ItemStack stack = tileinv.getStackInSlot(0);
if (stack != null) {
EntityItem entItem = new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack);
worldIn.spawnEntity(entItem);
}
}
}
super.breakBlock(worldIn, pos, state);
}
Aggregations