Fixed NPE with incorrectly initialized disks, fixes #200
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
- Fixed minor dupe bug with JEI transferring
|
- Fixed minor dupe bug with JEI transferring
|
||||||
- Fixed exporter crafting upgrades taking priority over other tasks
|
- Fixed exporter crafting upgrades taking priority over other tasks
|
||||||
|
- Fixed NPE with incorrectly initialized disks
|
||||||
|
|
||||||
### 0.8.10
|
### 0.8.10
|
||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
|
|||||||
@@ -238,6 +238,10 @@ public abstract class NBTStorage implements IStorage {
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValid(ItemStack stack) {
|
||||||
|
return stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_ITEMS) && stack.getTagCompound().hasKey(NBT_STORED);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param stack The {@link ItemStack} to populate with the NBT tags from {@link NBTStorage#createNBT()}
|
* @param stack The {@link ItemStack} to populate with the NBT tags from {@link NBTStorage#createNBT()}
|
||||||
* @return The provided {@link ItemStack} with NBT tags from {@link NBTStorage#createNBT()}
|
* @return The provided {@link ItemStack} with NBT tags from {@link NBTStorage#createNBT()}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ public class ItemStorageDisk extends ItemBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack disk, EntityPlayer player, List list, boolean b) {
|
public void addInformation(ItemStack disk, EntityPlayer player, List list, boolean b) {
|
||||||
|
if (NBTStorage.isValid(disk)) {
|
||||||
int capacity = EnumStorageType.getById(disk.getItemDamage()).getCapacity();
|
int capacity = EnumStorageType.getById(disk.getItemDamage()).getCapacity();
|
||||||
|
|
||||||
if (capacity == -1) {
|
if (capacity == -1) {
|
||||||
@@ -101,11 +102,12 @@ public class ItemStorageDisk extends ItemBase {
|
|||||||
list.add(I18n.format("misc.refinedstorage:storage.stored_capacity", NBTStorage.getStoredFromNBT(disk.getTagCompound()), capacity));
|
list.add(I18n.format("misc.refinedstorage:storage.stored_capacity", NBTStorage.getStoredFromNBT(disk.getTagCompound()), capacity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
|
public ActionResult<ItemStack> onItemRightClick(ItemStack disk, World world, EntityPlayer player, EnumHand hand) {
|
||||||
if (!world.isRemote && player.isSneaking() && NBTStorage.getStoredFromNBT(stack.getTagCompound()) == 0 && stack.getMetadata() != TYPE_CREATIVE) {
|
if (!world.isRemote && player.isSneaking() && NBTStorage.isValid(disk) && NBTStorage.getStoredFromNBT(disk.getTagCompound()) == 0 && disk.getMetadata() != TYPE_CREATIVE) {
|
||||||
ItemStack storagePart = new ItemStack(RefinedStorageItems.STORAGE_PART, 1, stack.getMetadata());
|
ItemStack storagePart = new ItemStack(RefinedStorageItems.STORAGE_PART, 1, disk.getMetadata());
|
||||||
|
|
||||||
if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
|
if (!player.inventory.addItemStackToInventory(storagePart.copy())) {
|
||||||
InventoryHelper.spawnItemStack(world, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), storagePart);
|
InventoryHelper.spawnItemStack(world, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), storagePart);
|
||||||
@@ -114,7 +116,7 @@ public class ItemStorageDisk extends ItemBase {
|
|||||||
return new ActionResult(EnumActionResult.SUCCESS, new ItemStack(RefinedStorageItems.STORAGE_HOUSING));
|
return new ActionResult(EnumActionResult.SUCCESS, new ItemStack(RefinedStorageItems.STORAGE_HOUSING));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ActionResult(EnumActionResult.PASS, stack);
|
return new ActionResult(EnumActionResult.PASS, disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -53,7 +53,12 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
|
|||||||
private static final String NBT_MODE = "Mode";
|
private static final String NBT_MODE = "Mode";
|
||||||
private static final String NBT_STORED = "Stored";
|
private static final String NBT_STORED = "Stored";
|
||||||
|
|
||||||
private BasicItemHandler disks = new BasicItemHandler(8, this, new BasicItemValidator(RefinedStorageItems.STORAGE_DISK)) {
|
private BasicItemHandler disks = new BasicItemHandler(8, this, new BasicItemValidator(RefinedStorageItems.STORAGE_DISK) {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(ItemStack disk) {
|
||||||
|
return super.isValid(disk) && NBTStorage.isValid(disk);
|
||||||
|
}
|
||||||
|
}) {
|
||||||
@Override
|
@Override
|
||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|||||||
Reference in New Issue
Block a user