Search in sources :

Example 1 with CustomFood

use of io.github.thebusybiscuit.exoticgarden.items.CustomFood in project ExoticGarden by TheBusyBiscuit.

the class ExoticGarden method registerTree.

private void registerTree(String name, String texture, String color, Color pcolor, String juice, boolean pie, Material... soil) {
    String id = name.toUpperCase(Locale.ROOT).replace(' ', '_');
    Tree tree = new Tree(id, texture, soil);
    trees.add(tree);
    SlimefunItemStack sapling = new SlimefunItemStack(id + "_SAPLING", Material.OAK_SAPLING, color + name + " Sapling");
    items.put(id + "_SAPLING", sapling);
    new BonemealableItem(mainItemGroup, sapling, ExoticGardenRecipeTypes.BREAKING_GRASS, new ItemStack[] { null, null, null, null, new ItemStack(Material.GRASS), null, null, null, null }).register(this);
    new ExoticGardenFruit(mainItemGroup, new SlimefunItemStack(id, texture, color + name), ExoticGardenRecipeTypes.HARVEST_TREE, true, new ItemStack[] { null, null, null, null, getItem(id + "_SAPLING"), null, null, null, null }).register(this);
    if (pcolor != null) {
        new Juice(drinksItemGroup, new SlimefunItemStack(juice.toUpperCase().replace(" ", "_"), new CustomPotion(color + juice, pcolor, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "", "&7&oRestores &b&o" + "3.0" + " &7&oHunger")), RecipeType.JUICER, new ItemStack[] { getItem(id), null, null, null, null, null, null, null, null }).register(this);
    }
    if (pie) {
        new CustomFood(foodItemGroup, new SlimefunItemStack(id + "_PIE", "3418c6b0a29fc1fe791c89774d828ff63d2a9fa6c83373ef3aa47bf3eb79", color + name + " Pie", "", "&7&oRestores &b&o" + "6.5" + " &7&oHunger"), new ItemStack[] { getItem(id), new ItemStack(Material.EGG), new ItemStack(Material.SUGAR), new ItemStack(Material.MILK_BUCKET), SlimefunItems.WHEAT_FLOUR, null, null, null, null }, 13).register(this);
    }
    if (!new File(schematicsFolder, id + "_TREE.schematic").exists()) {
        saveSchematic(id + "_TREE");
    }
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) Juice(io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice) BonemealableItem(io.github.thebusybiscuit.exoticgarden.items.BonemealableItem) ExoticGardenFruit(io.github.thebusybiscuit.exoticgarden.items.ExoticGardenFruit) CustomFood(io.github.thebusybiscuit.exoticgarden.items.CustomFood) ItemStack(org.bukkit.inventory.ItemStack) CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) File(java.io.File) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Example 2 with CustomFood

use of io.github.thebusybiscuit.exoticgarden.items.CustomFood in project DynaTech by ProfElements.

the class PicnicBasketListener method consumeFood.

private void consumeFood(Player p, ItemStack picnicBasketItem, PlayerBackpack backpack) {
    Inventory inv = backpack.getInventory();
    int slot = -1;
    for (int i = 0; i < inv.getSize(); i++) {
        ItemStack item = inv.getItem(i);
        if (item != null) {
            slot = i;
        }
    }
    if (slot >= 0) {
        ItemStack item = inv.getItem(slot);
        PicnicBasketFeedPlayerEvent event = new PicnicBasketFeedPlayerEvent(p, picnicBasket, picnicBasketItem, item);
        plugin.getServer().getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            boolean itemConsumed = false;
            SlimefunItem sfItem = SlimefunItem.getByItem(item);
            if (DynaTech.isExoticGardenInstalled() && sfItem != null) {
                if (sfItem instanceof CustomFood) {
                    CustomFood cfItem = (CustomFood) sfItem;
                    if (cfItem.getFoodValue() + p.getFoodLevel() <= 20) {
                        p.setFoodLevel(p.getFoodLevel() + cfItem.getFoodValue());
                        itemConsumed = true;
                    }
                }
            } else {
                Material material = item.getType();
                if (material == Material.COOKED_PORKCHOP || material == Material.PUMPKIN_PIE || material == Material.COOKED_BEEF) {
                    if (p.getFoodLevel() <= 12) {
                        p.setFoodLevel(p.getFoodLevel() + 8);
                        itemConsumed = true;
                    }
                } else if (material == Material.COOKED_CHICKEN || material == Material.COOKED_MUTTON || material == Material.COOKED_SALMON || material == Material.GOLDEN_CARROT) {
                    if (p.getFoodLevel() <= 14) {
                        p.setFoodLevel(p.getFoodLevel() + 6);
                        itemConsumed = true;
                    }
                } else if (material == Material.BAKED_POTATO || material == Material.COOKED_RABBIT || material == Material.COOKED_COD || material == Material.BREAD) {
                    if (p.getFoodLevel() <= 15) {
                        p.setFoodLevel(p.getFoodLevel() + 5);
                        itemConsumed = true;
                    }
                } else if (material == Material.APPLE) {
                    if (p.getFoodLevel() <= 16) {
                        p.setFoodLevel(p.getFoodLevel() + 4);
                        itemConsumed = true;
                    }
                } else if (material == Material.CARROT || material == Material.BEEF || material == Material.PORKCHOP || material == Material.RABBIT) {
                    if (p.getFoodLevel() <= 17) {
                        p.setFoodLevel(p.getFoodLevel() + 3);
                        itemConsumed = true;
                    }
                } else if (material == Material.COOKIE || material == Material.MELON_SLICE || material == Material.CHICKEN || material == Material.COD || material == Material.MUTTON || material == Material.SALMON || material == Material.SWEET_BERRIES) {
                    if (p.getFoodLevel() <= 18) {
                        p.setFoodLevel(p.getFoodLevel() + 2);
                        itemConsumed = true;
                    }
                } else if (material == Material.BEETROOT || material == Material.DRIED_KELP || material == Material.POTATO || material == Material.TROPICAL_FISH) {
                    if (p.getFoodLevel() <= 19) {
                        p.setFoodLevel(p.getFoodLevel() + 1);
                        itemConsumed = true;
                    }
                }
            }
            if (item.getAmount() > 1 && itemConsumed) {
                item.setAmount(item.getAmount() - 1);
                p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1F, 1F);
                p.setSaturation(p.getSaturation() + 4F);
            } else if (itemConsumed) {
                inv.setItem(slot, null);
                p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1F, 1F);
                p.setSaturation(p.getSaturation() + 4F);
            }
            backpack.markDirty();
        }
    }
}
Also used : Material(org.bukkit.Material) SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) CustomFood(io.github.thebusybiscuit.exoticgarden.items.CustomFood) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) PicnicBasketFeedPlayerEvent(me.profelements.dynatech.events.PicnicBasketFeedPlayerEvent)

Example 3 with CustomFood

use of io.github.thebusybiscuit.exoticgarden.items.CustomFood in project DynaTech by ProfElements.

the class CulinaryGenerator method findRecipe.

@Override
public MachineFuel findRecipe(BlockMenu inv, Map<Integer, Integer> found) {
    if (DynaTech.isExoticGardenInstalled() && exoticGardenIntegration.getValue()) {
        for (int inputSlot : getInputSlots()) {
            SlimefunItem sfItem = SlimefunItem.getByItem(inv.getItemInSlot(inputSlot));
            if (sfItem instanceof CustomFood) {
                CustomFood cfItem = (CustomFood) sfItem;
                MachineFuel fuel = new MachineFuel(cfItem.getFoodValue() * 4, sfItem.getItem());
                inv.consumeItem(inputSlot);
                return fuel;
            }
        }
    }
    return super.findRecipe(inv, found);
}
Also used : SlimefunItem(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem) CustomFood(io.github.thebusybiscuit.exoticgarden.items.CustomFood) MachineFuel(me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel)

Example 4 with CustomFood

use of io.github.thebusybiscuit.exoticgarden.items.CustomFood in project ExoticGarden by TheBusyBiscuit.

the class ExoticGarden method registerBerry.

public void registerBerry(String name, ChatColor color, Color potionColor, PlantType type, String texture) {
    String upperCase = name.toUpperCase(Locale.ROOT);
    Berry berry = new Berry(upperCase, type, texture);
    berries.add(berry);
    SlimefunItemStack sfi = new SlimefunItemStack(upperCase + "_BUSH", Material.OAK_SAPLING, color + name + " Bush");
    items.put(upperCase + "_BUSH", sfi);
    new BonemealableItem(mainItemGroup, sfi, ExoticGardenRecipeTypes.BREAKING_GRASS, new ItemStack[] { null, null, null, null, new ItemStack(Material.GRASS), null, null, null, null }).register(this);
    new ExoticGardenFruit(mainItemGroup, new SlimefunItemStack(upperCase, texture, color + name), ExoticGardenRecipeTypes.HARVEST_BUSH, true, new ItemStack[] { null, null, null, null, getItem(upperCase + "_BUSH"), null, null, null, null }).register(this);
    new Juice(drinksItemGroup, new SlimefunItemStack(upperCase + "_JUICE", new CustomPotion(color + name + " Juice", potionColor, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "", "&7&oRestores &b&o" + "3.0" + " &7&oHunger")), RecipeType.JUICER, new ItemStack[] { getItem(upperCase), null, null, null, null, null, null, null, null }).register(this);
    new Juice(drinksItemGroup, new SlimefunItemStack(upperCase + "_SMOOTHIE", new CustomPotion(color + name + " Smoothie", potionColor, new PotionEffect(PotionEffectType.SATURATION, 10, 0), "", "&7&oRestores &b&o" + "5.0" + " &7&oHunger")), RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] { getItem(upperCase + "_JUICE"), getItem("ICE_CUBE"), null, null, null, null, null, null, null }).register(this);
    new CustomFood(foodItemGroup, new SlimefunItemStack(upperCase + "_JELLY_SANDWICH", "8c8a939093ab1cde6677faf7481f311e5f17f63d58825f0e0c174631fb0439", color + name + " Jelly Sandwich", "", "&7&oRestores &b&o" + "8.0" + " &7&oHunger"), new ItemStack[] { null, new ItemStack(Material.BREAD), null, null, getItem(upperCase + "_JUICE"), null, null, new ItemStack(Material.BREAD), null }, 16).register(this);
    new CustomFood(foodItemGroup, new SlimefunItemStack(upperCase + "_PIE", "3418c6b0a29fc1fe791c89774d828ff63d2a9fa6c83373ef3aa47bf3eb79", color + name + " Pie", "", "&7&oRestores &b&o" + "6.5" + " &7&oHunger"), new ItemStack[] { getItem(upperCase), new ItemStack(Material.EGG), new ItemStack(Material.SUGAR), new ItemStack(Material.MILK_BUCKET), SlimefunItems.WHEAT_FLOUR, null, null, null, null }, 13).register(this);
}
Also used : PotionEffect(org.bukkit.potion.PotionEffect) Juice(io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice) BonemealableItem(io.github.thebusybiscuit.exoticgarden.items.BonemealableItem) ExoticGardenFruit(io.github.thebusybiscuit.exoticgarden.items.ExoticGardenFruit) CustomFood(io.github.thebusybiscuit.exoticgarden.items.CustomFood) ItemStack(org.bukkit.inventory.ItemStack) CustomItemStack(io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack) SlimefunItemStack(io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)

Aggregations

CustomFood (io.github.thebusybiscuit.exoticgarden.items.CustomFood)4 ItemStack (org.bukkit.inventory.ItemStack)3 BonemealableItem (io.github.thebusybiscuit.exoticgarden.items.BonemealableItem)2 ExoticGardenFruit (io.github.thebusybiscuit.exoticgarden.items.ExoticGardenFruit)2 SlimefunItem (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem)2 SlimefunItemStack (io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack)2 Juice (io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice)2 CustomItemStack (io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack)2 PotionEffect (org.bukkit.potion.PotionEffect)2 File (java.io.File)1 MachineFuel (me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel)1 PicnicBasketFeedPlayerEvent (me.profelements.dynatech.events.PicnicBasketFeedPlayerEvent)1 Material (org.bukkit.Material)1 Inventory (org.bukkit.inventory.Inventory)1