Skip to content

Commit 671ac79

Browse files
committed
Consider full blocks preventing item entity interaction in hopper sleeping
1 parent ea118fa commit 671ac79

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Diff for: common/src/main/java/net/caffeinemc/mods/lithium/mixin/block/hopper/HopperBlockEntityMixin.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.minecraft.core.BlockPos;
1616
import net.minecraft.core.Direction;
1717
import net.minecraft.server.level.ServerLevel;
18+
import net.minecraft.tags.BlockTags;
1819
import net.minecraft.world.CompoundContainer;
1920
import net.minecraft.world.Container;
2021
import net.minecraft.world.WorldlyContainer;
@@ -717,7 +718,7 @@ private static void checkSleepingConditions(Level world, BlockPos pos, BlockStat
717718
}
718719

719720
private void checkSleepingConditions() {
720-
if (this.isOnCooldown()) {
721+
if (this.isOnCooldown() || this.getLevel() == null) {
721722
return;
722723
}
723724
if (this instanceof SleepingBlockEntity thisSleepingBlockEntity) {
@@ -732,6 +733,7 @@ private void checkSleepingConditions() {
732733
boolean listenToExtractTracker = false;
733734
boolean listenToInsertTracker = false;
734735
boolean listenToExtractEntities = false;
736+
boolean listenToItemEntities = false;
735737
boolean listenToInsertEntities = false;
736738

737739
LithiumStackList thisStackList = InventoryHelper.getLithiumStackList(this);
@@ -755,6 +757,12 @@ private void checkSleepingConditions() {
755757
return;
756758
}
757759
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+
}
758766
} else {
759767
return;
760768
}
@@ -795,11 +803,15 @@ private void checkSleepingConditions() {
795803
return;
796804
}
797805
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 {
799811
return;
800812
}
801-
this.collectItemEntityTracker.listenToEntityMovementOnce(this);
802813
}
814+
803815
thisTracker.listenForContentChangesOnce(thisStackList, this);
804816
thisSleepingBlockEntity.lithium$startSleeping();
805817
}

0 commit comments

Comments
 (0)