Skip to content

Commit

Permalink
Bug fix: Crash with OpenBlocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Terminal-Access committed May 4, 2020
1 parent f231f85 commit 723ca5e
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions patches/net/minecraft/block/BlockDropper.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
@@ -60,10 +65,33 @@
@@ -60,10 +65,54 @@

if (iinventory != null)
{
Expand All @@ -38,7 +38,28 @@
+ }
+ else
+ {
+ destinationInventory = iinventory.getOwner().getInventory();
+ // Crucible start - support mod inventories, with no owners
+ try {
+
+ if (iinventory.getOwner().getInventory() != null) {
+ destinationInventory = iinventory.getOwner().getInventory();
+ } else {
+ // TODO: create a mod inventory for passing to the event, instead of null
+ destinationInventory = null;
+ }
+ } catch (AbstractMethodError e) { // fixes openblocks AbstractMethodError
+ if (iinventory instanceof TileEntity) {
+ org.bukkit.inventory.InventoryHolder holder = net.minecraftforge.cauldron.CauldronUtils.getOwner((net.minecraft.tileentity.TileEntity)iinventory);
+ if (holder != null) {
+ destinationInventory = holder.getInventory();
+ } else {
+ destinationInventory = null;
+ }
+ } else {
+ destinationInventory = null;
+ }
+ }
+ // Crucible end
+ }
+
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
Expand All @@ -56,4 +77,4 @@
+ // CraftBukkit end
itemstack1 = itemstack.copy();

if (--itemstack1.stackSize == 0)
if (--itemstack1.stackSize == 0)

0 comments on commit 723ca5e

Please sign in to comment.