Skip to content

Commit

Permalink
🐛 Fixed quarry screen staying open, even when the block is destroyed …
Browse files Browse the repository at this point in the history
…or too far away.
  • Loading branch information
RXJpaw committed Jul 7, 2024
1 parent 0a8a733 commit 282e030
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ public QuarryBlock getQuarryBlock(){
}
}

public boolean canPlayerUse(PlayerEntity player) {
if (this.world != null && this.world.getBlockEntity(this.pos) != this) {
return false;
} else {
return player.squaredDistanceTo((double)this.pos.getX() + 0.5, (double)this.pos.getY() + 0.5, (double)this.pos.getZ() + 0.5) <= 64.0;
}
}

@Override
public void markRemoved() {
if(world == null) return;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/pw/rxj/iron_quarry/util/QuarryInventory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pw.rxj.iron_quarry.util;

import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import pw.rxj.iron_quarry.blockentity.QuarryBlockEntity;
Expand All @@ -23,6 +24,13 @@ private ReferencedQuarryInventory(int size, @Nullable QuarryBlockEntity ref) {
return this.ref;
}

@Override
public boolean canPlayerUse(PlayerEntity player) {
QuarryBlockEntity quarryBlockEntity = this.ref();

return quarryBlockEntity != null && quarryBlockEntity.canPlayerUse(player);
}

@Override
public void markDirty() {
if(ref == null) return;
Expand Down

0 comments on commit 282e030

Please sign in to comment.