Skip to content

Commit 8ecfcf9

Browse files
committed
Fix redstone control modules getting consumed when applying in creative mode
1 parent 51faadc commit 8ecfcf9

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

src/main/java/aztech/modern_industrialization/machines/components/CasingComponent.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ public ItemInteractionResult onUse(MachineBlockEntity be, Player player, Interac
114114
dropCasing(be.getLevel(), be.getBlockPos());
115115
}
116116
setCasingStack(stackInHand.copyWithCount(1));
117-
if (!player.isCreative()) {
118-
stackInHand.shrink(1);
119-
}
117+
stackInHand.consume(1, player);
120118
be.setChanged();
121119
if (!be.getLevel().isClientSide()) {
122120
be.sync();

src/main/java/aztech/modern_industrialization/machines/components/OverdriveComponent.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ public ItemInteractionResult onUse(MachineBlockEntity be, Player player, Interac
6161
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
6262
}
6363
if (MIItem.OVERDRIVE_MODULE.is(stackInHand) && overdriveModule.isEmpty()) {
64-
overdriveModule = stackInHand.copy();
65-
overdriveModule.setCount(1);
66-
stackInHand.shrink(1);
64+
overdriveModule = stackInHand.copyWithCount(1);
65+
stackInHand.consume(1, player);
6766

6867
be.setChanged();
6968
return ItemInteractionResult.sidedSuccess(player.level().isClientSide);

src/main/java/aztech/modern_industrialization/machines/components/RedstoneControlComponent.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ public ItemInteractionResult onUse(MachineBlockEntity be, Player player, Interac
6666
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
6767
}
6868
if (MIItem.REDSTONE_CONTROL_MODULE.is(stackInHand) && controlModule.isEmpty()) {
69-
controlModule = stackInHand.copy();
70-
controlModule.setCount(1);
71-
stackInHand.shrink(1);
69+
controlModule = stackInHand.copyWithCount(1);
70+
stackInHand.consume(1, player);
7271

7372
be.setChanged();
7473
return ItemInteractionResult.sidedSuccess(player.level().isClientSide);

src/main/java/aztech/modern_industrialization/machines/components/UpgradeComponent.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ public ItemInteractionResult onUse(MachineBlockEntity be, Player player, Interac
7676
int maxAdded = Math.min(stackInHand.getCount(), itemStack.getMaxStackSize() - itemStack.getCount());
7777
changed = maxAdded > 0;
7878
itemStack.grow(maxAdded);
79-
if (!player.isCreative()) {
80-
stackInHand.shrink(maxAdded);
81-
}
79+
stackInHand.consume(maxAdded, player);
8280
}
8381
if (changed) {
8482
be.setChanged();

0 commit comments

Comments
 (0)