org.bukkit.Material#GRASS源码实例Demo

下面列出了org.bukkit.Material#GRASS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: QualityArmory   文件: Ammo.java
@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;
}
 
源代码2 项目: UhcCore   文件: SurgarCanePopulator.java
@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--;
                        }
                    }
                }
            }
        }
    }
}
 
源代码3 项目: Civs   文件: UtilTests.java
@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");
}
 
源代码4 项目: AdditionsAPI   文件: PlayerInteract.java
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;
}
 
源代码5 项目: ExoticGarden   文件: PlantsListener.java
@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);
            }
        }
    }
}
 
源代码6 项目: GiantTrees   文件: TreePopulator.java
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();
}
 
源代码7 项目: GiantTrees   文件: CreateTreeCommand.java
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;
}
 
源代码8 项目: uSkyBlock   文件: SkyBlockMenu.java
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");
        }
    }
}
 
 方法所在类
 同类方法