Integrate stack size logic directly into SlotPattern

This commit is contained in:
abel1502 2025-06-01 19:29:01 +03:00
parent d890443150
commit 8d7664f728
No known key found for this signature in database
GPG Key ID: 076926596A536338
11 changed files with 20 additions and 66 deletions

View File

@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotPattern extends Slot {
@ -24,6 +25,15 @@ public class SlotPattern extends Slot {
return 1;
}
@Override
public void putStack(ItemStack stack) {
if (stack != null) {
stack = stack.copy();
stack.stackSize = 1;
}
super.putStack(stack);
}
public SlotPattern disableHover() {
this.canHover = false;
return this;

View File

@ -74,13 +74,7 @@ public class ContainerAutocrafter extends ContainerBase {
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
autocrafter.matcher.initPatternSmart(autocrafter.getWorldObj(), slot.getStack(), index);
autocrafter.updateTemplateGrid();

View File

@ -66,13 +66,7 @@ public class ContainerCartDestroyer extends Container {
if(slot.getHasStack())
ret = slot.getStack().copy();
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
return ret;
}

View File

@ -48,13 +48,7 @@ public class ContainerCounterTorch extends ContainerBase {
return ret;
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
radio.matcher.initPatternStandard(radio.getWorldObj(), slot.getStack(), index);
return ret;

View File

@ -105,13 +105,7 @@ public class ContainerCraneExtractor extends ContainerBase {
return ret;
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
extractor.matcher.initPatternStandard(extractor.getWorldObj(), slot.getStack(), index);
return ret;

View File

@ -100,13 +100,7 @@ public class ContainerCraneGrabber extends ContainerBase {
return ret;
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
grabber.matcher.initPatternStandard(grabber.getWorldObj(), slot.getStack(), index);
return ret;

View File

@ -52,13 +52,7 @@ public class ContainerCraneRouter extends ContainerBase {
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
router.initPattern(slot.getStack(), index);
return ret;

View File

@ -85,13 +85,7 @@ public class ContainerDroneRequester extends ContainerCrateBase {
return ret;
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
requester.matcher.initPatternStandard(requester.getWorldObj(), slot.getStack(), index);
return ret;

View File

@ -94,13 +94,7 @@ public class ContainerMachineCustom extends Container {
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
custom.matcher.initPatternSmart(player.worldObj, slot.getStack(), index - 10);
return ret;

View File

@ -79,13 +79,7 @@ public class ContainerMassStorage extends ContainerBase {
if(storage.getStockpile() > 0)
return ret;
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) {
slot.getStack().stackSize = 1;
}
slot.onSlotChanged();
slot.putStack(held);
return ret;
}

View File

@ -39,9 +39,7 @@ public class ContainerPneumoTube extends ContainerBase {
tube.nextMode(index);
return ret;
} else {
slot.putStack(held != null ? held.copy() : null);
if(slot.getHasStack()) slot.getStack().stackSize = 1;
slot.onSlotChanged();
slot.putStack(held);
tube.initPattern(slot.getStack(), index);
return ret;
}