From 6b34f063246eb212114719791ea690defcc3f842 Mon Sep 17 00:00:00 2001 From: Boblet Date: Fri, 12 Jan 2024 14:20:34 +0100 Subject: [PATCH] faster chemplant ejector --- changelog | 1 + .../items/machine/ItemAssemblyTemplate.java | 2 +- .../machine/TileEntityMachineChemplant.java | 69 ++++++++++-------- .../TileEntityMachineChemplantBase.java | 72 ++++++++++--------- 4 files changed, 81 insertions(+), 63 deletions(-) diff --git a/changelog b/changelog index fdc381f0e..6fb4ecbcd 100644 --- a/changelog +++ b/changelog @@ -19,3 +19,4 @@ * Fixed PWR fuel rods not having any radiation value assigned to them * Fixed trenchmaster helmet not having gas mask protection * Fixed large thermobaric artillery rocket still using the wrong slag block +* Fixed some of the assembly templates having broken names due to using the wrong way of translating the output diff --git a/src/main/java/com/hbm/items/machine/ItemAssemblyTemplate.java b/src/main/java/com/hbm/items/machine/ItemAssemblyTemplate.java index 6c338eec9..a25a54983 100644 --- a/src/main/java/com/hbm/items/machine/ItemAssemblyTemplate.java +++ b/src/main/java/com/hbm/items/machine/ItemAssemblyTemplate.java @@ -106,7 +106,7 @@ public class ItemAssemblyTemplate extends Item { return EnumChatFormatting.RED + "Broken Template" + EnumChatFormatting.RESET; } - String s1 = ("" + StatCollector.translateToLocal(out.getUnlocalizedName() + ".name")).trim(); + String s1 = out.getDisplayName().trim(); if(s1 != null) { s = s + " " + s1; diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java index 00523e45b..3c421facd 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java @@ -428,41 +428,50 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements ISidedInventory sided = inv instanceof ISidedInventory ? (ISidedInventory) inv : null; int[] access = sided != null ? sided.getAccessibleSlotsFromSide(dir.ordinal()) : null; - for(int i = 5; i <= 8; i++) { - - ItemStack out = slots[i]; - - if(out != null) { + boolean shouldOutput = true; + + while(shouldOutput) { + shouldOutput = false; + outer: + for(int i = 5; i <= 8; i++) { - for(int j = 0; j < (access != null ? access.length : inv.getSizeInventory()); j++) { - - int slot = access != null ? access[j] : j; + ItemStack out = slots[i]; + + if(out != null) { - if(!inv.isItemValidForSlot(slot, out)) - continue; + for(int j = 0; j < (access != null ? access.length : inv.getSizeInventory()); j++) { + + int slot = access != null ? access[j] : j; - ItemStack target = inv.getStackInSlot(slot); - - if(InventoryUtil.doesStackDataMatch(out, target) && target.stackSize < target.getMaxStackSize()) { - this.decrStackSize(i, 1); - target.stackSize++; - return; + if(!inv.isItemValidForSlot(slot, out)) + continue; + + ItemStack target = inv.getStackInSlot(slot); + + if(InventoryUtil.doesStackDataMatch(out, target) && target.stackSize < Math.min(target.getMaxStackSize(), inv.getInventoryStackLimit())) { + int toDec = Math.min(out.stackSize, Math.min(target.getMaxStackSize(), inv.getInventoryStackLimit()) - target.stackSize); + this.decrStackSize(i, toDec); + target.stackSize += toDec; + shouldOutput = true; + break outer; + } } - } - - for(int j = 0; j < (access != null ? access.length : inv.getSizeInventory()); j++) { - - int slot = access != null ? access[j] : j; - if(!inv.isItemValidForSlot(slot, out)) - continue; - - if(inv.getStackInSlot(slot) == null && (sided != null ? sided.canInsertItem(slot, out, dir.ordinal()) : inv.isItemValidForSlot(slot, out))) { - ItemStack copy = out.copy(); - copy.stackSize = 1; - inv.setInventorySlotContents(slot, copy); - this.decrStackSize(i, 1); - return; + for(int j = 0; j < (access != null ? access.length : inv.getSizeInventory()); j++) { + + int slot = access != null ? access[j] : j; + + if(!inv.isItemValidForSlot(slot, out)) + continue; + + if(inv.getStackInSlot(slot) == null && (sided != null ? sided.canInsertItem(slot, out, dir.ordinal()) : inv.isItemValidForSlot(slot, out))) { + ItemStack copy = out.copy(); + copy.stackSize = 1; + inv.setInventorySlotContents(slot, copy); + this.decrStackSize(i, 1); + shouldOutput = true; + break outer; + } } } } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantBase.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantBase.java index 129a665fd..162a456f2 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantBase.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplantBase.java @@ -271,42 +271,50 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa IInventory inv = (IInventory) te; ISidedInventory sided = inv instanceof ISidedInventory ? (ISidedInventory) inv : null; int[] access = sided != null ? sided.getAccessibleSlotsFromSide(coord.getDir().ordinal()) : null; - - for(int i = indices[2]; i <= indices[3]; i++) { - - ItemStack out = slots[i]; - - if(out != null) { - - for(int j = 0; j < (access != null ? access.length : inv.getSizeInventory()); j++) { - int slot = access != null ? access[j] : j; + boolean shouldOutput = true; + while(shouldOutput) { + shouldOutput = false; + outer: + for(int i = indices[2]; i <= indices[3]; i++) { + + ItemStack out = slots[i]; + + if(out != null) { - if(!inv.isItemValidForSlot(slot, out)) - continue; - - ItemStack target = inv.getStackInSlot(slot); - - if(InventoryUtil.doesStackDataMatch(out, target) && target.stackSize < target.getMaxStackSize() && target.stackSize < inv.getInventoryStackLimit()) { - this.decrStackSize(i, 1); - target.stackSize++; - return; + for(int j = 0; j < (access != null ? access.length : inv.getSizeInventory()); j++) { + + int slot = access != null ? access[j] : j; + + if(!inv.isItemValidForSlot(slot, out)) + continue; + + ItemStack target = inv.getStackInSlot(slot); + + if(InventoryUtil.doesStackDataMatch(out, target) && target.stackSize < target.getMaxStackSize() && target.stackSize < inv.getInventoryStackLimit()) { + int toDec = Math.min(out.stackSize, Math.min(target.getMaxStackSize(), inv.getInventoryStackLimit()) - target.stackSize); + this.decrStackSize(i, toDec); + target.stackSize += toDec; + shouldOutput = true; + break outer; + } } - } - - for(int j = 0; j < (access != null ? access.length : inv.getSizeInventory()); j++) { - - int slot = access != null ? access[j] : j; - if(!inv.isItemValidForSlot(slot, out)) - continue; - - if(inv.getStackInSlot(slot) == null && (sided != null ? sided.canInsertItem(slot, out, coord.getDir().ordinal()) : inv.isItemValidForSlot(slot, out))) { - ItemStack copy = out.copy(); - copy.stackSize = 1; - inv.setInventorySlotContents(slot, copy); - this.decrStackSize(i, 1); - return; + for(int j = 0; j < (access != null ? access.length : inv.getSizeInventory()); j++) { + + int slot = access != null ? access[j] : j; + + if(!inv.isItemValidForSlot(slot, out)) + continue; + + if(inv.getStackInSlot(slot) == null && (sided != null ? sided.canInsertItem(slot, out, coord.getDir().ordinal()) : inv.isItemValidForSlot(slot, out))) { + ItemStack copy = out.copy(); + copy.stackSize = 1; + inv.setInventorySlotContents(slot, copy); + this.decrStackSize(i, 1); + shouldOutput = true; + break outer; + } } } }