Drop contents of Alveary when it's broken (#102)

Co-authored-by: Martin Robertz <dream-master@gmx.net>
This commit is contained in:
DarkShadow44andMartin Robertz authored and GitHub committed 2025-10-25 15:58:35 +02:00
1 parent 1552ad1b68
commit 278d091b08
2 files changed
+28

No files matched your search

@@ -8,7 +8,10 @@
******************************************************************************/
package forestry.apiculture;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
@@ -73,4 +76,27 @@ public class InventoryBeeHousing extends InventoryAdapterRestricted implements I
public final boolean addProduct(ItemStack product, boolean all) {
return InventoryUtil.tryAddStack(this, product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
}
public void dumpInventoryIntoWorld(World world, ChunkCoordinates coordinates) {
if (world.isRemote) {
return;
}
for (int i = 0; i < SLOT_PRODUCT_COUNT; i++) {
ItemStack stack = getStackInSlot(i);
if (stack == null) {
continue;
}
setInventorySlotContents(i, null);
EntityItem entityitem = new EntityItem(
world,
coordinates.posX + 0.5,
coordinates.posY + 0.5,
coordinates.posZ + 0.5,
stack);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
}
}
@@ -159,6 +159,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase
activeComponents.remove(oldPart);
}
}
inventory.dumpInventoryIntoWorld(this.worldObj, oldPart.getCoordinates());
}
@Override