Search in sources :

Example 1 with PlantDrop

use of jeresources.api.drop.PlantDrop in project JustEnoughResources by way2muchnoise.

the class MinecraftCompat method registerVanillaPlants.

private void registerVanillaPlants() {
    // Potato
    PlantDrop potato = new PlantDrop(new ItemStack(Items.POTATO), 1, 4);
    PlantDrop poisonous = new PlantDrop(new ItemStack(Items.POISONOUS_POTATO), 0.02F);
    registerPlant(new PlantEntry((PotatoBlock) Blocks.POTATOES, potato, poisonous));
    // Carrot
    PlantDrop carrot = new PlantDrop(new ItemStack(Items.CARROT), 1, 4);
    registerPlant(new PlantEntry((CarrotBlock) Blocks.CARROTS, carrot));
    // Wheat
    PlantDrop wheat = new PlantDrop(new ItemStack(Items.WHEAT), 1, 1);
    PlantDrop seeds = new PlantDrop(new ItemStack(Items.WHEAT_SEEDS), 0, 3);
    registerPlant(new PlantEntry((CropBlock) Blocks.WHEAT, wheat, seeds));
    // Melon
    PlantDrop melonSlice = new PlantDrop(new ItemStack(Items.MELON_SLICE), 3, 7);
    registerPlant(new PlantEntry((StemBlock) Blocks.MELON_STEM, melonSlice));
    // Pumpkin
    PlantDrop pumpkin = new PlantDrop(new ItemStack(Blocks.PUMPKIN), 1, 1);
    registerPlant(new PlantEntry((StemBlock) Blocks.PUMPKIN_STEM, pumpkin));
    // Beetroot
    PlantDrop beetroot = new PlantDrop(new ItemStack(Items.BEETROOT), 1, 1);
    PlantDrop beetrootSeeds = new PlantDrop(new ItemStack(Items.BEETROOT_SEEDS), 0, 3);
    registerPlant(new PlantEntry((BeetrootBlock) Blocks.BEETROOTS, beetroot, beetrootSeeds));
    // Nether Wart
    PlantDrop netherWartDrop = new PlantDrop(new ItemStack(Items.NETHER_WART), 2, 4);
    PlantEntry netherWartEntry = new PlantEntry((NetherWartBlock) Blocks.NETHER_WART, netherWartDrop);
    netherWartEntry.setSoil(Blocks.SOUL_SAND.defaultBlockState());
    registerPlant(netherWartEntry);
    // Sweet berries
    // Drops 1-2 at age 2, 2-3 at age 3
    PlantDrop sweetBerriesDrop = new PlantDrop(new ItemStack(Items.SWEET_BERRIES), 1, 3);
    PlantEntry sweetBerriesEntry = new PlantEntry((SweetBerryBushBlock) Blocks.SWEET_BERRY_BUSH, sweetBerriesDrop);
    sweetBerriesEntry.setSoil(Blocks.GRASS_BLOCK.defaultBlockState());
    registerPlant(sweetBerriesEntry);
}
Also used : PlantEntry(jeresources.entry.PlantEntry) PlantDrop(jeresources.api.drop.PlantDrop) ItemStack(net.minecraft.world.item.ItemStack)

Example 2 with PlantDrop

use of jeresources.api.drop.PlantDrop in project JustEnoughResources by way2muchnoise.

the class PlantEntry method add.

public void add(PlantDrop entry) {
    String key = MapKeys.getKey(entry.getDrop());
    if (!this.drops.containsKey(key))
        return;
    this.drops.put(key, new PlantDrop(entry.getDrop(), (this.totalWeight + entry.getWeight())));
}
Also used : PlantDrop(jeresources.api.drop.PlantDrop)

Example 3 with PlantDrop

use of jeresources.api.drop.PlantDrop in project JustEnoughResources by way2muchnoise.

the class SeedHelper method getSeeds.

@SuppressWarnings("unchecked")
public static List<PlantDrop> getSeeds() {
    List<PlantDrop> result = new ArrayList<>();
    Class seedEntry = ReflectionHelper.findClass("net.minecraftforge.common.ForgeHooks$SeedEntry");
    if (seedEntry == null)
        return result;
    List seedList = ReflectionHelper.getPrivateValue(ForgeHooks.class, null, "seedList");
    for (Object o : seedList) {
        if (o == null)
            continue;
        ItemStack seed = (ItemStack) ReflectionHelper.getPrivateValue(seedEntry, o, "seed");
        if (seed == null || seed.getItem() == null)
            continue;
        result.add(new PlantDrop(seed, ((WeightedEntry.IntrusiveBase) o).weight.asInt()));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PlantDrop(jeresources.api.drop.PlantDrop) ItemStack(net.minecraft.world.item.ItemStack) WeightedEntry(net.minecraft.util.random.WeightedEntry)

Example 4 with PlantDrop

use of jeresources.api.drop.PlantDrop in project JustEnoughResources by way2muchnoise.

the class PlantEntry method registerGrass.

public static PlantEntry registerGrass() {
    List<PlantDrop> seeds = SeedHelper.getSeeds();
    PlantEntry grass = new PlantEntry(new ItemStack(Blocks.TALL_GRASS, 1, new CompoundTag()), seeds.toArray(new PlantDrop[seeds.size()]));
    grass.totalWeight *= 8;
    return grass;
}
Also used : PlantDrop(jeresources.api.drop.PlantDrop) ItemStack(net.minecraft.world.item.ItemStack) CompoundTag(net.minecraft.nbt.CompoundTag)

Example 5 with PlantDrop

use of jeresources.api.drop.PlantDrop in project Advent-Of-Ascension by Tslat.

the class JerHooks method integrateCrops.

private static void integrateCrops() {
    IPlantRegistry plantRegistry = jerAPI.getPlantRegistry();
    try {
        Method getSeedsMethod = ObfuscationReflectionHelper.findMethod(BlockCrops.class, "func_149866_i", Item.class);
        for (Block block : ForgeRegistries.BLOCKS.getValuesCollection()) {
            if (block instanceof CropBlock) {
                CropBlock crop = (CropBlock) block;
                Item seedItem = (Item) getSeedsMethod.invoke(crop);
                ItemStack seeds = new ItemStack(seedItem);
                if (crop.dropsSeeds()) {
                    plantRegistry.register(seeds, (IPlantable) seedItem, new PlantDrop(new ItemStack(crop.getCrop()), 1f), new PlantDrop(seeds, 0, 3));
                } else {
                    plantRegistry.register(seeds, (IPlantable) seedItem, new PlantDrop(new ItemStack(crop.getCrop()), 1f), new PlantDrop(seeds, 0, 1));
                }
            }
        }
    } catch (Exception ex) {
        AdventOfAscension.logOptionalMessage("Error while reflecting crop blocks for JER, skipping.", ex);
    }
}
Also used : Item(net.minecraft.item.Item) LootEntryItem(net.minecraft.world.storage.loot.LootEntryItem) Block(net.minecraft.block.Block) CropBlock(net.tslat.aoa3.block.functional.crops.CropBlock) Method(java.lang.reflect.Method) CropBlock(net.tslat.aoa3.block.functional.crops.CropBlock) ItemStack(net.minecraft.item.ItemStack) PlantDrop(jeresources.api.drop.PlantDrop)

Aggregations

PlantDrop (jeresources.api.drop.PlantDrop)5 ItemStack (net.minecraft.world.item.ItemStack)3 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PlantEntry (jeresources.entry.PlantEntry)1 Block (net.minecraft.block.Block)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 CompoundTag (net.minecraft.nbt.CompoundTag)1 WeightedEntry (net.minecraft.util.random.WeightedEntry)1 LootEntryItem (net.minecraft.world.storage.loot.LootEntryItem)1 CropBlock (net.tslat.aoa3.block.functional.crops.CropBlock)1