use of forestry.api.core.IToolScoop in project ForestryMC by ForestryMC.
the class BlockForestryLeaves method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
TileLeaves leaves = TileUtil.getTile(worldIn, pos, TileLeaves.class);
if (leaves != null) {
IButterfly caterpillar = leaves.getCaterpillar();
ItemStack heldItem = playerIn.getHeldItem(hand);
if (heldItem.getItem() instanceof IToolScoop && caterpillar != null) {
ItemStack butterfly = ButterflyManager.butterflyRoot.getMemberStack(caterpillar, EnumFlutterType.CATERPILLAR);
ItemStackUtil.dropItemStackAsEntity(butterfly, worldIn, pos);
leaves.setCaterpillar(null);
return true;
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
use of forestry.api.core.IToolScoop in project ForestryMC by ForestryMC.
the class EntityButterfly method processInteract.
/* INTERACTION */
@Override
protected boolean processInteract(EntityPlayer player, EnumHand hand) {
if (isDead) {
return false;
}
ItemStack stack = player.getHeldItem(hand);
if ((stack.getItem() instanceof IToolScoop)) {
if (!world.isRemote) {
IButterflyRoot root = contained.getGenome().getPrimary().getRoot();
ILepidopteristTracker tracker = root.getBreedingTracker(world, player.getGameProfile());
ItemStack itemStack = root.getMemberStack(contained.copy(), EnumFlutterType.BUTTERFLY);
tracker.registerCatch(contained);
ItemStackUtil.dropItemStackAsEntity(itemStack, world, posX, posY, posZ);
setDead();
} else {
player.swingArm(hand);
}
return true;
}
return false;
}
Aggregations