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);
}
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())));
}
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;
}
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;
}
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);
}
}
Aggregations