Skip to content

Commit c66505c

Browse files
authored
Merge pull request #193 from Circulate233/master
fix:修复机械输出总线在刚放置时所有Slot堆叠上限均为0的问题
2 parents 9e0dd1f + b80e738 commit c66505c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/main/java/github/kasuminova/mmce/common/network/PktMEOutputBusStackSizeChange.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ public IMessage onMessage(final PktMEOutputBusStackSizeChange message, final Mes
4040
player.getServerWorld().addScheduledTask(() -> {
4141
TileEntity te = player.world.getTileEntity(message.pos);
4242

43-
if (!(te instanceof MEItemOutputBus)) {
43+
if (!(te instanceof MEItemOutputBus outputBus)) {
4444
return;
4545
}
4646

47-
MEItemOutputBus outputBus = (MEItemOutputBus) te;
48-
4947
int validatedStackSize = Math.max(1, message.stackSize);
5048

5149
outputBus.setConfiguredStackSize(validatedStackSize);

src/main/java/github/kasuminova/mmce/common/tile/MEItemOutputBus.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
public class MEItemOutputBus extends MEItemBus implements SettingsTransfer {
2323

24-
private int configuredStackSize = Integer.MAX_VALUE;
24+
private int configuredStackSize;
2525

2626
@Override
2727
public IOInventory buildInventory() {
@@ -31,7 +31,8 @@ public IOInventory buildInventory() {
3131
for (int slotID = 0; slotID < slotIDs.length; slotID++) {
3232
slotIDs[slotID] = slotID;
3333
}
34-
IOInventory inv = new IOInventory(this, new int[]{}, slotIDs);
34+
IOInventory inv = new IOInventory(this, new int[0], slotIDs);
35+
configuredStackSize = Integer.MAX_VALUE;
3536
inv.setStackLimit(this.configuredStackSize, slotIDs);
3637
inv.setListener(slot -> {
3738
synchronized (this) {

src/main/java/hellfirepvp/modularmachinery/common/util/IOInventory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import javax.annotation.Nonnull;
2323
import java.util.concurrent.locks.ReadWriteLock;
2424
import java.util.concurrent.locks.ReentrantReadWriteLock;
25-
import java.util.function.Consumer;
25+
import java.util.function.IntConsumer;
2626

2727
/**
2828
* This class is part of the Modular Machinery Mod
@@ -37,7 +37,7 @@ public class IOInventory extends IItemHandlerImpl implements ReadWriteLockProvid
3737

3838
private final TileEntitySynchronized owner;
3939
// TODO IntConsumer.
40-
private Consumer<Integer> listener = null;
40+
private IntConsumer listener = null;
4141

4242
private IOInventory(TileEntitySynchronized owner) {
4343
this.owner = owner;
@@ -58,7 +58,7 @@ public static IOInventory deserialize(TileEntitySynchronized owner, NBTTagCompou
5858
return inv;
5959
}
6060

61-
public IOInventory setListener(Consumer<Integer> listener) {
61+
public IOInventory setListener(IntConsumer listener) {
6262
this.listener = listener;
6363
return this;
6464
}

0 commit comments

Comments
 (0)