net.minecraft.item.ItemSpade Java Examples

The following examples show how to use net.minecraft.item.ItemSpade. 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: GrassPath.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
public static void onPlayerInteract(PlayerInteractEvent event) {
	if (EtFuturum.enableGrassPath)
		if (event.entityPlayer != null) {
			World world = event.entityPlayer.worldObj;
			if (event.action == Action.RIGHT_CLICK_BLOCK)
				if (world.getBlock(event.x, event.y, event.z) == Blocks.grass) {
					ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
					if (stack != null && (stack.getItem() instanceof ItemSpade || isTinkersShovel(stack))) {
						world.setBlock(event.x, event.y, event.z, ModBlocks.grass_path);
						event.entityPlayer.swingItem();
						stack.damageItem(1, event.entityPlayer);
						world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F);
					}
				}
		}
}
 
Example #2
Source File: PlayerInteractEventHandler.java    From AgriCraft with MIT License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void waterPadCreation(PlayerInteractEvent.RightClickBlock event) {
    // Fetch held item.
    final ItemStack stack = event.getItemStack();

    // Check if holding shovel.
    if (!StackHelper.isValid(stack, ItemSpade.class)) {
        return;
    }

    // Fetch world information.
    final BlockPos pos = event.getPos();
    final World world = event.getWorld();
    final IBlockState state = world.getBlockState(pos);

    // Fetch the block at the location.
    final Block block = state.getBlock();

    // Test that clicked block was farmland.
    if (block != Blocks.FARMLAND) {
        return;
    }

    // Deny the event.
    event.setUseBlock(Event.Result.DENY);
    event.setUseItem(Event.Result.DENY);
    event.setResult(Event.Result.DENY);

    // If we are on the client side we are done.
    if (event.getSide().isClient()) {
        return;
    }

    // Fetch the player.
    final EntityPlayer player = event.getEntityPlayer();

    // Create the new block on the server side.
    world.setBlockState(pos, AgriBlocks.getInstance().WATER_PAD.getDefaultState(), 3);

    // Damage player's tool if not in creative.
    if (!player.capabilities.isCreativeMode) {
        stack.damageItem(1, player);
    }
}
 
Example #3
Source File: EnchantmentConsuming.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public boolean canApply(ItemStack item) {
    if (item.getItem() instanceof ItemPickaxe || item.getItem() instanceof ItemSpade || item.getItem() instanceof ItemPrimalCrusher)
        return true;
    else
        return false;
}