mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
NBT pain
This commit is contained in:
parent
cfa87c084c
commit
202620c73a
@ -41,7 +41,7 @@ public class HazardTransformerRadiationContainer extends HazardTransformerBase {
|
||||
|
||||
if(isBox) {
|
||||
|
||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack);
|
||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack, 20);
|
||||
if(fromNBT == null) return;
|
||||
|
||||
for(ItemStack held : fromNBT) {
|
||||
|
||||
@ -54,10 +54,10 @@ public class ItemLeadBox extends Item implements IGUIProvider {
|
||||
if(!box.hasTagCompound())
|
||||
box.setTagCompound(new NBTTagCompound());
|
||||
|
||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(box);
|
||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(box, slots.length);
|
||||
|
||||
if(fromNBT != null) {
|
||||
for(int i = 0; i < Math.min(slots.length, fromNBT.length); i++) {
|
||||
for(int i = 0; i < slots.length; i++) {
|
||||
slots[i] = fromNBT[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,27 +118,34 @@ public class ItemStackUtil {
|
||||
stack.stackTagCompound.setTag("items", tags);
|
||||
}
|
||||
|
||||
public static ItemStack[] readStacksFromNBT(ItemStack stack) {
|
||||
public static ItemStack[] readStacksFromNBT(ItemStack stack, int count) {
|
||||
|
||||
if(!stack.hasTagCompound())
|
||||
return null;
|
||||
|
||||
NBTTagList list = stack.stackTagCompound.getTagList("items", 10);
|
||||
int count = list.tagCount();
|
||||
if(count == 0) {
|
||||
count = list.tagCount();
|
||||
}
|
||||
|
||||
ItemStack[] stacks = new ItemStack[count];
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
NBTTagCompound slotNBT = list.getCompoundTagAt(i);
|
||||
byte slot = slotNBT.getByte("slot");
|
||||
if(slot >= 0 && slot < stacks.length) {
|
||||
stacks[slot] = ItemStack.loadItemStackFromNBT(slotNBT);
|
||||
ItemStack loadedStack = ItemStack.loadItemStackFromNBT(slotNBT);
|
||||
if(slot >= 0 && slot < stacks.length && loadedStack != null) {
|
||||
stacks[slot] = loadedStack;
|
||||
}
|
||||
}
|
||||
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public static ItemStack[] readStacksFromNBT(ItemStack stack) {
|
||||
return readStacksFromNBT(stack, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a List<String> of all ore dict names for this stack. Stack cannot be null, list is empty when there are no ore dict entries.
|
||||
* @param stack
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user