use of net.minecraftforge.common.IShearable in project BetterWithAddons by DaedalusGame.
the class ItemAxeConvenient method onBlockStartBreak.
@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) {
if (player.world.isRemote || player.capabilities.isCreativeMode) {
return false;
}
IBlockState state = player.world.getBlockState(pos);
Block block = state.getBlock();
if (canShear(itemstack, state) && block instanceof IShearable) {
IShearable target = (IShearable) block;
if (target.isShearable(itemstack, player.world, pos)) {
List<ItemStack> drops = target.onSheared(itemstack, player.world, pos, getEnchantmentLevel(net.minecraft.init.Enchantments.FORTUNE, itemstack));
for (ItemStack stack : drops) {
InventoryUtil.addItemToPlayer(player, stack);
}
itemstack.damageItem(1, player);
player.addStat(getBlockStats(block));
// TODO: Move to IShearable implementors in 1.12+
player.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);
return true;
}
}
return false;
}
use of net.minecraftforge.common.IShearable in project BetterWithAddons by DaedalusGame.
the class ItemSpadeConvenient method onBlockStartBreak.
@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) {
if (player.world.isRemote || player.capabilities.isCreativeMode) {
return false;
}
IBlockState state = player.world.getBlockState(pos);
Block block = state.getBlock();
if (canShear(itemstack, state) && block instanceof IShearable) {
IShearable target = (IShearable) block;
if (target.isShearable(itemstack, player.world, pos)) {
List<ItemStack> drops = target.onSheared(itemstack, player.world, pos, getEnchantmentLevel(net.minecraft.init.Enchantments.FORTUNE, itemstack));
for (ItemStack stack : drops) {
InventoryUtil.addItemToPlayer(player, stack);
}
itemstack.damageItem(1, player);
player.addStat(getBlockStats(block));
// TODO: Move to IShearable implementors in 1.12+
player.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);
return true;
}
}
return false;
}
use of net.minecraftforge.common.IShearable in project BetterWithAddons by DaedalusGame.
the class ItemSwordConvenient method onBlockStartBreak.
@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) {
if (player.world.isRemote || player.capabilities.isCreativeMode) {
return false;
}
IBlockState state = player.world.getBlockState(pos);
Block block = state.getBlock();
if (canShear(itemstack, state) && block instanceof IShearable) {
IShearable target = (IShearable) block;
if (target.isShearable(itemstack, player.world, pos)) {
List<ItemStack> drops = target.onSheared(itemstack, player.world, pos, getEnchantmentLevel(net.minecraft.init.Enchantments.FORTUNE, itemstack));
for (ItemStack stack : drops) {
InventoryUtil.addItemToPlayer(player, stack);
}
itemstack.damageItem(1, player);
player.addStat(getBlockStats(block));
// TODO: Move to IShearable implementors in 1.12+
player.world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);
return true;
}
}
return false;
}
use of net.minecraftforge.common.IShearable in project pnc-repressurized by TeamPneumatic.
the class EntityVortex method onImpact.
@Override
protected void onImpact(RayTraceResult objectPosition) {
if (objectPosition.entityHit != null) {
Entity entity = objectPosition.entityHit;
entity.motionX += motionX;
entity.motionY += motionY;
entity.motionZ += motionZ;
if (!entity.world.isRemote && entity instanceof IShearable) {
IShearable shearable = (IShearable) entity;
BlockPos pos = new BlockPos(posX, posY, posZ);
if (shearable.isShearable(ItemStack.EMPTY, world, pos)) {
List<ItemStack> drops = shearable.onSheared(ItemStack.EMPTY, world, pos, 0);
for (ItemStack stack : drops) {
PneumaticCraftUtils.dropItemOnGround(stack, world, entity.posX, entity.posY, entity.posZ);
}
}
}
} else {
Block block = world.getBlockState(objectPosition.getBlockPos()).getBlock();
if (block instanceof IPlantable || block instanceof BlockLeaves) {
motionX = oldMotionX;
motionY = oldMotionY;
motionZ = oldMotionZ;
} else {
setDead();
}
}
hitCounter++;
if (hitCounter > 20)
setDead();
}
use of net.minecraftforge.common.IShearable in project BiomesOPlenty by Glitchfiend.
the class ItemFlowerBasket method isStackSuitableForBasket.
public static boolean isStackSuitableForBasket(@Nonnull ItemStack stack) {
Item item = stack.getItem();
Block block = Block.getBlockFromItem(item);
return !(item instanceof ItemFlowerBasket) && (block instanceof IPlantable || block instanceof IGrowable || block instanceof IShearable || block instanceof BlockBOPMushroom || item instanceof ItemSeedFood || item instanceof ItemSeeds || item == Items.REEDS || item == Items.APPLE || item == Items.MELON || item == Items.BEETROOT || item == Items.WHEAT || item == Items.CHORUS_FRUIT || item == BOPItems.berries || item == BOPItems.pear || item == BOPItems.peach || item == BOPItems.persimmon || item == BOPItems.pinecone || item == BOPItems.turnip);
}
Aggregations