mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-03-14 13:45:36 +00:00
NBT pain
This commit is contained in:
parent
cfa87c084c
commit
202620c73a
@ -41,7 +41,7 @@ public class HazardTransformerRadiationContainer extends HazardTransformerBase {
|
|||||||
|
|
||||||
if(isBox) {
|
if(isBox) {
|
||||||
|
|
||||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack);
|
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(stack, 20);
|
||||||
if(fromNBT == null) return;
|
if(fromNBT == null) return;
|
||||||
|
|
||||||
for(ItemStack held : fromNBT) {
|
for(ItemStack held : fromNBT) {
|
||||||
|
|||||||
@ -54,10 +54,10 @@ public class ItemLeadBox extends Item implements IGUIProvider {
|
|||||||
if(!box.hasTagCompound())
|
if(!box.hasTagCompound())
|
||||||
box.setTagCompound(new NBTTagCompound());
|
box.setTagCompound(new NBTTagCompound());
|
||||||
|
|
||||||
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(box);
|
ItemStack[] fromNBT = ItemStackUtil.readStacksFromNBT(box, slots.length);
|
||||||
|
|
||||||
if(fromNBT != null) {
|
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];
|
slots[i] = fromNBT[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,27 +118,34 @@ public class ItemStackUtil {
|
|||||||
stack.stackTagCompound.setTag("items", tags);
|
stack.stackTagCompound.setTag("items", tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack[] readStacksFromNBT(ItemStack stack) {
|
public static ItemStack[] readStacksFromNBT(ItemStack stack, int count) {
|
||||||
|
|
||||||
if(!stack.hasTagCompound())
|
if(!stack.hasTagCompound())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
NBTTagList list = stack.stackTagCompound.getTagList("items", 10);
|
NBTTagList list = stack.stackTagCompound.getTagList("items", 10);
|
||||||
int count = list.tagCount();
|
if(count == 0) {
|
||||||
|
count = list.tagCount();
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack[] stacks = new ItemStack[count];
|
ItemStack[] stacks = new ItemStack[count];
|
||||||
|
|
||||||
for(int i = 0; i < count; i++) {
|
for(int i = 0; i < count; i++) {
|
||||||
NBTTagCompound slotNBT = list.getCompoundTagAt(i);
|
NBTTagCompound slotNBT = list.getCompoundTagAt(i);
|
||||||
byte slot = slotNBT.getByte("slot");
|
byte slot = slotNBT.getByte("slot");
|
||||||
if(slot >= 0 && slot < stacks.length) {
|
ItemStack loadedStack = ItemStack.loadItemStackFromNBT(slotNBT);
|
||||||
stacks[slot] = ItemStack.loadItemStackFromNBT(slotNBT);
|
if(slot >= 0 && slot < stacks.length && loadedStack != null) {
|
||||||
|
stacks[slot] = loadedStack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return stacks;
|
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.
|
* 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
|
* @param stack
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user