Files
MagicBees/magicbees_src/magicbees/bees/FlowerProviderAuraNode.java
T

101 lines
2.3 KiB
Java
Raw Normal View History

2013-05-23 21:07:28 -07:00
package magicbees.bees;
2013-01-26 13:42:39 -08:00
2013-05-23 21:07:28 -07:00
import magicbees.main.utils.LocalizationManager;
2013-01-26 13:42:39 -08:00
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
2013-05-22 00:42:49 -07:00
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
2013-01-26 13:42:39 -08:00
import forestry.api.genetics.IPollinatable;
public class FlowerProviderAuraNode implements IFlowerProvider
{
protected int nodeRange = 70;
@Override
2013-05-22 00:42:49 -07:00
public boolean isAcceptedFlower(World world, IIndividual genome, int x, int y, int z)
2013-01-26 13:42:39 -08:00
{
return this.isNodeWithinRange(world, x, y, z);
}
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable)
{
2013-04-21 15:38:52 -07:00
return pollinatable.getPlantType().size() > 0;
2013-01-26 13:42:39 -08:00
}
@Override
2013-05-22 00:42:49 -07:00
public boolean growFlower(World world, IIndividual genome, int x, int y, int z)
2013-01-26 13:42:39 -08:00
{
return true;
2013-01-26 13:42:39 -08:00
}
@Override
public String getDescription()
{
2013-06-04 13:26:44 -07:00
return LocalizationManager.getLocalizedString("flowerProvider.node");
2013-01-26 13:42:39 -08:00
}
@Override
2013-05-22 00:42:49 -07:00
public ItemStack[] affectProducts(World world, IIndividual genome, int x, int y, int z, ItemStack[] products)
2013-01-26 13:42:39 -08:00
{
return products;
}
@Override
public ItemStack[] getItemStacks()
{
return null;
}
protected boolean isNodeWithinRange(World w, int x, int y, int z)
{
boolean nodeNearby = false;
2013-09-04 20:44:03 -07:00
/*if (ThaumcraftApi.getClosestAuraWithinRange(w, x, y, z, this.nodeRange) >= 0)
2013-01-26 13:42:39 -08:00
{
nodeNearby = true;
2013-09-04 20:44:03 -07:00
}*/
2013-01-26 13:42:39 -08:00
return nodeNearby;
}
2013-09-04 20:44:03 -07:00
/*protected AuraNode getNodeWithinRange(World w, int x, int y, int z)
2013-01-26 13:42:39 -08:00
{
AuraNode node = null;
int nodeId = ThaumcraftApi.getClosestAuraWithinRange(w, x, y, z, this.nodeRange);
if (nodeId >= 0)
{
node = ThaumcraftApi.getNodeCopy(nodeId);
}
return node;
2013-09-04 20:44:03 -07:00
}*/
2013-01-26 13:42:39 -08:00
protected ItemStack[] addItemToProducts(ItemStack[] products, ItemStack itemStack)
{
for (ItemStack stack : products)
{
if (stack.itemID == itemStack.itemID && stack.getItemDamage() == itemStack.getItemDamage())
{
if (stack.stackSize < stack.getItem().getItemStackLimit())
{
stack.stackSize += itemStack.stackSize;
itemStack.stackSize = Math.max(stack.stackSize - stack.getItem().getItemStackLimit(), 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;
}
2013-01-26 13:42:39 -08:00
}