mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Make mass storage process output instantly
Same deal as previously, this bypasses the bottleneck of tile entity ticking and network latency. This change is less relevant than the previous one, because there shift-dragging or shift-double-clicking were possible with mods, while here it only really affects autoclickers. Still, it can't hurt
This commit is contained in:
parent
a6740a35e9
commit
7ef016ccce
@ -31,6 +31,11 @@ public class ContainerMassStorage extends ContainerBase {
|
||||
ItemStack result = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
// Refill instantly if needed, then do regular slot behavior
|
||||
if(index == 2 && slot != null && !slot.getHasStack()) {
|
||||
slot.putStack(storage.quickExtract());
|
||||
}
|
||||
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack initial = slot.getStack();
|
||||
result = initial.copy();
|
||||
@ -41,7 +46,7 @@ public class ContainerMassStorage extends ContainerBase {
|
||||
}
|
||||
} else {
|
||||
// Try to insert instantly, then fall back to regular slot behavior
|
||||
if(!storage.insert(initial) && !this.mergeItemStack(initial, 0, 1, false)) {
|
||||
if(!storage.quickInsert(initial) && !this.mergeItemStack(initial, 0, 1, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa
|
||||
return getType() != null && getStockpile() < getCapacity() && stack != null && stack.isItemEqual(getType()) && ItemStack.areItemStackTagsEqual(stack, getType());
|
||||
}
|
||||
|
||||
public boolean insert(ItemStack stack) {
|
||||
public boolean quickInsert(ItemStack stack) {
|
||||
if (!canInsert(stack))
|
||||
return false;
|
||||
|
||||
@ -115,6 +115,24 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack quickExtract() {
|
||||
if (!output) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int amount = getType().getMaxStackSize();
|
||||
|
||||
if (getStockpile() < amount)
|
||||
return null;
|
||||
|
||||
ItemStack result = slots[1].copy();
|
||||
result.stackSize = amount;
|
||||
this.stack -= amount;
|
||||
this.markDirty();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf buf) {
|
||||
buf.writeInt(this.stack);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user