Java Code Examples for org.bukkit.Material#GRASS

The following examples show how to use org.bukkit.Material#GRASS . 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: Ammo.java    From QualityArmory with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onRMB(Player e, ItemStack usedItem) {
	QAMain.DEBUG("The item being click is ammo!");
	Block b = e.getTargetBlock(null,6);
	if (usedItem.getType() == Material.DIAMOND_HOE
			&& (b.getType() == Material.DIRT
					||b.getType() == Material.GRASS
					|| b.getType() == Material.GRASS_PATH
					|| b.getType() == MultiVersionLookup.getMycil()))
		return true;
	return false;
}
 
Example 2
Source File: SurgarCanePopulator.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void populate(World world, Random random, Chunk chunk){
    for (int x = 1; x < 15; x++) {
        for (int z = 1; z < 15; z++) {
            Block block = world.getHighestBlockAt(chunk.getBlock(x, 0, z).getLocation());
            Block below = block.getRelative(BlockFace.DOWN);

            if (percentage > random.nextInt(100) && (below.getType() == Material.SAND || below.getType() == Material.GRASS)){

                Material water = UniversalMaterial.STATIONARY_WATER.getType();
                if (
                        below.getRelative(BlockFace.NORTH).getType() == water ||
                        below.getRelative(BlockFace.EAST).getType() == water ||
                        below.getRelative(BlockFace.SOUTH).getType() == water ||
                        below.getRelative(BlockFace.WEST).getType() == water
                ){
                    if (block.getType() == Material.AIR){
                        int height = random.nextInt(3)+1;
                        Location location = block.getLocation();
                        while (height > 0){
                            world.getBlockAt(location).setType(UniversalMaterial.SUGAR_CANE_BLOCK.getType());
                            location = location.add(0, 1, 0);
                            height--;
                        }
                    }
                }
            }
        }
    }
}
 
Example 3
Source File: UtilTests.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void addItemsShouldAddProperItems() {
    TestUtil.world.setChunkLoaded(false);
    List<ItemStack> inventoryContents = new ArrayList<>();
    inventoryContents.add(new ItemStack(Material.COBBLESTONE, 6));
    inventoryContents.add(new ItemStack(Material.WOODEN_AXE));
    inventoryContents.add(new ItemStack(Material.STONE_SWORD));
    inventoryContents.add(null);
    inventoryContents.add(null);
    inventoryContents.add(null);
    inventoryContents.add(null);
    inventoryContents.add(null);
    inventoryContents.add(null);
    List<CVItem> tempList = new ArrayList<>();
    tempList.add(CVItem.createCVItemFromString("GRASS"));
    List<List<CVItem>> returnList = new ArrayList<>();
    returnList.add(tempList);
    CVInventory cvInventory = UnloadedInventoryHandler.getInstance().getChestInventory(new Location(TestUtil.world, 0, 0, 0));
    Util.addItems(returnList, cvInventory);
    for (ItemStack itemStack : cvInventory.getContents()) {
        System.out.println(itemStack.getType().name());
        if (itemStack.getType() == Material.GRASS) {
            return;
        }
    }
    fail("No Grass found in inventory");
}
 
Example 4
Source File: PlayerInteract.java    From AdditionsAPI with MIT License 5 votes vote down vote up
public static boolean shouldPlaySound(Material material, ItemStack item, byte data, Player player) {
	if ((material == Material.GRASS || (material == Material.DIRT && data != (byte) 2))) {
		if (!AdditionsAPI.isCustomItem(item))
			return true;
		CustomItemStack cStack = new CustomItemStack(item);
		ItemPermissions perm = cStack.getCustomItem().getPermissions();
		if (cStack.getCustomItem().hasHoeAbilities() && perm instanceof HoePermissions
				&& PermissionUtils.allowedAction(player, perm.getType(), ((HoePermissions) perm).getHoe()))
			return true;
	}
	return false;
}
 
Example 5
Source File: PlantsListener.java    From ExoticGarden with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHarvest(BlockBreakEvent e) {
    if (SlimefunPlugin.getProtectionManager().hasPermission(e.getPlayer(), e.getBlock().getLocation(), ProtectableAction.BREAK_BLOCK)) {
        if (e.getBlock().getType().equals(Material.PLAYER_HEAD) || Tag.LEAVES.isTagged(e.getBlock().getType())) {
            dropFruitFromTree(e.getBlock());
        }

        if (e.getBlock().getType() == Material.GRASS) {
            if (!ExoticGarden.getItems().keySet().isEmpty() && e.getPlayer().getGameMode() != GameMode.CREATIVE) {
                Random random = ThreadLocalRandom.current();

                if (random.nextInt(100) < 6) {
                    ItemStack[] items = ExoticGarden.getItems().values().toArray(new ItemStack[0]);
                    e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), items[random.nextInt(items.length)]);
                }
            }
        }
        else {
            ItemStack item = ExoticGarden.harvestPlant(e.getBlock());

            if (item != null) {
                e.setCancelled(true);
                e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), item);
            }
        }
    }
}
 
Example 6
Source File: TreePopulator.java    From GiantTrees with GNU General Public License v3.0 5 votes vote down vote up
int getHighestSoil(Block highestBlock) {
  while ((highestBlock.getY() > 0)
         && (highestBlock.getType() != Material.DIRT)
         && // Includes podzol
         (highestBlock.getType() != Material.GRASS)
         && (highestBlock.getType() != Material.MYCELIUM)
         && (highestBlock.getType() != Material.SAND)) {
    highestBlock = highestBlock.getRelative(BlockFace.DOWN);
  }
  return highestBlock.getY();
}
 
Example 7
Source File: CreateTreeCommand.java    From GiantTrees with GNU General Public License v3.0 5 votes vote down vote up
Block getHighestSoil(Block highestBlock) {
  while ((highestBlock.getY() > 0)
         && (highestBlock.getType() != Material.DIRT)
         && // Includes podzol
         (highestBlock.getType() != Material.GRASS)
         && (highestBlock.getType() != Material.MYCELIUM)
         && (highestBlock.getType() != Material.SAND)) {
    highestBlock = highestBlock.getRelative(BlockFace.DOWN);
  }
  return highestBlock;
}
 
Example 8
Source File: SkyBlockMenu.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
private void onClickMainMenu(InventoryClickEvent event, ItemStack currentItem, Player p, int slotIndex) {
    event.setCancelled(true);
    if (slotIndex < 0 || slotIndex > 35) {
        return;
    }
    PlayerInfo playerInfo = plugin.getPlayerInfo(p);
    IslandInfo islandInfo = plugin.getIslandInfo(playerInfo);
    if (currentItem.getType() == Material.JUNGLE_SAPLING) {
        p.closeInventory();
        p.performCommand("island biome");
    } else if (currentItem.getType() == Material.PLAYER_HEAD) {
        p.closeInventory();
        p.performCommand("island party");
    } else if (currentItem.getType() == Material.RED_BED) {
        p.closeInventory();
        p.performCommand("island sethome");
        p.performCommand("island");
    } else if (currentItem.getType() == Material.GRASS) {
        p.closeInventory();
        p.performCommand("island spawn");
    } else if (currentItem.getType() == Material.HOPPER) {
        p.closeInventory();
        p.performCommand("island setwarp");
        p.performCommand("island");
    } else if (currentItem.getType() == Material.WRITABLE_BOOK) {
        p.closeInventory();
        p.performCommand("island log");
    } else if (currentItem.getType() == Material.OAK_DOOR) {
        p.closeInventory();
        p.performCommand("island home");
    } else if (currentItem.getType() == Material.EXPERIENCE_BOTTLE) {
        p.closeInventory();
        p.performCommand("island level");
    } else if (currentItem.getType() == Material.DIAMOND_ORE) {
        p.closeInventory();
        p.performCommand("c");
    } else if (currentItem.getType() == Material.END_STONE || currentItem.getType() == Material.END_PORTAL_FRAME) {
        p.closeInventory();
        p.performCommand("island togglewarp");
        p.performCommand("island");
    } else if (currentItem.getType() == Material.IRON_BARS && islandInfo.isLocked()) {
        p.closeInventory();
        p.performCommand("island unlock");
        p.performCommand("island");
    } else if (currentItem.getType() == Material.IRON_BARS && !islandInfo.isLocked()) {
        p.closeInventory();
        p.performCommand("island lock");
        p.performCommand("island");
    } else if (slotIndex == 17) {
        if (islandInfo.isLeader(p) && plugin.getConfig().getBoolean("island-schemes-enabled", true)) {
            p.closeInventory();
            p.openInventory(createRestartGUI(p));
        } else {
            if (plugin.getConfirmHandler().millisLeft(p, "/is leave") > 0) {
                p.closeInventory();
                p.performCommand("island leave");
            } else {
                p.performCommand("island leave");
                updateLeaveMenuItemTimer(p, event.getInventory(), currentItem);
            }
        }
    } else {
        if (!isExtraMenuAction(p, currentItem)) {
            p.closeInventory();
            p.performCommand("island");
        }
    }
}