net.minecraft.item.ItemShears Java Examples

The following examples show how to use net.minecraft.item.ItemShears. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockPepperCrop.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (worldIn.isRemote) {
		return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
	}
	int i = this.getAge(state);
	if (i >= 6) {
		if (playerIn.getHeldItem(hand).getItem() instanceof ItemShears) {
			List<ItemStack> list = onSheared(playerIn.getHeldItem(hand), worldIn, pos, 0);
			for (ItemStack stackresult : list)
				spawnAsEntity(worldIn, pos, stackresult);
			worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, 2));
		}
	}
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
Example #2
Source File: BlockGrapeLeaves.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (worldIn.isRemote) {
		return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
	}
	int i = this.getAge(state);
	if (i >= 6) {
		if (playerIn.getHeldItem(hand).getItem() instanceof ItemShears) {
			List<ItemStack> list = onSheared(playerIn.getHeldItem(hand), worldIn, pos, 0);
			for (ItemStack stackresult : list)
				spawnAsEntity(worldIn, pos.down(), stackresult);
			worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, 2));
		}
	}
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
Example #3
Source File: ShearModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();
        if(mc.player.inventory.getCurrentItem().getItem() instanceof ItemShears) {
            for(Entity e : mc.world.loadedEntityList) {
                if(e != null && e instanceof EntitySheep) {
                    final EntitySheep sheep = (EntitySheep) e;
                    if(sheep.getHealth() > 0) {
                        if (!sheep.isChild() && !sheep.getSheared() && mc.player.getDistance(sheep) <= 4.5f) {
                            mc.playerController.interactWithEntity(mc.player, sheep, EnumHand.MAIN_HAND);
                        }
                    }
                }
            }
        }
    }
}
 
Example #4
Source File: BlockVanillaCrop.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if (this.isMaxAge(state)) {
		if (playerIn.getHeldItem(hand).getItem() instanceof ItemShears) {
			List<ItemStack> list = onSheared(playerIn.getHeldItem(hand), worldIn, pos, 0);
			for (ItemStack stackresult : list)
				spawnAsEntity(worldIn, pos, stackresult);
			worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, 3));
		}
	}
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
Example #5
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@SubscribeEvent
public void harvestEvent(BlockEvent.HarvestDropsEvent event) {
	if (EtFuturum.enableSilkTouchingMushrooms && event.isSilkTouching)
		if (event.block == Blocks.brown_mushroom_block) {
			event.drops.clear();
			event.drops.add(new ItemStack(ModBlocks.brown_mushroom_block));
		} else if (event.block == Blocks.red_mushroom_block) {
			event.drops.clear();
			event.drops.add(new ItemStack(ModBlocks.red_mushroom_block));
		}

	if (EtFuturum.enableSticksFromDeadBushes)
		if (event.block == Blocks.deadbush) {
			boolean isShears = event.harvester != null && event.harvester.getCurrentEquippedItem() != null && event.harvester.getCurrentEquippedItem().getItem() instanceof ItemShears;
			if (event.harvester == null || event.harvester.getCurrentEquippedItem() == null || !isShears)
				for (int i = 0; i < event.world.rand.nextInt(3); i++)
					event.drops.add(new ItemStack(Items.stick));
		}

	if (EtFuturum.enableShearableCobwebs)
		if (event.block == Blocks.web && event.harvester != null) {
			ItemStack stack = event.harvester.getCurrentEquippedItem();
			if (stack != null && stack.getItem() instanceof ItemShears) {
				event.drops.clear();
				event.drops.add(new ItemStack(Blocks.web));
			}
		}
}