15
15
import net .minecraft .core .BlockPos ;
16
16
import net .minecraft .core .Direction ;
17
17
import net .minecraft .server .level .ServerLevel ;
18
+ import net .minecraft .tags .BlockTags ;
18
19
import net .minecraft .world .CompoundContainer ;
19
20
import net .minecraft .world .Container ;
20
21
import net .minecraft .world .WorldlyContainer ;
@@ -717,7 +718,7 @@ private static void checkSleepingConditions(Level world, BlockPos pos, BlockStat
717
718
}
718
719
719
720
private void checkSleepingConditions () {
720
- if (this .isOnCooldown ()) {
721
+ if (this .isOnCooldown () || this . getLevel () == null ) {
721
722
return ;
722
723
}
723
724
if (this instanceof SleepingBlockEntity thisSleepingBlockEntity ) {
@@ -732,6 +733,7 @@ private void checkSleepingConditions() {
732
733
boolean listenToExtractTracker = false ;
733
734
boolean listenToInsertTracker = false ;
734
735
boolean listenToExtractEntities = false ;
736
+ boolean listenToItemEntities = false ;
735
737
boolean listenToInsertEntities = false ;
736
738
737
739
LithiumStackList thisStackList = InventoryHelper .getLithiumStackList (this );
@@ -755,6 +757,12 @@ private void checkSleepingConditions() {
755
757
return ;
756
758
}
757
759
listenToExtractEntities = true ;
760
+
761
+ BlockPos blockPos = this .getBlockPos ().above ();
762
+ BlockState blockState = this .getLevel ().getBlockState (blockPos );
763
+ if (!blockState .isCollisionShapeFullBlock (this .getLevel (), blockPos ) || blockState .is (BlockTags .DOES_NOT_BLOCK_HOPPERS )) {
764
+ listenToItemEntities = true ;
765
+ }
758
766
} else {
759
767
return ;
760
768
}
@@ -795,11 +803,15 @@ private void checkSleepingConditions() {
795
803
return ;
796
804
}
797
805
this .extractInventoryEntityTracker .listenToEntityMovementOnce (this );
798
- if (this .collectItemEntityTracker == null ) {
806
+ }
807
+ if (listenToItemEntities ) {
808
+ if (this .collectItemEntityTracker != null ) {
809
+ this .collectItemEntityTracker .listenToEntityMovementOnce (this );
810
+ } else {
799
811
return ;
800
812
}
801
- this .collectItemEntityTracker .listenToEntityMovementOnce (this );
802
813
}
814
+
803
815
thisTracker .listenForContentChangesOnce (thisStackList , this );
804
816
thisSleepingBlockEntity .lithium$startSleeping ();
805
817
}
0 commit comments