Skip to content

Commit

Permalink
Fix redstone control modules getting consumed when applying in creati…
Browse files Browse the repository at this point in the history
…ve mode (#958)
  • Loading branch information
Swedz authored Dec 12, 2024
1 parent 51faadc commit 5847e58
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ public ItemInteractionResult onUse(MachineBlockEntity be, Player player, Interac
dropCasing(be.getLevel(), be.getBlockPos());
}
setCasingStack(stackInHand.copyWithCount(1));
if (!player.isCreative()) {
stackInHand.shrink(1);
}
stackInHand.consume(1, player);
be.setChanged();
if (!be.getLevel().isClientSide()) {
be.sync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ public ItemInteractionResult onUse(MachineBlockEntity be, Player player, Interac
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
if (MIItem.OVERDRIVE_MODULE.is(stackInHand) && overdriveModule.isEmpty()) {
overdriveModule = stackInHand.copy();
overdriveModule.setCount(1);
stackInHand.shrink(1);
overdriveModule = stackInHand.copyWithCount(1);
stackInHand.consume(1, player);

be.setChanged();
return ItemInteractionResult.sidedSuccess(player.level().isClientSide);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ public ItemInteractionResult onUse(MachineBlockEntity be, Player player, Interac
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
}
if (MIItem.REDSTONE_CONTROL_MODULE.is(stackInHand) && controlModule.isEmpty()) {
controlModule = stackInHand.copy();
controlModule.setCount(1);
stackInHand.shrink(1);
controlModule = stackInHand.copyWithCount(1);
stackInHand.consume(1, player);

be.setChanged();
return ItemInteractionResult.sidedSuccess(player.level().isClientSide);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ public ItemInteractionResult onUse(MachineBlockEntity be, Player player, Interac
int maxAdded = Math.min(stackInHand.getCount(), itemStack.getMaxStackSize() - itemStack.getCount());
changed = maxAdded > 0;
itemStack.grow(maxAdded);
if (!player.isCreative()) {
stackInHand.shrink(maxAdded);
}
stackInHand.consume(maxAdded, player);
}
if (changed) {
be.setChanged();
Expand Down

0 comments on commit 5847e58

Please sign in to comment.