mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-28 15:56:14 +00:00
Ton of null fixes
This commit is contained in:
132 files changed
+403
-325
No files matched your search
@@ -23,6 +23,8 @@ import vazkii.botania.api.mana.spark.ISparkEntity;
|
||||
import vazkii.botania.api.mana.spark.SparkUpgradeType;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileSparkChanger extends TileSimpleInventory {
|
||||
|
||||
public void doSwap() {
|
||||
@@ -38,7 +40,7 @@ public class TileSparkChanger extends TileSimpleInventory {
|
||||
ISparkEntity spark = attach.getAttachedSpark();
|
||||
if(spark != null) {
|
||||
SparkUpgradeType upg = spark.getUpgrade();
|
||||
SparkUpgradeType newUpg = changeStack == null ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1];
|
||||
SparkUpgradeType newUpg = changeStack.isEmpty() ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1];
|
||||
if(upg != newUpg)
|
||||
attachables.add(attach);
|
||||
}
|
||||
@@ -49,8 +51,8 @@ public class TileSparkChanger extends TileSimpleInventory {
|
||||
ISparkAttachable attach = attachables.get(world.rand.nextInt(attachables.size()));
|
||||
ISparkEntity spark = attach.getAttachedSpark();
|
||||
SparkUpgradeType upg = spark.getUpgrade();
|
||||
ItemStack sparkStack = upg == SparkUpgradeType.NONE ? null : new ItemStack(ModItems.sparkUpgrade, 1, upg.ordinal() - 1);
|
||||
SparkUpgradeType newUpg = changeStack == null ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1];
|
||||
ItemStack sparkStack = upg == SparkUpgradeType.NONE ? ItemStack.EMPTY : new ItemStack(ModItems.sparkUpgrade, 1, upg.ordinal() - 1);
|
||||
SparkUpgradeType newUpg = changeStack.isEmpty() ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1];
|
||||
spark.setUpgrade(newUpg);
|
||||
Collection transfers = spark.getTransfers();
|
||||
if(transfers != null)
|
||||
@@ -70,13 +72,14 @@ public class TileSparkChanger extends TileSimpleInventory {
|
||||
protected SimpleItemStackHandler createItemHandler() {
|
||||
return new SimpleItemStackHandler(this, true) {
|
||||
@Override
|
||||
protected int getStackLimit(int slot, ItemStack stack) {
|
||||
protected int getStackLimit(int slot, @Nonnull ItemStack stack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||
if(stack != null && stack.getItem() == ModItems.sparkUpgrade)
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
if(!stack.isEmpty() && stack.getItem() == ModItems.sparkUpgrade)
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
else return stack;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user