mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-17 11:05:02 +00:00
Cleaned up effect & flower provider alleles. Added basic genome template for Botanical, Blossoming, Floral bees. Added FlowerProviderBotania to grow Mystical Flowers.
86 lines
2.4 KiB
Java
86 lines
2.4 KiB
Java
package magicbees.bees.allele.flowerProvider;
|
|
|
|
import magicbees.main.utils.LocalizationManager;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.world.World;
|
|
import forestry.api.genetics.IFlowerProvider;
|
|
import forestry.api.genetics.IIndividual;
|
|
import forestry.api.genetics.IPollinatable;
|
|
|
|
public class FlowerProviderAuraNode implements IFlowerProvider {
|
|
protected int nodeRange = 70;
|
|
|
|
@Override
|
|
public boolean isAcceptedFlower(World world, IIndividual genome, int x, int y, int z) {
|
|
return this.isNodeWithinRange(world, x, y, z);
|
|
}
|
|
|
|
@Override
|
|
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
|
return pollinatable.getPlantType().size() > 0;
|
|
}
|
|
|
|
@Override
|
|
public boolean growFlower(World world, IIndividual genome, int x, int y, int z) {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return LocalizationManager.getLocalizedString("flowerProvider.node");
|
|
}
|
|
|
|
@Override
|
|
public ItemStack[] affectProducts(World world, IIndividual genome, int x, int y, int z, ItemStack[] products) {
|
|
return products;
|
|
}
|
|
|
|
@Override
|
|
public ItemStack[] getItemStacks() {
|
|
return null;
|
|
}
|
|
|
|
protected boolean isNodeWithinRange(World w, int x, int y, int z) {
|
|
boolean nodeNearby = false;
|
|
/*
|
|
* if (ThaumcraftApi.getClosestAuraWithinRange(w, x, y, z,
|
|
* this.nodeRange) >= 0) { nodeNearby = true; }
|
|
*/
|
|
return nodeNearby;
|
|
}
|
|
|
|
/*
|
|
* protected AuraNode getNodeWithinRange(World w, int x, int y, int z) {
|
|
* AuraNode node = null;
|
|
*
|
|
* int nodeId = ThaumcraftApi.getClosestAuraWithinRange(w, x, y, z,
|
|
* this.nodeRange); if (nodeId >= 0) { node =
|
|
* ThaumcraftApi.getNodeCopy(nodeId); }
|
|
*
|
|
* return node; }
|
|
*/
|
|
|
|
protected ItemStack[] addItemToProducts(ItemStack[] products, ItemStack itemStack) {
|
|
for (ItemStack stack : products) {
|
|
if (stack.getItem() == itemStack.getItem() && stack.getItemDamage() == itemStack.getItemDamage()) {
|
|
if (stack.stackSize < stack.getItem().getItemStackLimit(stack)) {
|
|
stack.stackSize += itemStack.stackSize;
|
|
itemStack.stackSize = Math.max(stack.stackSize - stack.getItem().getItemStackLimit(stack), 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (itemStack.stackSize > 0) {
|
|
ItemStack[] newProducts = new ItemStack[products.length + 1];
|
|
for (int i = 0; i < products.length; ++i) {
|
|
newProducts[i] = products[i];
|
|
}
|
|
newProducts[products.length] = itemStack;
|
|
products = newProducts;
|
|
}
|
|
|
|
return products;
|
|
}
|
|
|
|
}
|