Java Code Examples for org.bukkit.Material#NETHER_WART

The following examples show how to use org.bukkit.Material#NETHER_WART . 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: FarmerAndroid.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private ItemStack getDropFromCrop(Material crop) {
    Random random = ThreadLocalRandom.current();

    if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) && crop == Material.SWEET_BERRY_BUSH) {
        return new ItemStack(Material.SWEET_BERRIES, random.nextInt(3) + 1);
    }

    switch (crop) {
    case WHEAT:
        return new ItemStack(Material.WHEAT, random.nextInt(2) + 1);
    case POTATOES:
        return new ItemStack(Material.POTATO, random.nextInt(3) + 1);
    case CARROTS:
        return new ItemStack(Material.CARROT, random.nextInt(3) + 1);
    case BEETROOTS:
        return new ItemStack(Material.BEETROOT, random.nextInt(3) + 1);
    case COCOA:
        return new ItemStack(Material.COCOA_BEANS, random.nextInt(3) + 1);
    case NETHER_WART:
        return new ItemStack(Material.NETHER_WART, random.nextInt(3) + 1);
    default:
        return null;
    }
}
 
Example 2
Source File: InfernalBonemeal.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemUseHandler getItemHandler() {
    return e -> {
        Optional<Block> block = e.getClickedBlock();
        e.setUseBlock(Result.DENY);

        if (block.isPresent()) {
            Block b = block.get();

            if (b.getType() == Material.NETHER_WART) {
                Ageable ageable = (Ageable) b.getBlockData();

                if (ageable.getAge() < ageable.getMaximumAge()) {
                    ageable.setAge(ageable.getMaximumAge());
                    b.setBlockData(ageable);
                    b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);

                    if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
                        ItemUtils.consumeItem(e.getItem(), false);
                    }
                }
            }
        }
    };
}
 
Example 3
Source File: XBlock.java    From IridiumSkyblock with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isNetherWart(Material material) {
    return XMaterial.ISFLAT ? material == Material.NETHER_WART : material.name().equals("NETHER_WARTS");
}
 
Example 4
Source File: XBlock.java    From XSeries with MIT License 4 votes vote down vote up
public static boolean isNetherWart(Material material) {
    return ISFLAT ? material == Material.NETHER_WART : material.name().equals("NETHER_WARTS");
}
 
Example 5
Source File: BlockListener.java    From MineTinker with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
	Player player = event.getPlayer();
	ItemStack tool = player.getInventory().getItemInMainHand();

	if (Lists.WORLDS.contains(player.getWorld().getName())) {
		return;
	}

	if (event.getBlock().getType().getHardness() == 0 && !(tool.getType() == Material.SHEARS
			|| ToolType.HOE.contains(tool.getType()))) {
		return;
	}

	if (!modManager.isToolViable(tool)) {
		return;
	}

	FileConfiguration config = MineTinker.getPlugin().getConfig();

	//--------------------------------------EXP-CALCULATIONS--------------------------------------------
	if (player.getGameMode() != GameMode.CREATIVE) {
		long cooldown = MineTinker.getPlugin().getConfig().getLong("BlockExpCooldownInSeconds", 60) * 1000;
		boolean eligible = true;
		if (cooldown > 0) {
			List<MetadataValue> blockPlaced = event.getBlock().getMetadata("blockPlaced");
			for(MetadataValue val : blockPlaced) {
				if (val == null) continue;
				if (!MineTinker.getPlugin().equals(val.getOwningPlugin())) continue; //Not MTs value

				Object value = val.value();
				if (value instanceof Long) {
					long time = (long) value;
					eligible = System.currentTimeMillis() - cooldown > time;
					break;
				}
			}
		}

		if (eligible) {
			int expAmount = config.getInt("ExpPerBlockBreak");
			if (!(!config.getBoolean("ExtraExpPerBlock.ApplicableToSilkTouch")
					&& modManager.hasMod(tool, SilkTouch.instance()))) {
				expAmount += config.getInt("ExtraExpPerBlock." + event.getBlock().getType().toString());
				//adds 0 if not in found in config (negative values are also fine)
			}

			modManager.addExp(player, tool, expAmount);
		}
	}

	//-------------------------------------------POWERCHECK---------------------------------------------
	if (Power.HAS_POWER.get(player).get() && !ToolType.PICKAXE.contains(tool.getType())
			&& event.getBlock().getDrops(tool).isEmpty()
			&& event.getBlock().getType() != Material.NETHER_WART) { //Necessary for EasyHarvest NetherWard-Break

		event.setCancelled(true);
		return;
	}

	MTBlockBreakEvent breakEvent = new MTBlockBreakEvent(tool, event);
	Bukkit.getPluginManager().callEvent(breakEvent); //Event-Trigger for Modifiers
}
 
Example 6
Source File: AutoBrewer.java    From Slimefun4 with GNU General Public License v3.0 4 votes vote down vote up
private ItemStack brew(Material input, Material potionType, PotionMeta potion) {
    PotionData data = potion.getBasePotionData();

    if (data.getType() == PotionType.WATER) {
        if (input == Material.FERMENTED_SPIDER_EYE) {
            potion.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false));
            return new ItemStack(potionType);
        }
        else if (input == Material.NETHER_WART) {
            potion.setBasePotionData(new PotionData(PotionType.AWKWARD, false, false));
            return new ItemStack(potionType);
        }
        else if (potionType == Material.POTION && input == Material.GUNPOWDER) {
            return new ItemStack(Material.SPLASH_POTION);
        }
        else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) {
            return new ItemStack(Material.LINGERING_POTION);
        }
        else {
            return null;
        }

    }
    else if (input == Material.FERMENTED_SPIDER_EYE) {
        potion.setBasePotionData(new PotionData(fermentations.get(data.getType()), false, false));
        return new ItemStack(potionType);
    }
    else if (input == Material.REDSTONE) {
        potion.setBasePotionData(new PotionData(data.getType(), true, data.isUpgraded()));
        return new ItemStack(potionType);
    }
    else if (input == Material.GLOWSTONE_DUST) {
        potion.setBasePotionData(new PotionData(data.getType(), data.isExtended(), true));
        return new ItemStack(potionType);
    }
    else if (data.getType() == PotionType.AWKWARD && potionRecipes.containsKey(input)) {
        potion.setBasePotionData(new PotionData(potionRecipes.get(input), false, false));
        return new ItemStack(potionType);
    }
    else {
        return null;
    }
}