mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-11-17 19:05:01 +00:00
Change virtual slot updating (#68)
This commit is contained in:
1 parent
cebb8b6d94
commit
14b41ee7d4
3 files changed
+12
-12
No files matched your search
@@ -135,7 +135,7 @@ public class PacketNEIPatternRecipe implements IMessage {
|
||||
list.put(i, aes);
|
||||
}
|
||||
|
||||
container.receiveSlotStacks(StorageName.CRAFTING_INPUT, list);
|
||||
updateVirtualSlots(container, StorageName.CRAFTING_INPUT, list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,8 +193,15 @@ public class PacketNEIPatternRecipe implements IMessage {
|
||||
}
|
||||
|
||||
container.clear();
|
||||
container.receiveSlotStacks(StorageName.CRAFTING_INPUT, input);
|
||||
container.receiveSlotStacks(StorageName.CRAFTING_OUTPUT, output);
|
||||
updateVirtualSlots(container, StorageName.CRAFTING_INPUT, input);
|
||||
updateVirtualSlots(container, StorageName.CRAFTING_OUTPUT, output);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVirtualSlots(ContainerPatternTerm container, StorageName storageName,
|
||||
Int2ObjectOpenHashMap<IAEStack<?>> stacks) {
|
||||
for (var entry : stacks.int2ObjectEntrySet()) {
|
||||
container.updateVirtualSlot(storageName, entry.getIntKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.github.vfyjxf.nee.NotEnoughEnergistics;
|
||||
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
@@ -73,11 +72,9 @@ public class PacketSlotStackChange implements IMessage {
|
||||
@Override
|
||||
public IMessage onMessage(PacketSlotStackChange message, MessageContext ctx) {
|
||||
if (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerPatternTerm cpt) {
|
||||
final Int2ObjectMap<IAEStack<?>> temp = new Int2ObjectOpenHashMap<>();
|
||||
for (Int2ObjectMap.Entry<IAEItemStack> entry : message.getSlotStacks().int2ObjectEntrySet()) {
|
||||
temp.put(entry.getIntKey(), entry.getValue());
|
||||
cpt.updateVirtualSlot(StorageName.CRAFTING_INPUT, entry.getIntKey(), entry.getValue());
|
||||
}
|
||||
cpt.receiveSlotStacks(StorageName.CRAFTING_INPUT, temp);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
/**
|
||||
* @author vfyjxf
|
||||
@@ -73,10 +71,8 @@ public class PacketStackCountChange implements IMessage {
|
||||
.getAEStackInSlot(message.getSlotIndex());
|
||||
if (aes != null) {
|
||||
final IAEStack<?> newAes = aes.copy();
|
||||
final Int2ObjectMap<IAEStack<?>> temp = new Int2ObjectOpenHashMap<>();
|
||||
newAes.setStackSize(Math.max(1, aes.getStackSize() + message.getChangeCount()));
|
||||
temp.put(message.getSlotIndex(), newAes);
|
||||
cpt.receiveSlotStacks(message.getStorageName(), temp);
|
||||
cpt.updateVirtualSlot(message.getStorageName(), message.getSlotIndex(), newAes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user