@@ -601,9 +601,12 @@ private Either<Player.BedSleepingProblem, Unit> getBedResult(BlockPos blockposit
601601 if (container != null ) {
602602 ((ContainerBridge ) container ).bridge$setTitle (iTileInventory .getDisplayName ());
603603 boolean cancelled = false ;
604- ArclightCaptures .captureContainerOwner ((ServerPlayer ) (Object ) this );
605- container = CraftEventFactory .callInventoryOpenEvent ((ServerPlayer ) (Object ) this , container , cancelled );
606- ArclightCaptures .popContainerOwner ((ServerPlayer ) (Object ) this );
604+ try {
605+ ArclightCaptures .captureContainerOwner ((ServerPlayer ) (Object ) this );
606+ container = CraftEventFactory .callInventoryOpenEvent ((ServerPlayer ) (Object ) this , container , cancelled );
607+ } finally {
608+ ArclightCaptures .popContainerOwner ((ServerPlayer ) (Object ) this );
609+ }
607610 if (container == null && !cancelled ) {
608611 if (iTileInventory instanceof Container ) {
609612 ((Container ) iTileInventory ).stopOpen ((ServerPlayer ) (Object ) this );
@@ -637,9 +640,12 @@ private Either<Player.BedSleepingProblem, Unit> getBedResult(BlockPos blockposit
637640 @ Inject (method = "doCloseContainer" , at = @ At ("HEAD" ))
638641 private void arclight$invClose (CallbackInfo ci ) {
639642 if (this .containerMenu != this .inventoryMenu ) {
640- ArclightCaptures .captureContainerOwner ((ServerPlayer ) (Object ) this );
641- CraftEventFactory .handleInventoryCloseEvent ((ServerPlayer ) (Object ) this );
642- ArclightCaptures .popContainerOwner ((ServerPlayer ) (Object ) this );
643+ try {
644+ ArclightCaptures .captureContainerOwner ((ServerPlayer ) (Object ) this );
645+ CraftEventFactory .handleInventoryCloseEvent ((ServerPlayer ) (Object ) this );
646+ } finally {
647+ ArclightCaptures .popContainerOwner ((ServerPlayer ) (Object ) this );
648+ }
643649 }
644650 }
645651
0 commit comments