Java Code Examples for net.minecraft.init.Items.shears()

The following are Jave code examples for showing how to use shears() of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: BaseClient   File: EntitySheep.java   View Source Code Vote up 5 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.shears && !this.getSheared() && !this.isChild())
    {
        if (!this.worldObj.isRemote)
        {
            this.setSheared(true);
            int i = 1 + this.rand.nextInt(3);

            for (int j = 0; j < i; ++j)
            {
                EntityItem entityitem = this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor().getMetadata()), 1.0F);
                entityitem.motionY += (double)(this.rand.nextFloat() * 0.05F);
                entityitem.motionX += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
                entityitem.motionZ += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            }
        }

        itemstack.damageItem(1, player);
        this.playSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.interact(player);
}
 
Example 2
Project: DecompiledMinecraft   File: BlockTripWire.java   View Source Code Vote up 5 votes
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    if (!worldIn.isRemote)
    {
        if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
        {
            worldIn.setBlockState(pos, state.withProperty(DISARMED, Boolean.valueOf(true)), 4);
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: BlockDoublePlant.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (worldIn.isRemote || player.getCurrentEquippedItem() == null || player.getCurrentEquippedItem().getItem() != Items.shears || state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.onHarvest(worldIn, pos, state, player))
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 4
Project: DecompiledMinecraft   File: BlockTallGrass.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 1, ((BlockTallGrass.EnumType)state.getValue(TYPE)).getMeta()));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 5
Project: DecompiledMinecraft   File: BlockVine.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.vine, 1, 0));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 6
Project: BaseClient   File: BlockOldLeaf.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata()));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 7
Project: BaseClient   File: BlockDeadBush.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush, 1, 0));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 8
Project: DecompiledMinecraft   File: BlockDeadBush.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush, 1, 0));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 9
Project: BaseClient   File: BlockNewLeaf.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 10
Project: BaseClient   File: BlockDoublePlant.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (worldIn.isRemote || player.getCurrentEquippedItem() == null || player.getCurrentEquippedItem().getItem() != Items.shears || state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.onHarvest(worldIn, pos, state, player))
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 11
Project: BaseClient   File: BlockTallGrass.java   View Source Code Vote up 5 votes
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 1, ((BlockTallGrass.EnumType)state.getValue(TYPE)).getMeta()));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 12
Project: BaseClient   File: EntitySheep.java   View Source Code Vote up 5 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.shears && !this.getSheared() && !this.isChild())
    {
        if (!this.worldObj.isRemote)
        {
            this.setSheared(true);
            int i = 1 + this.rand.nextInt(3);

            for (int j = 0; j < i; ++j)
            {
                EntityItem entityitem = this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor().getMetadata()), 1.0F);
                entityitem.motionY += (double)(this.rand.nextFloat() * 0.05F);
                entityitem.motionX += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
                entityitem.motionZ += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            }
        }

        itemstack.damageItem(1, player);
        this.playSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.interact(player);
}
 
Example 13
Project: DecompiledMinecraft   File: EntityMooshroom.java   View Source Code Vote up 4 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.bowl && this.getGrowingAge() >= 0)
    {
        if (itemstack.stackSize == 1)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.mushroom_stew));
            return true;
        }

        if (player.inventory.addItemStackToInventory(new ItemStack(Items.mushroom_stew)) && !player.capabilities.isCreativeMode)
        {
            player.inventory.decrStackSize(player.inventory.currentItem, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.getItem() == Items.shears && this.getGrowingAge() >= 0)
    {
        this.setDead();
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY + (double)(this.height / 2.0F), this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);

        if (!this.worldObj.isRemote)
        {
            EntityCow entitycow = new EntityCow(this.worldObj);
            entitycow.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
            entitycow.setHealth(this.getHealth());
            entitycow.renderYawOffset = this.renderYawOffset;

            if (this.hasCustomName())
            {
                entitycow.setCustomNameTag(this.getCustomNameTag());
            }

            this.worldObj.spawnEntityInWorld(entitycow);

            for (int i = 0; i < 5; ++i)
            {
                this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY + (double)this.height, this.posZ, new ItemStack(Blocks.red_mushroom)));
            }

            itemstack.damageItem(1, player);
            this.playSound("mob.sheep.shear", 1.0F, 1.0F);
        }

        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
Example 14
Project: BaseClient   File: EnchantmentDigging.java   View Source Code Vote up 4 votes
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() == Items.shears ? true : super.canApply(stack);
}
 
Example 15
Project: BaseClient   File: BlockDoublePlant.java   View Source Code Vote up 4 votes
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
    {
        if (worldIn.getBlockState(pos.down()).getBlock() == this)
        {
            if (!player.capabilities.isCreativeMode)
            {
                IBlockState iblockstate = worldIn.getBlockState(pos.down());
                BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);

                if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
                {
                    worldIn.destroyBlock(pos.down(), true);
                }
                else if (!worldIn.isRemote)
                {
                    if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
                    {
                        this.onHarvest(worldIn, pos, iblockstate, player);
                        worldIn.setBlockToAir(pos.down());
                    }
                    else
                    {
                        worldIn.destroyBlock(pos.down(), true);
                    }
                }
                else
                {
                    worldIn.setBlockToAir(pos.down());
                }
            }
            else
            {
                worldIn.setBlockToAir(pos.down());
            }
        }
    }
    else if (player.capabilities.isCreativeMode && worldIn.getBlockState(pos.up()).getBlock() == this)
    {
        worldIn.setBlockState(pos.up(), Blocks.air.getDefaultState(), 2);
    }

    super.onBlockHarvested(worldIn, pos, state, player);
}
 
Example 16
Project: DecompiledMinecraft   File: EntityMooshroom.java   View Source Code Vote up 4 votes
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.bowl && this.getGrowingAge() >= 0)
    {
        if (itemstack.stackSize == 1)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.mushroom_stew));
            return true;
        }

        if (player.inventory.addItemStackToInventory(new ItemStack(Items.mushroom_stew)) && !player.capabilities.isCreativeMode)
        {
            player.inventory.decrStackSize(player.inventory.currentItem, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.getItem() == Items.shears && this.getGrowingAge() >= 0)
    {
        this.setDead();
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY + (double)(this.height / 2.0F), this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);

        if (!this.worldObj.isRemote)
        {
            EntityCow entitycow = new EntityCow(this.worldObj);
            entitycow.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
            entitycow.setHealth(this.getHealth());
            entitycow.renderYawOffset = this.renderYawOffset;

            if (this.hasCustomName())
            {
                entitycow.setCustomNameTag(this.getCustomNameTag());
            }

            this.worldObj.spawnEntityInWorld(entitycow);

            for (int i = 0; i < 5; ++i)
            {
                this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY + (double)this.height, this.posZ, new ItemStack(Blocks.red_mushroom)));
            }

            itemstack.damageItem(1, player);
            this.playSound("mob.sheep.shear", 1.0F, 1.0F);
        }

        return true;
    }
    else
    {
        return super.interact(player);
    }
}
 
Example 17
Project: BaseClient   File: EnchantmentUntouching.java   View Source Code Vote up 4 votes
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() == Items.shears ? true : super.canApply(stack);
}
 
Example 18
Project: DecompiledMinecraft   File: BlockDoublePlant.java   View Source Code Vote up 4 votes
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
    {
        if (worldIn.getBlockState(pos.down()).getBlock() == this)
        {
            if (!player.capabilities.isCreativeMode)
            {
                IBlockState iblockstate = worldIn.getBlockState(pos.down());
                BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);

                if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
                {
                    worldIn.destroyBlock(pos.down(), true);
                }
                else if (!worldIn.isRemote)
                {
                    if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
                    {
                        this.onHarvest(worldIn, pos, iblockstate, player);
                        worldIn.setBlockToAir(pos.down());
                    }
                    else
                    {
                        worldIn.destroyBlock(pos.down(), true);
                    }
                }
                else
                {
                    worldIn.setBlockToAir(pos.down());
                }
            }
            else
            {
                worldIn.setBlockToAir(pos.down());
            }
        }
    }
    else if (player.capabilities.isCreativeMode && worldIn.getBlockState(pos.up()).getBlock() == this)
    {
        worldIn.setBlockState(pos.up(), Blocks.air.getDefaultState(), 2);
    }

    super.onBlockHarvested(worldIn, pos, state, player);
}
 
Example 19
Project: BaseClient   File: EnchantmentDigging.java   View Source Code Vote up 4 votes
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() == Items.shears ? true : super.canApply(stack);
}
 
Example 20
Project: BaseClient   File: EnchantmentUntouching.java   View Source Code Vote up 4 votes
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() == Items.shears ? true : super.canApply(stack);
}