mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 12:19:46 +00:00
Fix a bunch more null issues
This commit is contained in:
15 files changed
+36
-38
No files matched your search
@@ -133,8 +133,7 @@ public class SubTileLoonuim extends SubTileFunctional {
|
||||
entity.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, Integer.MAX_VALUE, 0));
|
||||
entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, Integer.MAX_VALUE, 0));
|
||||
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
stack.writeToNBT(cmp);
|
||||
NBTTagCompound cmp = stack.writeToNBT(new NBTTagCompound());
|
||||
entity.getEntityData().setTag(TAG_ITEMSTACK_TO_DROP, cmp);
|
||||
|
||||
world.spawnEntity(entity);
|
||||
|
||||
@@ -248,8 +248,7 @@ public class TileAlfPortal extends TileMod {
|
||||
cmp.setInteger(TAG_STACK_COUNT, stacksIn.size());
|
||||
int i = 0;
|
||||
for(ItemStack stack : stacksIn) {
|
||||
NBTTagCompound stackcmp = new NBTTagCompound();
|
||||
stack.writeToNBT(stackcmp);
|
||||
NBTTagCompound stackcmp = stack.writeToNBT(new NBTTagCompound());
|
||||
cmp.setTag(TAG_STACK + i, stackcmp);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TileCacophonium extends TileMod {
|
||||
|
||||
NBTTagCompound cmp1 = new NBTTagCompound();
|
||||
if(!stack.isEmpty())
|
||||
stack.writeToNBT(cmp1);
|
||||
cmp1 = stack.writeToNBT(cmp1);
|
||||
cmp.setTag(TAG_STACK, cmp1);
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
|
||||
|
||||
NBTTagCompound itemCmp = new NBTTagCompound();
|
||||
if(itemToEnchant != null)
|
||||
itemToEnchant.writeToNBT(itemCmp);
|
||||
itemCmp = itemToEnchant.writeToNBT(itemCmp);
|
||||
cmp.setTag(TAG_ITEM, itemCmp);
|
||||
|
||||
String enchStr = enchants.stream()
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ public class TileCorporeaCrystalCube extends TileCorporeaBase implements ICorpor
|
||||
super.writePacketNBT(par1nbtTagCompound);
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
if(requestTarget != null)
|
||||
requestTarget.writeToNBT(cmp);
|
||||
cmp = requestTarget.writeToNBT(cmp);
|
||||
par1nbtTagCompound.setTag(TAG_REQUEST_TARGET, cmp);
|
||||
par1nbtTagCompound.setInteger(TAG_ITEM_COUNT, itemCount);
|
||||
}
|
||||
|
||||
@@ -89,8 +89,7 @@ public class TileCorporeaRetainer extends TileMod {
|
||||
cmp.setString(TAG_REQUEST_CONTENTS, (String) request);
|
||||
break;
|
||||
case REQUEST_ITEMSTACK:
|
||||
NBTTagCompound cmp1 = new NBTTagCompound();
|
||||
((ItemStack) request).writeToNBT(cmp1);
|
||||
NBTTagCompound cmp1 = ((ItemStack) request).writeToNBT(new NBTTagCompound());
|
||||
cmp.setTag(TAG_REQUEST_STACK, cmp1);
|
||||
break;
|
||||
default: break;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ManaGunClipRecipe implements IRecipe {
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
ItemStack lens = ItemManaGun.getLens(gun);
|
||||
ItemManaGun.setLens(gun, null);
|
||||
ItemManaGun.setLens(gun, ItemStack.EMPTY);
|
||||
ItemStack gunCopy = gun.copy();
|
||||
ItemManaGun.setClip(gunCopy, true);
|
||||
ItemManaGun.setLensAtPos(gunCopy, lens, 0);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ManaGunLensRecipe implements IRecipe {
|
||||
for(int i = 0; i < var1.getSizeInventory(); i++) {
|
||||
ItemStack stack = var1.getStackInSlot(i);
|
||||
if(!stack.isEmpty()) {
|
||||
if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) == null)
|
||||
if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack).isEmpty())
|
||||
foundGun = true;
|
||||
|
||||
else if(stack.getItem() instanceof ILens) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ManaGunRemoveLensRecipe implements IRecipe {
|
||||
for(int i = 0; i < var1.getSizeInventory(); i++) {
|
||||
ItemStack stack = var1.getStackInSlot(i);
|
||||
if(!stack.isEmpty()) {
|
||||
if(stack.getItem() instanceof ItemManaGun && ItemManaGun.getLens(stack) != null)
|
||||
if(stack.getItem() instanceof ItemManaGun && !ItemManaGun.getLens(stack).isEmpty())
|
||||
foundGun = true;
|
||||
|
||||
else return false; // Found an invalid item, breaking the recipe
|
||||
@@ -53,7 +53,7 @@ public class ManaGunRemoveLensRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
ItemStack gunCopy = gun.copy();
|
||||
ItemManaGun.setLens(gunCopy, null);
|
||||
ItemManaGun.setLens(gunCopy, ItemStack.EMPTY);
|
||||
|
||||
return gunCopy;
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
ItemStack stack = getSourceLens();
|
||||
NBTTagCompound lensCmp = new NBTTagCompound();
|
||||
if(!stack.isEmpty())
|
||||
stack.writeToNBT(lensCmp);
|
||||
lensCmp = stack.writeToNBT(lensCmp);
|
||||
par1nbtTagCompound.setTag(TAG_LENS_STACK, lensCmp);
|
||||
|
||||
BlockPos coords = getBurstSourceBlockPos();
|
||||
|
||||
@@ -328,7 +328,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
|
||||
|
||||
ItemStack result = CraftingManager.getInstance().findMatchingRecipe((InventoryCrafting) event.craftMatrix, event.player.world);
|
||||
if(!result.isEmpty()) {
|
||||
result.writeToNBT(cmp1);
|
||||
cmp1 = result.writeToNBT(cmp1);
|
||||
cmp.setTag(TAG_ITEM_PREFIX + 9, cmp1);
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
@@ -338,7 +338,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
|
||||
if(!stackSlot.isEmpty()) {
|
||||
ItemStack writeStack = stackSlot.copy();
|
||||
writeStack.setCount(1);
|
||||
writeStack.writeToNBT(cmp1);
|
||||
cmp1 = writeStack.writeToNBT(cmp1);
|
||||
}
|
||||
cmp.setTag(TAG_ITEM_PREFIX + i, cmp1);
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ public class ItemKeepIvy extends ItemMod {
|
||||
int i = 0;
|
||||
for(EntityItem keep : keeps) {
|
||||
ItemStack stack = keep.getEntityItem();
|
||||
NBTTagCompound cmp1 = new NBTTagCompound();
|
||||
stack.writeToNBT(cmp1);
|
||||
NBTTagCompound cmp1 = stack.writeToNBT(new NBTTagCompound());
|
||||
cmp.setTag(TAG_DROP_PREFIX + i, cmp1);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack) {
|
||||
return getLens(stack) != null;
|
||||
return !getLens(stack).isEmpty();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -158,7 +158,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
BurstProperties props = new BurstProperties(maxMana, ticksBeforeManaLoss, manaLossPerTick, gravity, motionModifier, color);
|
||||
|
||||
ItemStack lens = getLens(stack);
|
||||
if(lens != null)
|
||||
if(!lens.isEmpty())
|
||||
((ILens) lens.getItem()).apply(lens, props);
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
}
|
||||
|
||||
ItemStack lens = getLens(par1ItemStack);
|
||||
if(lens != null) {
|
||||
if(!lens.isEmpty()) {
|
||||
List<String> tooltip = lens.getTooltip(player, false);
|
||||
if(tooltip.size() > 1)
|
||||
stacks.addAll(tooltip.subList(1, tooltip.size()));
|
||||
@@ -216,7 +216,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
@Override
|
||||
public String getItemStackDisplayName(@Nonnull ItemStack par1ItemStack) {
|
||||
ItemStack lens = getLens(par1ItemStack);
|
||||
return super.getItemStackDisplayName(par1ItemStack) + (lens == null ? "" : " (" + TextFormatting.GREEN + lens.getDisplayName() + TextFormatting.RESET + ")");
|
||||
return super.getItemStackDisplayName(par1ItemStack) + (lens.isEmpty() ? "" : " (" + TextFormatting.GREEN + lens.getDisplayName() + TextFormatting.RESET + ")");
|
||||
}
|
||||
|
||||
public static boolean hasClip(ItemStack stack) {
|
||||
@@ -266,7 +266,7 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
public static void setLensAtPos(ItemStack stack, ItemStack lens, int pos) {
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
if(lens != null)
|
||||
lens.writeToNBT(cmp);
|
||||
cmp = lens.writeToNBT(cmp);
|
||||
ItemNBTHelper.setCompound(stack, TAG_LENS + pos, cmp);
|
||||
}
|
||||
|
||||
@@ -275,8 +275,8 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
|
||||
setLensAtPos(stack, lens, getClipPos(stack));
|
||||
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
if(lens != null)
|
||||
lens.writeToNBT(cmp);
|
||||
if(!lens.isEmpty())
|
||||
cmp = lens.writeToNBT(cmp);
|
||||
ItemNBTHelper.setCompound(stack, TAG_LENS, cmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
|
||||
addStringToTooltip(I18n.format("botania.baubletooltip", key), stacks);
|
||||
|
||||
ItemStack cosmetic = getCosmeticItem(par1ItemStack);
|
||||
if(cosmetic != null)
|
||||
if(!cosmetic.isEmpty())
|
||||
addStringToTooltip(I18n.format("botaniamisc.hasCosmetic", cosmetic.getDisplayName()), stacks);
|
||||
|
||||
if(hasPhantomInk(par1ItemStack))
|
||||
@@ -158,15 +158,15 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
|
||||
public ItemStack getCosmeticItem(ItemStack stack) {
|
||||
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COSMETIC_ITEM, true);
|
||||
if(cmp == null)
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
return new ItemStack(cmp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCosmeticItem(ItemStack stack, ItemStack cosmetic) {
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
if(cosmetic != null)
|
||||
cosmetic.writeToNBT(cmp);
|
||||
if(!cosmetic.isEmpty())
|
||||
cmp = cosmetic.writeToNBT(cmp);
|
||||
ItemNBTHelper.setCompound(stack, TAG_COSMETIC_ITEM, cmp);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
|
||||
@Override
|
||||
public String getItemStackDisplayName(@Nonnull ItemStack stack) {
|
||||
ItemStack compositeLens = getCompositeLens(stack);
|
||||
if(compositeLens == null)
|
||||
if(compositeLens.isEmpty())
|
||||
return super.getItemStackDisplayName(stack);
|
||||
return String.format(net.minecraft.util.text.translation.I18n.translateToLocal("item.botania:compositeLens.name"), getItemShortTermName(stack), getItemShortTermName(compositeLens));
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
|
||||
getLens(stack.getItemDamage()).apply(stack, props);
|
||||
|
||||
ItemStack compositeLens = getCompositeLens(stack);
|
||||
if(compositeLens != null && compositeLens.getItem() instanceof ILens)
|
||||
if(!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens)
|
||||
((ILens) compositeLens.getItem()).apply(compositeLens, props);
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
|
||||
dead = getLens(stack.getItemDamage()).collideBurst(burst, entity, pos, isManaBlock, dead, stack);
|
||||
|
||||
ItemStack compositeLens = getCompositeLens(stack);
|
||||
if(compositeLens != null && compositeLens.getItem() instanceof ILens)
|
||||
if(!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens)
|
||||
dead = ((ILens) compositeLens.getItem()).collideBurst(burst, pos, isManaBlock, dead, compositeLens);
|
||||
|
||||
return dead;
|
||||
@@ -228,7 +228,7 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
|
||||
getLens(stack.getItemDamage()).updateBurst(burst, entity, stack);
|
||||
|
||||
ItemStack compositeLens = getCompositeLens(stack);
|
||||
if(compositeLens != null && compositeLens.getItem() instanceof ILens)
|
||||
if(!compositeLens.isEmpty() && compositeLens.getItem() instanceof ILens)
|
||||
((ILens) compositeLens.getItem()).updateBurst(burst, compositeLens);
|
||||
}
|
||||
|
||||
@@ -299,15 +299,17 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
|
||||
@Override
|
||||
public ItemStack getCompositeLens(ItemStack stack) {
|
||||
NBTTagCompound cmp = ItemNBTHelper.getCompound(stack, TAG_COMPOSITE_LENS, false);
|
||||
return new ItemStack(cmp);
|
||||
if(cmp == null)
|
||||
return ItemStack.EMPTY;
|
||||
else return new ItemStack(cmp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens) {
|
||||
NBTTagCompound cmp = new NBTTagCompound();
|
||||
compositeLens.writeToNBT(cmp);
|
||||
ItemNBTHelper.setCompound(sourceLens, TAG_COMPOSITE_LENS, cmp);
|
||||
|
||||
if(!compositeLens.isEmpty()) {
|
||||
NBTTagCompound cmp = compositeLens.writeToNBT(new NBTTagCompound());
|
||||
ItemNBTHelper.setCompound(sourceLens, TAG_COMPOSITE_LENS, cmp);
|
||||
}
|
||||
return sourceLens;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user