@Override public boolean includes(Material item) { return item.equals(Material.BOW); } },
@Override public boolean includes(Material item) { return item.equals(Material.FISHING_ROD); } };
@Override public boolean includes(Material item) { return item.equals(Material.WOOD_SPADE) || item.equals(Material.STONE_SPADE) || item.equals(Material.IRON_SPADE) || item.equals(Material.DIAMOND_SPADE) || item.equals(Material.GOLD_SPADE) || item.equals(Material.WOOD_PICKAXE) || item.equals(Material.STONE_PICKAXE) || item.equals(Material.IRON_PICKAXE) || item.equals(Material.DIAMOND_PICKAXE) || item.equals(Material.GOLD_PICKAXE) || item.equals(Material.WOOD_HOE) // NOTE: No vanilla enchantments for this || item.equals(Material.STONE_HOE) // NOTE: No vanilla enchantments for this || item.equals(Material.IRON_HOE) // NOTE: No vanilla enchantments for this || item.equals(Material.DIAMOND_HOE) // NOTE: No vanilla enchantments for this || item.equals(Material.GOLD_HOE) // NOTE: No vanilla enchantments for this || item.equals(Material.WOOD_AXE) || item.equals(Material.STONE_AXE) || item.equals(Material.IRON_AXE) || item.equals(Material.DIAMOND_AXE) || item.equals(Material.GOLD_AXE) || item.equals(Material.SHEARS) // NOTE: No vanilla enchantments for this || item.equals(Material.FLINT_AND_STEEL); // NOTE: No vanilla enchantments for this } },
@Override public Collection<ItemStack> getDrops(GlowBlock me, ItemStack tool) { // If the block below the dead bush is removed, // the bush will simply disappear without dropping anything. if (tool == null) { return BlockDropless.EMPTY_STACK; } // Dead bush drops it self when broken with shears if (tool.getType().equals(Material.SHEARS)) { return Collections.unmodifiableList(Arrays.asList(new ItemStack(Material.DEAD_BUSH))); } // Dead bush drops 0-2 sticks when broken without shears ThreadLocalRandom random = ThreadLocalRandom.current(); return Collections.unmodifiableList(Arrays.asList( new ItemStack(Material.STICK,random.nextInt(3)))); } }
/** * Get the underlying firework item. * * @return The Firework ItemStack of this Firework entity, or a new Firework ItemStack */ public ItemStack getFireworkItem() { ItemStack item = this.metadata.getItem(MetadataIndex.FIREWORK_INFO); if (InventoryUtil.isEmpty(item) || !Material.FIREWORK.equals(item.getType())) { item = DEFAULT_FIREWORK_ITEM.clone(); } return item; }
/** * Set the firework item of this firework entity. If an empty ItemStack, or none of the type * {{@link Material#FIREWORK}} was given, a new Firework ItemStack will be created. * * @param item FireWork Item this entity should use */ public void setFireworkItem(ItemStack item) { if (InventoryUtil.isEmpty(item) || !Material.FIREWORK.equals(item.getType())) { item = DEFAULT_FIREWORK_ITEM.clone(); } this.metadata.set(MetadataIndex.FIREWORK_INFO, item.clone()); }
@Override public boolean itemPlaceAllowed(int slot, ItemStack stack) { if (slot == FUEL_SLOT) { return ((GlowServer) ServerProvider.getServer()) .getCraftingManager().isFuel(stack.getType()) || stack.getType().equals(Material.BUCKET); } return super.itemPlaceAllowed(slot, stack); } }
/** * Find a a Location obove or below the specified Location, which is on ground. * * <p>The returned Location will be at the center of the block, X and Y wise. * * @param spawn The Location a safe spawn position should be found at. * @return The location to spawn the player at. */ private static Location findSafeSpawnLocation(Location spawn) { World world = spawn.getWorld(); int blockX = spawn.getBlockX(); int blockY = spawn.getBlockY(); int blockZ = spawn.getBlockZ(); int highestY = world.getHighestBlockYAt(blockX, blockZ); int y = blockY; boolean wasPreviousSafe = false; for (; y <= highestY; y++) { Material type = world.getBlockAt(blockX, y, blockZ).getType(); boolean safe = Material.AIR.equals(type); if (wasPreviousSafe && safe) { y--; break; } wasPreviousSafe = safe; } return new Location(world, blockX + 0.5, y, blockZ + 0.5); }
burnTimeFuel = burnTime; if (inv.getFuel().getAmount() == 1) { if (inv.getFuel().getType().equals(Material.LAVA_BUCKET)) { inv.setFuel(new ItemStack(Material.BUCKET)); } else { EventFactory.getInstance().callEvent(smeltEvent); if (!smeltEvent.isCancelled()) { if (inv.getSmelting().getType().equals(Material.SPONGE) && inv.getSmelting().getData().getData() == 1 && inv.getFuel() != null && inv.getFuel().getType().equals(Material.BUCKET) && inv.getFuel().getAmount() == 1) { inv.setFuel(new ItemStack(Material.WATER_BUCKET)); if (inv.getResult() == null || inv.getResult().getType().equals(Material.AIR)) { inv.setResult(smeltEvent.getResult()); } else if (inv.getResult().getType().equals(smeltEvent.getResult().getType())) { inv.getResult().setAmount( inv.getResult().getAmount() + smeltEvent.getResult().getAmount());
private boolean isBurnable() { GlowFurnaceInventory inv = (GlowFurnaceInventory) getInventory(); if ((burnTime != 0 || !InventoryUtil.isEmpty(inv.getFuel())) && !InventoryUtil .isEmpty(inv.getSmelting())) { if ((InventoryUtil.isEmpty(inv.getFuel()) || InventoryUtil.isEmpty(inv.getSmelting())) && burnTime == 0) { return false; } CraftingManager cm = ((GlowServer) ServerProvider.getServer()).getCraftingManager(); if (burnTime != 0 || cm.isFuel(inv.getFuel().getType())) { Recipe recipe = cm.getFurnaceRecipe(inv.getSmelting()); if (recipe != null && (InventoryUtil.isEmpty(inv.getResult()) || inv.getResult().getType().equals(recipe.getResult().getType()) && inv.getResult().getAmount() + recipe.getResult().getAmount() <= recipe .getResult().getMaxStackSize())) { return true; } } } return false; } }
@Override public boolean entityInteract(GlowPlayer player, InteractEntityMessage message) { super.entityInteract(player, message); if (message.getAction() == InteractEntityMessage.Action.INTERACT.ordinal()) { if (player.getGameMode().equals(GameMode.CREATIVE) || player.getGameMode() .equals(GameMode.SPECTATOR)) { return false; } if (!isAdult()) { return false; } ItemStack hand = InventoryUtil .itemOrEmpty(player.getInventory().getItem(message.getHandSlot())); if (!hand.getType().equals(Material.BUCKET)) { return false; } player.getInventory().consumeItemInHand(message.getHandSlot()); if (player.getInventory().firstEmpty() == -1) { GlowItem item = player.getWorld() .dropItem(player.getLocation().clone().add(0, 1, 0), new ItemStack(Material.MILK_BUCKET, 1)); item.setVelocity(getLocation().add(0, -1, 0).clone().toVector() .subtract(player.getLocation().clone().add(0, 1, 0).toVector()).multiply(0.3)); } else { player.getInventory().addItem(new ItemStack(Material.MILK_BUCKET, 1)); } } return true; }
for (Material m : blockedlevel1) { if (m.equals(searchedMaterial)) { // assuming that equals() was overriden // found it! do something with it break; } }
public static boolean isColorable(ItemStack itemstack) { return (itemstack.getType().equals(Material.STAINED_CLAY) || itemstack.getType().equals(Material.WOOL) || itemstack.getType().equals(Material.CARPET) || itemstack.getType().equals(Material.STAINED_GLASS) || itemstack.getType().equals(Material.STAINED_GLASS_PANE)); }
private boolean isMetarizable() { return (!this.material.equals(Material.POTION) && !(!BedwarsRel.getInstance().getCurrentVersion().startsWith("v1_8") && (this.material.equals(Material.valueOf("TIPPED_ARROW")) || this.material.equals(Material.valueOf("LINGERING_POTION")) || this.material.equals(Material.valueOf("SPLASH_POTION"))))); }