mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Fix crash in BeekeepingLogic when removing a flower near bee hives
Fix Bee produceStacks logic
This commit is contained in:
1 parent
9fccfd1198
commit
6dab61b0f9
2 files changed
+11
-15
No files matched your search
@@ -208,6 +208,9 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
private void doProduction() {
|
||||
// Produce and add stacks
|
||||
ItemStack[] products = queen.produceStacks(housing);
|
||||
if (products == null) {
|
||||
return;
|
||||
}
|
||||
housing.wearOutEquipment(1);
|
||||
for (ItemStack stack : products) {
|
||||
housing.addProduct(stack, false);
|
||||
|
||||
@@ -467,10 +467,6 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
@Override
|
||||
public ItemStack[] produceStacks(IBeeHousing housing) {
|
||||
if (!hasFlower(housing)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (housing == null) {
|
||||
Proxies.log.warning("Failed to produce in an apiary because the beehousing was null.");
|
||||
return null;
|
||||
@@ -481,7 +477,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<ItemStack> products = new ArrayList<ItemStack>();
|
||||
List<ItemStack> products = new ArrayList<ItemStack>();
|
||||
|
||||
IAlleleBeeSpecies primary = genome.getPrimary();
|
||||
IAlleleBeeSpecies secondary = genome.getSecondary();
|
||||
@@ -507,20 +503,17 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
}
|
||||
|
||||
// We are done if the we are not jubilant.
|
||||
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing)) {
|
||||
return products.toArray(new ItemStack[products.size()]);
|
||||
}
|
||||
|
||||
// / Specialty products
|
||||
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet()) {
|
||||
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
|
||||
products.add(entry.getKey().copy());
|
||||
if (primary.isJubilant(genome, housing) && secondary.isJubilant(genome, housing)) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet()) {
|
||||
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
|
||||
products.add(entry.getKey().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(),
|
||||
products.toArray(new ItemStack[products.size()]));
|
||||
ItemStack[] productsArray = products.toArray(new ItemStack[products.size()]);
|
||||
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), productsArray);
|
||||
}
|
||||
|
||||
/* REPRODUCTION */
|
||||
|
||||
Reference in new issue
Block a user