ow my leg

This commit is contained in:
Boblet 2026-04-01 13:36:59 +02:00
parent 832ddfe600
commit b21e6ab56e
3 changed files with 37 additions and 9 deletions

View File

@ -1,7 +1,8 @@
package api.hbm.ntl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
@ -11,7 +12,7 @@ import net.minecraft.nbt.NBTTagCompound;
public class StorageManifest {
public HashMap<Integer, MetaNode> itemMeta = new HashMap();
public LinkedHashMap<Integer, MetaNode> itemMeta = new LinkedHashMap();
public void writeStack(ItemStack stack) {
int id = Item.getIdFromItem(stack.getItem());
@ -38,7 +39,7 @@ public class StorageManifest {
nbt.nbtAmount.put(compound, amount);
}
public List<StorageStack> getStacks() {
public List<StorageStack> getStacks(boolean sorted) {
List<StorageStack> stacks = new ArrayList();
for(Entry<Integer, MetaNode> itemNode : itemMeta.entrySet()) {
@ -53,16 +54,16 @@ public class StorageManifest {
}
}
if(sorted) Collections.sort(stacks);
return stacks;
}
public class MetaNode {
public HashMap<Integer, NBTNode> metaNBT = new HashMap();
public LinkedHashMap<Integer, NBTNode> metaNBT = new LinkedHashMap();
}
public class NBTNode {
public HashMap<NBTTagCompound, Long> nbtAmount = new HashMap();
public LinkedHashMap<NBTTagCompound, Long> nbtAmount = new LinkedHashMap();
}
}

View File

@ -1,14 +1,17 @@
package api.hbm.ntl;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class StorageStack {
public class StorageStack implements Comparable {
private int cachedItemId;
private ItemStack type;
private long amount;
public StorageStack(ItemStack type) {
this(type, type.stackSize);
this.cachedItemId = Item.getIdFromItem(type.getItem());
}
public StorageStack(ItemStack type, long amount) {
@ -24,4 +27,27 @@ public class StorageStack {
public long getAmount() {
return this.amount;
}
@Override
public int compareTo(Object o) {
StorageStack other = (StorageStack) o;
if(this.cachedItemId < other.cachedItemId) return -1;
if(this.cachedItemId > other.cachedItemId) return 1;
if(this.type.getItemDamage() < other.type.getItemDamage()) return -1;
if(this.type.getItemDamage() > other.type.getItemDamage()) return 1;
if(this.type.hasTagCompound() && !other.type.hasTagCompound()) return -1;
if(!this.type.hasTagCompound() && other.type.hasTagCompound()) return 1;
if(this.type.hasTagCompound() && other.type.hasTagCompound()) {
// keyset size comparison should hopefully catch most of the larger NBT cases
if(this.type.stackTagCompound.func_150296_c().size() < other.type.stackTagCompound.func_150296_c().size()) return -1;
if(this.type.stackTagCompound.func_150296_c().size() > other.type.stackTagCompound.func_150296_c().size()) return 1;
int comp = this.type.stackTagCompound.toString().compareTo(other.type.stackTagCompound.toString()); // not terribly performant but hopefully not that common
if(comp != 0) return comp;
}
if(this.type.stackSize < other.type.stackSize) return -1;
if(this.type.stackSize > other.type.stackSize) return 1;
return 0;
}
}

View File

@ -87,7 +87,8 @@ public class GUICrucible extends GuiInfoContainer {
GenericRecipe recipe = CrucibleRecipes.INSTANCE.recipeNameMap.get(crucible.recipe);
this.renderItem(recipe != null ? recipe.getIcon() : TEMPLATE_FOLDER, 107, 81);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
if(!crucible.recipeStack.isEmpty()) drawStack(crucible.recipeStack, crucible.recipeZCapacity, 62, 97);
if(!crucible.wasteStack.isEmpty()) drawStack(crucible.wasteStack, crucible.wasteZCapacity, 17, 97);
}