Java Code Examples for org.bukkit.Material#SPAWNER

The following examples show how to use org.bukkit.Material#SPAWNER . 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: BlockPlacer.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
private void placeSlimefunBlock(SlimefunItem sfItem, ItemStack item, Block block, Dispenser dispenser) {
    block.setType(item.getType());
    BlockStorage.store(block, sfItem.getID());
    block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, item.getType());

    if (item.getType() == Material.SPAWNER && sfItem instanceof RepairedSpawner) {
        Optional<EntityType> entity = ((RepairedSpawner) sfItem).getEntityType(item);

        if (entity.isPresent()) {
            CreatureSpawner spawner = (CreatureSpawner) block.getState();
            spawner.setSpawnedType(entity.get());
            spawner.update(true, false);
        }
    }

    if (dispenser.getInventory().containsAtLeast(item, 2)) {
        dispenser.getInventory().removeItem(new CustomItem(item, 1));
    }
    else {
        Slimefun.runSync(() -> dispenser.getInventory().removeItem(item), 2L);
    }
}
 
Example 2
Source File: BlockUtils.java    From AACAdditionPro with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Fix for Spigot's broken occluding method.
 */
public static boolean isReallyOccluding(Material material)
{
    switch (ServerVersion.getActiveServerVersion()) {
        case MC188:
        case MC112:
            return material != Material.BARRIER && material != Material.getMaterial("MOB_SPAWNER") && material.isOccluding();
        case MC113:
        case MC114:
        case MC115:
            return material != Material.BARRIER && material != Material.SPAWNER && material.isOccluding();
        default:
            throw new UnknownMinecraftVersion();
    }
}
 
Example 3
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ItemStack getMaterial(String item) {
	if (item.equalsIgnoreCase("SKULL_ITEM")) {
		return new ItemStack(Material.SKELETON_SKULL, 1);
	} else if (item.equalsIgnoreCase("ENDER_PORTAL_FRAME")) {
		return new ItemStack(Material.END_PORTAL_FRAME, 1);
	} else if (item.equalsIgnoreCase("WORKBENCH")) {
		return new ItemStack(Material.CRAFTING_TABLE, 1);
	} else if (item.equalsIgnoreCase("IRON_FENCE")) {
		return new ItemStack(Material.IRON_BARS, 1);
	} else if (item.equalsIgnoreCase("REDSTONE_COMPARATOR")) {
		return new ItemStack(Material.COMPARATOR);
	} else if (item.equalsIgnoreCase("SIGN_POST")) {
		return new ItemStack(Material.SIGN);
	} else if (item.equalsIgnoreCase("STONE_PLATE")) {
		return new ItemStack(Material.STONE_PRESSURE_PLATE);
	} else if (item.equalsIgnoreCase("IRON_PLATE")) {
		return new ItemStack(Material.HEAVY_WEIGHTED_PRESSURE_PLATE);
	} else if (item.equalsIgnoreCase("GOLD_PLATE")) {
		return new ItemStack(Material.LIGHT_WEIGHTED_PRESSURE_PLATE);
	} else if (item.equalsIgnoreCase("MOB_SPAWNER")) {
		return new ItemStack(Material.SPAWNER);
	} else if (item.equalsIgnoreCase("SNOW_BALL")) {
		return new ItemStack(Material.SNOWBALL);
	} else {
		return new ItemStack(Material.AIR, 1);
	}
}
 
Example 4
Source File: PickaxeOfContainment.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@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)) {
                if (!Slimefun.hasUnlocked(e.getPlayer(), PickaxeOfContainment.this, true)) {
                    return true;
                }

                Block b = e.getBlock();

                if (b.getType() != Material.SPAWNER) {
                    return true;
                }

                ItemStack spawner = breakSpawner(b);
                b.getLocation().getWorld().dropItemNaturally(b.getLocation(), spawner);

                e.setExpToDrop(0);
                e.setDropItems(false);
                return true;
            }
            else {
                if (e.getBlock().getType() == Material.SPAWNER) e.setDropItems(false);
                return false;
            }
        }
    };
}
 
Example 5
Source File: CommandNBTTile.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected TileNBTWrapper getWrapper(Player player) throws MyCommandException {
	Block block = UtilsMc.getTargetBlock(player, 5);
	if (block.getType() == Material.AIR) {
		throw new MyCommandException("§cNo tile in sight!");
	}
	try {
		if (block.getType() == Material.SPAWNER) {
			return new SpawnerNBTWrapper(block);
		}
		return new TileNBTWrapper(block);
	} catch (RuntimeException e) {
		throw new MyCommandException("§cCannot edit that tile!");
	}
}