Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,26 @@
BlockState newState = state.setValue(POWERED, signal);
if (!signal) {
newState = newState.setValue(SIDE_CHAIN_PART, SideChainPart.UNCONNECTED);
@@ -162,7 +_,7 @@
final InteractionHand hand,
final BlockHitResult hitResult
) {
- if (level.getBlockEntity(pos) instanceof ShelfBlockEntity shelfBlockEntity && !hand.equals(InteractionHand.OFF_HAND)) {
+ if (level.getBlockEntity(pos) instanceof ShelfBlockEntity shelfBlockEntity) {
OptionalInt hitSlot = this.getHitSlot(hitResult, state.getValue(FACING));
if (hitSlot.isEmpty()) {
return InteractionResult.PASS;
@@ -227,11 +_,10 @@
boolean anySwapped = false;

for (int shelfPartIndex = 0; shelfPartIndex < connectedBlocks.size(); shelfPartIndex++) {
- ShelfBlockEntity shelfPart = (ShelfBlockEntity)level.getBlockEntity(connectedBlocks.get(shelfPartIndex));
- if (shelfPart != null) {
+ if (level.getBlockEntity(connectedBlocks.get(shelfPartIndex)) instanceof ShelfBlockEntity shelfPart) {
for (int slot = 0; slot < shelfPart.getContainerSize(); slot++) {
int inventorySlot = 9 - (connectedBlocks.size() - shelfPartIndex) * shelfPart.getContainerSize() + slot;
- if (inventorySlot >= 0 && inventorySlot <= inventory.getContainerSize()) {
+ if (inventorySlot >= 0 && inventorySlot < inventory.getContainerSize()) {
ItemStack placedInventoryItem = inventory.removeItemNoUpdate(inventorySlot);
ItemStack removedShelfItem = shelfPart.swapItemNoUpdate(slot, placedInventoryItem);
if (!placedInventoryItem.isEmpty() || !removedShelfItem.isEmpty()) {