Skip to content

Commit

Permalink
Don't try to cfinditem inside blocked shulker boxes. Closes #219
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed May 19, 2024
1 parent 59199d0 commit c715f43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.ShulkerBoxBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.ChestType;
import net.minecraft.world.level.chunk.LevelChunk;
Expand Down Expand Up @@ -242,15 +244,16 @@ private boolean canSearch(Level level, BlockPos pos) {
BlockEntity blockEntity = level.getBlockEntity(pos);
if (!(blockEntity instanceof Container) && state.getBlock() != Blocks.ENDER_CHEST) {
return false;
}
if (state.getBlock() instanceof ChestBlock || state.getBlock() == Blocks.ENDER_CHEST) {
} else if (state.getBlock() instanceof ChestBlock || state.getBlock() == Blocks.ENDER_CHEST) {
if (ChestBlock.isChestBlockedAt(level, pos)) {
return false;
}
if (state.getBlock() instanceof ChestBlock && state.getValue(ChestBlock.TYPE) != ChestType.SINGLE) {
BlockPos offsetPos = pos.relative(ChestBlock.getConnectedDirection(state));
return level.getBlockState(offsetPos).getBlock() != state.getBlock() || !ChestBlock.isChestBlockedAt(level, offsetPos);
}
} else if (state.getBlock() instanceof ShulkerBoxBlock && blockEntity instanceof ShulkerBoxBlockEntity shulkerBox) {
return ShulkerBoxBlock.canOpen(state, level, pos, shulkerBox);
}
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/clientcommands.aw
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ accessible field net/minecraft/client/DebugQueryHandler transactionId I

# cfinditem
accessible field net/minecraft/world/inventory/AbstractContainerMenu menuType Lnet/minecraft/world/inventory/MenuType;
accessible method net/minecraft/world/level/block/ShulkerBoxBlock canOpen (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/ShulkerBoxBlockEntity;)Z

# cfish
accessible method net/minecraft/world/entity/projectile/FishingHook canHitEntity (Lnet/minecraft/world/entity/Entity;)Z
Expand Down

0 comments on commit c715f43

Please sign in to comment.