org.bukkit.Tag Java Examples
The following examples show how to use
org.bukkit.Tag.
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: MultiBlock.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
private boolean compareBlocks(Material a, Material b) { if (b != null) { for (Tag<Material> tag : SUPPORTED_TAGS) { if (tag.isTagged(b)) { return tag.isTagged(a); } } // This ensures that the Industrial Miner is still recognized while operating if (a == Material.PISTON) { return a == b || b == Material.MOVING_PISTON; } // This ensures that the Industrial Miner is still recognized while operating if (b == Material.PISTON) { return a == b || a == Material.MOVING_PISTON; } if (b != a) { return false; } } return true; }
Example #2
Source File: Crucible.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@Override public BlockUseHandler getItemHandler() { return e -> { Optional<Block> optional = e.getClickedBlock(); if (optional.isPresent()) { e.cancel(); Player p = e.getPlayer(); Block b = optional.get(); if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.ACCESS_INVENTORIES)) { ItemStack input = e.getItem(); Block block = b.getRelative(BlockFace.UP); if (craft(p, input)) { boolean water = Tag.LEAVES.isTagged(input.getType()); generateLiquid(block, water); } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true); } } } }; }
Example #3
Source File: AutoDrier.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
private ItemStack getOutput(ItemStack item) { for (int i = 0; i < recipeList.size(); i += 2) { if (SlimefunUtils.isItemSimilar(item, recipeList.get(i), true)) { return recipeList.get(i + 1); } } if (Tag.SAPLINGS.isTagged(item.getType())) { return new ItemStack(Material.STICK, 2); } else if (Tag.LEAVES.isTagged(item.getType())) { return new ItemStack(Material.STICK, 1); } else if (item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION) { return new ItemStack(Material.GLASS_BOTTLE); } return null; }
Example #4
Source File: TreeGrowthAccelerator.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
protected void tick(Block b) { BlockMenu inv = BlockStorage.getInventory(b); if (ChargableBlock.getCharge(b) >= ENERGY_CONSUMPTION) { for (int x = -RADIUS; x <= RADIUS; x++) { for (int z = -RADIUS; z <= RADIUS; z++) { Block block = b.getRelative(x, 0, z); if (Tag.SAPLINGS.isTagged(block.getType())) { Sapling sapling = (Sapling) block.getBlockData(); if (sapling.getStage() < sapling.getMaximumStage() && grow(b, block, inv, sapling)) { return; } } } } } }
Example #5
Source File: BlockPhysicsListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onLiquidFlow(BlockFromToEvent e) { Block block = e.getToBlock(); if (block.getType() == Material.PLAYER_HEAD || block.getType() == Material.PLAYER_WALL_HEAD || Tag.SAPLINGS.isTagged(block.getType())) { String item = BlockStorage.checkID(block); if (item != null) { e.setCancelled(true); } } }
Example #6
Source File: TableSaw.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
public TableSaw(Category category, SlimefunItemStack item) { super(category, item, new ItemStack[] { null, null, null, new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.STONECUTTER), new ItemStack(Material.SMOOTH_STONE_SLAB), null, new ItemStack(Material.IRON_BLOCK), null }, new ItemStack[0], BlockFace.SELF); for (Material log : Tag.LOGS.getValues()) { Optional<Material> planks = MaterialConverter.getPlanksFromLog(log); if (planks.isPresent()) { displayedRecipes.add(new ItemStack(log)); displayedRecipes.add(new ItemStack(planks.get(), 8)); } } }
Example #7
Source File: IndustrialMiner.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
/** * This registers the various types of fuel that can be used in the * {@link IndustrialMiner}. */ protected void registerDefaultFuelTypes() { // Coal & Charcoal fuelTypes.add(new MachineFuel(4, new ItemStack(Material.COAL))); fuelTypes.add(new MachineFuel(4, new ItemStack(Material.CHARCOAL))); fuelTypes.add(new MachineFuel(40, new ItemStack(Material.COAL_BLOCK))); fuelTypes.add(new MachineFuel(10, new ItemStack(Material.DRIED_KELP_BLOCK))); fuelTypes.add(new MachineFuel(4, new ItemStack(Material.BLAZE_ROD))); // Logs for (Material mat : Tag.LOGS.getValues()) { fuelTypes.add(new MachineFuel(1, new ItemStack(mat))); } }
Example #8
Source File: ElectrifiedCrucible.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Override protected void registerDefaultRecipes() { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.COBBLESTONE, 16) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.TERRACOTTA, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.OBSIDIAN) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); for (Material terracotta : MaterialCollections.getAllTerracottaColors().getAsArray()) { registerRecipe(8, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(terracotta, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) }); } for (Material leaves : Tag.LEAVES.getValues()) { registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(leaves, 16) }, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) }); } }
Example #9
Source File: BlockListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
public BlockListener(SlimefunPlugin plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); sensitiveMaterials.add(Material.CAKE); sensitiveMaterials.add(Material.STONE_PRESSURE_PLATE); sensitiveMaterials.add(Material.LIGHT_WEIGHTED_PRESSURE_PLATE); sensitiveMaterials.add(Material.HEAVY_WEIGHTED_PRESSURE_PLATE); sensitiveMaterials.addAll(Tag.SAPLINGS.getValues()); sensitiveMaterials.addAll(Tag.WOODEN_PRESSURE_PLATES.getValues()); }
Example #10
Source File: PipeManager.java From Transport-Pipes with MIT License | 5 votes |
@Override public void registerRecipes() { BaseDuctType<Pipe> pipeBaseDuctType = ductRegister.baseDuctTypeOf("pipe"); DuctType ductType; ductType = pipeBaseDuctType.ductTypeOf("White"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "white_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "a a", " a "}, 'a', Material.GLASS)); ductType = pipeBaseDuctType.ductTypeOf("Blue"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "blue_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.LAPIS_LAZULI)); ductType = pipeBaseDuctType.ductTypeOf("Red"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "red_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', LegacyUtils.getInstance().getRedDye())); ductType = pipeBaseDuctType.ductTypeOf("Yellow"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "yellow_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', LegacyUtils.getInstance().getYellowDye())); ductType = pipeBaseDuctType.ductTypeOf("Green"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "green_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', LegacyUtils.getInstance().getGreenDye())); ductType = pipeBaseDuctType.ductTypeOf("Black"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "black_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.INK_SAC)); ductType = pipeBaseDuctType.ductTypeOf("Golden"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "golden_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.GOLD_BLOCK)); ductType = pipeBaseDuctType.ductTypeOf("Iron"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "iron_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.IRON_BLOCK)); ductType = pipeBaseDuctType.ductTypeOf("Ice"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "ice_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.SNOW_BLOCK)); ductType = pipeBaseDuctType.ductTypeOf("Void"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "void_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.OBSIDIAN)); ductType = pipeBaseDuctType.ductTypeOf("Extraction"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "extraction_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Tag.PLANKS.getValues())); ductType = pipeBaseDuctType.ductTypeOf("Crafting"); ductType.setDuctRecipe(itemService.createShapedRecipe(transportPipes, "crafting_pipe", pipeBaseDuctType.getItemManager().getClonedItem(ductType), new String[]{" a ", "aba", " a "}, 'a', Material.GLASS, 'b', Material.CRAFTING_TABLE)); wrenchRecipe = itemService.createShapedRecipe(transportPipes, "wrench", itemService.getWrench(), new String[]{" a ", "aba", " a "}, 'a', Material.REDSTONE, 'b', Material.STICK); Bukkit.addRecipe(wrenchRecipe); }
Example #11
Source File: MultiBlockListener.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private boolean equals(Material a, Material b) { if (a == b) return true; for (Tag<Material> tag : MultiBlock.getSupportedTags()) { if (tag.isTagged(a) && tag.isTagged(b)) { return true; } } return false; }
Example #12
Source File: ChestSlimefunGuide.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private void displayItem(ChestMenu menu, PlayerProfile profile, Player p, Object item, ItemStack output, RecipeType recipeType, ItemStack[] recipe, RecipeChoiceTask task) { addBackButton(menu, 0, p, profile); MenuClickHandler clickHandler = (pl, slot, itemstack, action) -> { try { if (itemstack != null && itemstack.getType() != Material.BARRIER) { displayItem(profile, itemstack, 0, true); } } catch (Exception | LinkageError x) { printErrorMessage(pl, x); } return false; }; boolean isSlimefunRecipe = item instanceof SlimefunItem; for (int i = 0; i < 9; i++) { ItemStack recipeItem = getDisplayItem(p, isSlimefunRecipe, recipe[i]); menu.addItem(recipeSlots[i], recipeItem, clickHandler); if (recipeItem != null && item instanceof MultiBlockMachine) { for (Tag<Material> tag : MultiBlock.getSupportedTags()) { if (tag.isTagged(recipeItem.getType())) { task.add(recipeSlots[i], tag); break; } } } } menu.addItem(10, recipeType.getItem(p), ChestMenuUtils.getEmptyClickHandler()); menu.addItem(16, output, ChestMenuUtils.getEmptyClickHandler()); }
Example #13
Source File: ExoticGarden.java From ExoticGarden with GNU General Public License v3.0 | 5 votes |
public static ItemStack harvestPlant(Block block) { SlimefunItem item = BlockStorage.check(block); if (item == null) return null; for (Berry berry : getBerries()) { if (item.getID().equalsIgnoreCase(berry.getID())) { switch (berry.getType()) { case ORE_PLANT: case DOUBLE_PLANT: Block plant = block; if (Tag.LEAVES.isTagged(block.getType())) block = block.getRelative(BlockFace.UP); else plant = block.getRelative(BlockFace.DOWN); BlockStorage._integrated_removeBlockInfo(block.getLocation(), false); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.OAK_LEAVES); block.setType(Material.AIR); plant.setType(Material.OAK_SAPLING); BlockStorage._integrated_removeBlockInfo(plant.getLocation(), false); BlockStorage.store(plant, getItem(berry.toBush())); return berry.getItem(); default: block.setType(Material.OAK_SAPLING); BlockStorage._integrated_removeBlockInfo(block.getLocation(), false); BlockStorage.store(block, getItem(berry.toBush())); return berry.getItem(); } } } return null; }
Example #14
Source File: Crook.java From ExoticGarden with GNU General Public License v3.0 | 5 votes |
@Override public BlockBreakHandler getItemHandler() { return new BlockBreakHandler() { @Override public boolean isPrivate() { return false; } @Override public boolean onBlockBreak(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) { if (isItem(item)) { damageItem(e.getPlayer(), item); if (Tag.LEAVES.isTagged(e.getBlock().getType()) && ThreadLocalRandom.current().nextInt(100) < CHANCE) { ItemStack sapling = new ItemStack(Material.getMaterial(e.getBlock().getType().toString().replace("LEAVES", "SAPLING"))); drops.add(sapling); } return true; } return false; } }; }
Example #15
Source File: PlantsListener.java From ExoticGarden with GNU General Public License v3.0 | 5 votes |
@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 #16
Source File: PlantsListener.java From ExoticGarden with GNU General Public License v3.0 | 5 votes |
private boolean isFlat(Block current) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { for (int k = 0; k < 6; k++) { if (current.getRelative(i, k, j).getType().isSolid() || Tag.LEAVES.isTagged(current.getRelative(i, k, j).getType()) || !current.getRelative(i, -1, j).getType().isSolid()) { return false; } } } } return true; }
Example #17
Source File: JumpPadFeature.java From VoxelGamesLibv2 with MIT License | 5 votes |
@GameEvent public void onStep(@Nonnull PlayerInteractEvent event) { if (event.getAction() == Action.PHYSICAL) { if (!Tag.WOODEN_PRESSURE_PLATES.isTagged(event.getClickedBlock().getType()) && event.getClickedBlock().getType() != Material.STONE_PRESSURE_PLATE) { return; } if (event.isCancelled()) { return; } double strength = 1.5; double up = 1; if (event.getClickedBlock().getRelative(BlockFace.DOWN, 2).getState() instanceof Sign) { Sign sign = (Sign) event.getClickedBlock().getRelative(BlockFace.DOWN, 2).getState(); if (sign.getLine(0).contains("[Boom]")) { try { strength = Double.parseDouble(sign.getLine(1)); up = Double.parseDouble(sign.getLine(2)); } catch (final Exception ex) { log.warning("Invalid boom sign at " + sign.getLocation()); } } } event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ENDER_DRAGON_SHOOT, 10.0F, 1.0F); event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.SMOKE, 10); Vector v = event.getPlayer().getLocation().getDirection().multiply(strength / 2).setY(up / 2); event.getPlayer().setVelocity(v); event.setCancelled(true); } }
Example #18
Source File: RecipeChoiceTask.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
public void add(int slot, Tag<Material> tag) { Validate.notNull(tag, "Cannot add a null Tag"); iterators.put(slot, new LoopIterator<>(tag.getValues())); }
Example #19
Source File: SignEditListener.java From NyaaUtils with MIT License | 4 votes |
public static boolean isSign(Material m) { return Tag.SIGNS.isTagged(m); }
Example #20
Source File: PlantsListener.java From ExoticGarden with GNU General Public License v3.0 | 4 votes |
private void growStructure(StructureGrowEvent e) { SlimefunItem item = BlockStorage.check(e.getLocation().getBlock()); if (item != null) { e.setCancelled(true); for (Tree tree : ExoticGarden.getTrees()) { if (item.getID().equalsIgnoreCase(tree.getSapling())) { BlockStorage.clearBlockInfo(e.getLocation()); Schematic.pasteSchematic(e.getLocation(), tree); return; } } for (Berry berry : ExoticGarden.getBerries()) { if (item.getID().equalsIgnoreCase(berry.toBush())) { switch (berry.getType()) { case BUSH: e.getLocation().getBlock().setType(Material.OAK_LEAVES); break; case ORE_PLANT: case DOUBLE_PLANT: Block blockAbove = e.getLocation().getBlock().getRelative(BlockFace.UP); item = BlockStorage.check(blockAbove); if (item != null) return; if (!Tag.SAPLINGS.isTagged(blockAbove.getType()) && !Tag.LEAVES.isTagged(blockAbove.getType())) { switch (blockAbove.getType()) { case AIR: case CAVE_AIR: case SNOW: break; default: return; } } BlockStorage.store(blockAbove, berry.getItem()); e.getLocation().getBlock().setType(Material.OAK_LEAVES); blockAbove.setType(Material.PLAYER_HEAD); Rotatable rotatable = (Rotatable) blockAbove.getBlockData(); rotatable.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]); blockAbove.setBlockData(rotatable); SkullBlock.setFromHash(blockAbove, berry.getTexture()); break; default: e.getLocation().getBlock().setType(Material.PLAYER_HEAD); Rotatable s = (Rotatable) e.getLocation().getBlock().getBlockData(); s.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]); e.getLocation().getBlock().setBlockData(s); SkullBlock.setFromHash(e.getLocation().getBlock(), berry.getTexture()); break; } BlockStorage._integrated_removeBlockInfo(e.getLocation(), false); BlockStorage.store(e.getLocation().getBlock(), berry.getItem()); e.getWorld().playEffect(e.getLocation(), Effect.STEP_SOUND, Material.OAK_LEAVES); break; } } } }
Example #21
Source File: LumberAxe.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
private boolean isUnstrippedLog(Block block) { return Tag.LOGS.isTagged(block.getType()) && !block.getType().name().startsWith("STRIPPED_"); }
Example #22
Source File: MultiBlock.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
public static Set<Tag<Material>> getSupportedTags() { return SUPPORTED_TAGS; }
Example #23
Source File: CargoUtils.java From Slimefun4 with GNU General Public License v3.0 | 3 votes |
/** * This method checks if a given {@link ItemStack} is smeltable or not. * The lazy-option is a performance-saver since actually calculating this can be quite expensive. * For the current applicational purposes a quick check for any wooden logs is sufficient. * Otherwise the "lazyness" can be turned off in the future. * * @param stack * The {@link ItemStack} to test * @param lazy * Whether or not to perform a "lazy" but performance-saving check * * @return Whether the given {@link ItemStack} can be smelted or not */ private static boolean isSmeltable(ItemStack stack, boolean lazy) { if (lazy) { return stack != null && Tag.LOGS.isTagged(stack.getType()); } else { return SlimefunPlugin.getMinecraftRecipeService().isSmeltable(stack); } }