Search in sources :

Example 46 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class HeatedPressureChamber method registerDefaultRecipes.

@Override
protected void registerDefaultRecipes() {
    registerRecipe(45, new ItemStack[] { SlimefunItems.OIL_BUCKET }, new ItemStack[] { new CustomItemStack(SlimefunItems.PLASTIC_SHEET, 8) });
    registerRecipe(30, new ItemStack[] { SlimefunItems.GOLD_24K, SlimefunItems.URANIUM }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT });
    registerRecipe(30, new ItemStack[] { SlimefunItems.BLISTERING_INGOT, SlimefunItems.CARBONADO }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_2 });
    registerRecipe(60, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_2, new ItemStack(Material.NETHER_STAR) }, new ItemStack[] { SlimefunItems.BLISTERING_INGOT_3 });
    registerRecipe(90, new ItemStack[] { SlimefunItems.PLUTONIUM, SlimefunItems.URANIUM }, new ItemStack[] { SlimefunItems.BOOSTED_URANIUM });
    registerRecipe(60, new ItemStack[] { SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM }, new ItemStack[] { new CustomItemStack(SlimefunItems.ENRICHED_NETHER_ICE, 4) });
    registerRecipe(45, new ItemStack[] { SlimefunItems.ENRICHED_NETHER_ICE }, new ItemStack[] { new CustomItemStack(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8) });
    registerRecipe(8, new ItemStack[] { SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SALT }, new ItemStack[] { SlimefunItems.MAGNESIUM_SALT });
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ItemStack(org.bukkit.inventory.ItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack)

Example 47 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class ReactorAccessPort method constructMenu.

private void constructMenu(@Nonnull BlockMenuPreset preset) {
    preset.drawBackground(ChestMenuUtils.getBackground(), background);
    preset.drawBackground(new CustomItemStack(Material.LIME_STAINED_GLASS_PANE, " "), fuelBorder);
    preset.drawBackground(new CustomItemStack(Material.CYAN_STAINED_GLASS_PANE, " "), inputBorder);
    preset.drawBackground(new CustomItemStack(Material.GREEN_STAINED_GLASS_PANE, " "), outputBorder);
    preset.addItem(1, new CustomItemStack(SlimefunItems.URANIUM, "&7Fuel Slot", "", "&rThis Slot accepts radioactive Fuel such as:", "&2Uranium &ror &aNeptunium"), ChestMenuUtils.getEmptyClickHandler());
    preset.addItem(22, new CustomItemStack(SlimefunItems.PLUTONIUM, "&7Byproduct Slot", "", "&rThis Slot contains the Reactor's Byproduct", "&rsuch as &aNeptunium &ror &7Plutonium"), ChestMenuUtils.getEmptyClickHandler());
    preset.addItem(7, new CustomItemStack(SlimefunItems.REACTOR_COOLANT_CELL, "&bCoolant Slot", "", "&rThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode"), ChestMenuUtils.getEmptyClickHandler());
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack)

Example 48 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class AbstractFilterNode method updateBlockMenu.

@Override
protected void updateBlockMenu(BlockMenu menu, Block b) {
    Location loc = b.getLocation();
    String filterType = BlockStorage.getLocationInfo(loc, FILTER_TYPE);
    if (!BlockStorage.hasBlockInfo(b) || filterType == null || filterType.equals("whitelist")) {
        menu.replaceExistingItem(15, new CustomItemStack(Material.WHITE_WOOL, "&7Type: &rWhitelist", "", "&e> Click to change it to Blacklist"));
        menu.addMenuClickHandler(15, (p, slot, item, action) -> {
            BlockStorage.addBlockInfo(b, FILTER_TYPE, "blacklist");
            updateBlockMenu(menu, b);
            return false;
        });
    } else {
        menu.replaceExistingItem(15, new CustomItemStack(Material.BLACK_WOOL, "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist"));
        menu.addMenuClickHandler(15, (p, slot, item, action) -> {
            BlockStorage.addBlockInfo(b, FILTER_TYPE, "whitelist");
            updateBlockMenu(menu, b);
            return false;
        });
    }
    String lore = BlockStorage.getLocationInfo(b.getLocation(), FILTER_LORE);
    if (!BlockStorage.hasBlockInfo(b) || lore == null || lore.equals(String.valueOf(true))) {
        menu.replaceExistingItem(25, new CustomItemStack(Material.MAP, "&7Include Lore: &2\u2714", "", "&e> Click to toggle whether the Lore has to match"));
        menu.addMenuClickHandler(25, (p, slot, item, action) -> {
            BlockStorage.addBlockInfo(b, FILTER_LORE, String.valueOf(false));
            updateBlockMenu(menu, b);
            return false;
        });
    } else {
        menu.replaceExistingItem(25, new CustomItemStack(Material.MAP, "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match"));
        menu.addMenuClickHandler(25, (p, slot, item, action) -> {
            BlockStorage.addBlockInfo(b, FILTER_LORE, String.valueOf(true));
            updateBlockMenu(menu, b);
            return false;
        });
    }
    addChannelSelector(b, menu, 41, 42, 43);
    markDirty(loc);
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) Location(org.bukkit.Location)

Example 49 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class CargoInputNode method updateBlockMenu.

@Override
protected void updateBlockMenu(BlockMenu menu, Block b) {
    super.updateBlockMenu(menu, b);
    String roundRobinMode = BlockStorage.getLocationInfo(b.getLocation(), ROUND_ROBIN_MODE);
    if (!BlockStorage.hasBlockInfo(b) || roundRobinMode == null || roundRobinMode.equals(String.valueOf(false))) {
        menu.replaceExistingItem(24, new CustomItemStack(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&7Round-Robin Mode: &4\u2718", "", "&e> Click to enable Round Robin Mode", "&e(Items will be equally distributed on the Channel)"));
        menu.addMenuClickHandler(24, (p, slot, item, action) -> {
            BlockStorage.addBlockInfo(b, ROUND_ROBIN_MODE, String.valueOf(true));
            updateBlockMenu(menu, b);
            return false;
        });
    } else {
        menu.replaceExistingItem(24, new CustomItemStack(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)"));
        menu.addMenuClickHandler(24, (p, slot, item, action) -> {
            BlockStorage.addBlockInfo(b, ROUND_ROBIN_MODE, String.valueOf(false));
            updateBlockMenu(menu, b);
            return false;
        });
    }
    String smartFillNode = BlockStorage.getLocationInfo(b.getLocation(), SMART_FILL_MODE);
    if (!BlockStorage.hasBlockInfo(b) || smartFillNode == null || smartFillNode.equals(String.valueOf(false))) {
        menu.replaceExistingItem(16, new CustomItemStack(Material.WRITABLE_BOOK, "&7\"Smart-Filling\" Mode: &4\u2718", "", "&e> Click to enable \"Smart-Filling\" Mode", "", "&fIn this mode, the Cargo node will attempt", "&fto keep a constant amount of items", "&fin the inventory. This is not perfect", "&fand will still fill in empty slots that", "&fcome before a stack of a configured item."));
        menu.addMenuClickHandler(16, (p, slot, item, action) -> {
            BlockStorage.addBlockInfo(b, SMART_FILL_MODE, String.valueOf(true));
            updateBlockMenu(menu, b);
            return false;
        });
    } else {
        menu.replaceExistingItem(16, new CustomItemStack(Material.WRITTEN_BOOK, "&7\"Smart-Filling\" Mode: &2\u2714", "", "&e> Click to disable \"Smart-Filling\" Mode", "", "&fIn this mode, the Cargo node will attempt", "&fto keep a constant amount of items", "&fin the inventory. This is not perfect", "&fand will still fill in empty slots that", "&fcome before a stack of a configured item."));
        menu.addMenuClickHandler(16, (p, slot, item, action) -> {
            BlockStorage.addBlockInfo(b, SMART_FILL_MODE, String.valueOf(false));
            updateBlockMenu(menu, b);
            return false;
        });
    }
}
Also used : CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack)

Example 50 with CustomItemStack

use of io.github.bakedlibs.dough.items.CustomItemStack in project Slimefun4 by Slimefun.

the class ResourceManager method scan.

/**
 * This method will start a geo-scan at the given {@link Block} and display the result
 * of that scan to the given {@link Player}.
 *
 * Note that scans are always per {@link Chunk}, not per {@link Block}, the {@link Block}
 * parameter only determines the {@link Location} that was clicked but it will still scan
 * the entire {@link Chunk}.
 *
 * @param p
 *            The {@link Player} who requested these results
 * @param block
 *            The {@link Block} which the scan starts at
 * @param page
 *            The page to display
 */
public void scan(@Nonnull Player p, @Nonnull Block block, int page) {
    if (Slimefun.getGPSNetwork().getNetworkComplexity(p.getUniqueId()) < 600) {
        Slimefun.getLocalization().sendMessages(p, "gps.insufficient-complexity", true, msg -> msg.replace("%complexity%", "600"));
        return;
    }
    int x = block.getX() >> 4;
    int z = block.getZ() >> 4;
    String title = "&4" + Slimefun.getLocalization().getResourceString(p, "tooltips.results");
    ChestMenu menu = new ChestMenu(title);
    for (int slot : backgroundSlots) {
        menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
    }
    menu.addItem(4, new CustomItemStack(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler());
    List<GEOResource> resources = new ArrayList<>(Slimefun.getRegistry().getGEOResources().values());
    resources.sort(Comparator.comparing(a -> a.getName(p).toLowerCase(Locale.ROOT)));
    int index = 10;
    int pages = (resources.size() - 1) / 36 + 1;
    for (int i = page * 28; i < resources.size() && i < (page + 1) * 28; i++) {
        GEOResource resource = resources.get(i);
        OptionalInt optional = getSupplies(resource, block.getWorld(), x, z);
        int supplies = optional.isPresent() ? optional.getAsInt() : generate(resource, block.getWorld(), x, block.getY(), z);
        String suffix = Slimefun.getLocalization().getResourceString(p, supplies == 1 ? "tooltips.unit" : "tooltips.units");
        ItemStack item = new CustomItemStack(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix);
        if (supplies > 1) {
            item.setAmount(supplies > item.getMaxStackSize() ? item.getMaxStackSize() : supplies);
        }
        menu.addItem(index, item, ChestMenuUtils.getEmptyClickHandler());
        index++;
        if (index % 9 == 8) {
            index += 2;
        }
    }
    menu.addItem(47, ChestMenuUtils.getPreviousButton(p, page + 1, pages));
    menu.addMenuClickHandler(47, (pl, slot, item, action) -> {
        if (page > 0) {
            scan(pl, block, page - 1);
        }
        return false;
    });
    menu.addItem(51, ChestMenuUtils.getNextButton(p, page + 1, pages));
    menu.addMenuClickHandler(51, (pl, slot, item, action) -> {
        if (page + 1 < pages) {
            scan(pl, block, page + 1);
        }
        return false;
    });
    menu.open(p);
}
Also used : BlockStorage(me.mrCookieSlime.Slimefun.api.BlockStorage) Player(org.bukkit.entity.Player) OptionalInt(java.util.OptionalInt) Biome(org.bukkit.block.Biome) ArrayList(java.util.ArrayList) GEOResourceGenerationEvent(io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent) Block(org.bukkit.block.Block) GEOMiner(io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner) Location(org.bukkit.Location) Locale(java.util.Locale) World(org.bukkit.World) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Chunk(org.bukkit.Chunk) BlockPosition(io.github.bakedlibs.dough.blocks.BlockPosition) Nonnull(javax.annotation.Nonnull) Bukkit(org.bukkit.Bukkit) ChestMenuUtils(io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils) Config(io.github.bakedlibs.dough.config.Config) GEOScanner(io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner) ItemStack(org.bukkit.inventory.ItemStack) MinecraftVersion(io.github.thebusybiscuit.slimefun4.api.MinecraftVersion) List(java.util.List) Slimefun(io.github.thebusybiscuit.slimefun4.implementation.Slimefun) ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu) ChatColor(org.bukkit.ChatColor) Comparator(java.util.Comparator) HeadTexture(io.github.thebusybiscuit.slimefun4.utils.HeadTexture) Validate(org.apache.commons.lang.Validate) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ArrayList(java.util.ArrayList) OptionalInt(java.util.OptionalInt) ItemStack(org.bukkit.inventory.ItemStack) CustomItemStack(io.github.bakedlibs.dough.items.CustomItemStack) ChestMenu(me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu)

Aggregations

CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)172 Test (org.junit.jupiter.api.Test)100 DisplayName (org.junit.jupiter.api.DisplayName)90 SlimefunItem (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)83 ItemStack (org.bukkit.inventory.ItemStack)70 SlimefunItemStack (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)43 NamespacedKey (org.bukkit.NamespacedKey)31 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)26 Player (org.bukkit.entity.Player)25 ChestMenu (me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu)22 ItemGroup (io.github.thebusybiscuit.slimefun4.api.items.ItemGroup)20 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)18 Slimefun (io.github.thebusybiscuit.slimefun4.implementation.Slimefun)12 PlayerProfile (io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile)11 FlexItemGroup (io.github.thebusybiscuit.slimefun4.api.items.groups.FlexItemGroup)10 ArrayList (java.util.ArrayList)10 Nonnull (javax.annotation.Nonnull)10 Material (org.bukkit.Material)10 LockedItemGroup (io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup)9 Location (org.bukkit.Location)9