Fix a load of null issues, and get it to sort of work.

This commit is contained in:
modmuss50 2016-11-19 16:36:13 +00:00
parent 65e651f402
commit 528fecc2b5
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
35 changed files with 101 additions and 87 deletions

View file

@ -183,7 +183,7 @@ public class BlockOre extends BaseBlock implements ITexturedBlock, IOreNameProvi
@Override @Override
public String getTextureNameFromState(IBlockState BlockStateContainer, EnumFacing facing) { public String getTextureNameFromState(IBlockState BlockStateContainer, EnumFacing facing) {
return "techreborn:blocks/ore/ore" + StringUtils.toFirstCapital(ores[getMetaFromState(BlockStateContainer)]); return "techreborn:blocks/ore/ore" + ores[getMetaFromState(BlockStateContainer)];
} }
@Override @Override

View file

@ -397,12 +397,14 @@ public class ModBlocks {
} }
public static void registerBlock(Block block, String name) { public static void registerBlock(Block block, String name) {
name = name.toLowerCase();
block.setRegistryName(name); block.setRegistryName(name);
GameRegistry.register(block); GameRegistry.register(block);
GameRegistry.register(new ItemBlock(block), block.getRegistryName()); GameRegistry.register(new ItemBlock(block), block.getRegistryName());
} }
public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass, String name) { public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass, String name) {
name = name.toLowerCase();
block.setRegistryName(name); block.setRegistryName(name);
GameRegistry.register(block); GameRegistry.register(block);
try { try {

View file

@ -10,6 +10,6 @@ public abstract class ItemTextureBase extends ItemTR implements ITexturedItem {
@Override @Override
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) { public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory"); return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5).toLowerCase(), "inventory");
} }
} }

View file

@ -9,6 +9,7 @@ import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -68,7 +69,7 @@ public class ItemLapotronPack extends ItemArmor implements IEnergyItemInfo, ITex
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { public void getSubItems(Item item, CreativeTabs par2CreativeTabs, NonNullList itemList) {
ItemStack itemStack = new ItemStack(this, 1); ItemStack itemStack = new ItemStack(this, 1);
itemList.add(itemStack); itemList.add(itemStack);
@ -87,7 +88,7 @@ public class ItemLapotronPack extends ItemArmor implements IEnergyItemInfo, ITex
@Override @Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (player.inventory.getStackInSlot(i) != null) { if (player.inventory.getStackInSlot(i) != ItemStack.EMPTY) {
ItemStack item = player.inventory.getStackInSlot(i); ItemStack item = player.inventory.getStackInSlot(i);
if (item.getItem() instanceof IEnergyItemInfo) { if (item.getItem() instanceof IEnergyItemInfo) {
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem(); IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem();

View file

@ -38,7 +38,7 @@ public class ItemLithiumBatpack extends ItemArmor implements IEnergyItemInfo, IT
@Override @Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (player.inventory.getStackInSlot(i) != null) { if (player.inventory.getStackInSlot(i) != ItemStack.EMPTY) {
ItemStack item = player.inventory.getStackInSlot(i); ItemStack item = player.inventory.getStackInSlot(i);
if (item.getItem() instanceof IEnergyItemInfo) { if (item.getItem() instanceof IEnergyItemInfo) {
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem(); IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem();

View file

@ -52,7 +52,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo {
World worldIn, World worldIn,
@Nullable @Nullable
EntityLivingBase entityIn) { EntityLivingBase entityIn) {
if (stack != null && stack.getTagCompound().getBoolean("isActive")) { if (stack != ItemStack.EMPTY && stack.getTagCompound().getBoolean("isActive")) {
return 1.0F; return 1.0F;
} }
return 0.0F; return 0.0F;
@ -65,7 +65,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo {
ItemStack stack) { ItemStack stack) {
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create(); Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
int modifier = 0; int modifier = 0;
if (stack.getTagCompound().getBoolean("isActive")) if (!stack.isEmpty() && stack.getTagCompound().getBoolean("isActive"))
modifier = 9; modifier = 9;
if (slot == EntityEquipmentSlot.MAINHAND) { if (slot == EntityEquipmentSlot.MAINHAND) {

View file

@ -32,7 +32,7 @@ public class WaliaPartProvider implements IWailaDataProvider {
return mop.partHit.getDrops().get(0); return mop.partHit.getDrops().get(0);
} }
} }
return null; return ItemStack.EMPTY;
} }
@Override @Override

View file

@ -34,7 +34,7 @@ public class TRPowerNet {
for (EnumFacing facing : EnumFacing.VALUES) { for (EnumFacing facing : EnumFacing.VALUES) {
BlockPos pos = cable.getPos().offset(facing); BlockPos pos = cable.getPos().offset(facing);
TileEntity tile = cable.getWorld().getTileEntity(pos); TileEntity tile = cable.getWorld().getTileEntity(pos);
if (tile != null && tile instanceof IEnergyInterfaceTile) { if (tile instanceof IEnergyInterfaceTile) {
IEnergyInterfaceTile eit = (IEnergyInterfaceTile) tile; IEnergyInterfaceTile eit = (IEnergyInterfaceTile) tile;
net.addConnection(eit, facing); net.addConnection(eit, facing);
} }

View file

@ -132,6 +132,7 @@ public class ClientProxy extends CommonProxy {
@Override @Override
public void registerFluidBlockRendering(Block block, String name) { public void registerFluidBlockRendering(Block block, String name) {
name = name.toLowerCase();
super.registerFluidBlockRendering(block, name); super.registerFluidBlockRendering(block, name);
final ModelResourceLocation fluidLocation = new ModelResourceLocation(ModInfo.MOD_ID.toLowerCase() + ":fluids", name); final ModelResourceLocation fluidLocation = new ModelResourceLocation(ModInfo.MOD_ID.toLowerCase() + ":fluids", name);
@ -146,13 +147,15 @@ public class ClientProxy extends CommonProxy {
@Override @Override
public void registerCustomBlockSateLocation(Block block, String resourceLocation) { public void registerCustomBlockSateLocation(Block block, String resourceLocation) {
resourceLocation = resourceLocation.toLowerCase();
super.registerCustomBlockSateLocation(block, resourceLocation); super.registerCustomBlockSateLocation(block, resourceLocation);
String finalResourceLocation = resourceLocation;
ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() { ModelLoader.setCustomStateMapper(block, new DefaultStateMapper() {
@Override @Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state) { protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
String resourceDomain = Block.REGISTRY.getNameForObject(state.getBlock()).getResourceDomain(); String resourceDomain = Block.REGISTRY.getNameForObject(state.getBlock()).getResourceDomain();
String propertyString = getPropertyString(state.getProperties()); String propertyString = getPropertyString(state.getProperties());
return new ModelResourceLocation(resourceDomain + ':' + resourceLocation, propertyString); return new ModelResourceLocation(resourceDomain + ':' + finalResourceLocation, propertyString);
} }
}); });
String resourceDomain = Block.REGISTRY.getNameForObject(block).getResourceDomain(); String resourceDomain = Block.REGISTRY.getNameForObject(block).getResourceDomain();

View file

@ -90,12 +90,12 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
--this.burnTime; --this.burnTime;
} }
if (!this.world.isRemote) { if (!this.world.isRemote) {
if (this.burnTime != 0 || getStackInSlot(input1) != null && getStackInSlot(fuel) != null) { if (this.burnTime != 0 || getStackInSlot(input1) != ItemStack.EMPTY && getStackInSlot(fuel) != ItemStack.EMPTY) {
if (this.burnTime == 0 && this.canSmelt()) { if (this.burnTime == 0 && this.canSmelt()) {
this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel)); this.currentItemBurnTime = this.burnTime = getItemBurnTime(getStackInSlot(fuel));
if (this.burnTime > 0) { if (this.burnTime > 0) {
flag1 = true; flag1 = true;
if (this.getStackInSlot(fuel) != null) { if (this.getStackInSlot(fuel) != ItemStack.EMPTY) {
decrStackSize(fuel, 1); decrStackSize(fuel, 1);
} }
} }
@ -140,7 +140,7 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
} }
private boolean canSmelt() { private boolean canSmelt() {
if (this.getStackInSlot(input1) == null || this.getStackInSlot(input2) == null) { if (this.getStackInSlot(input1) == ItemStack.EMPTY || this.getStackInSlot(input2) == ItemStack.EMPTY) {
return false; return false;
} else { } else {
ItemStack itemstack = null; ItemStack itemstack = null;
@ -153,7 +153,7 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
if (itemstack == null) if (itemstack == null)
return false; return false;
if (this.getStackInSlot(output) == null) if (this.getStackInSlot(output) == ItemStack.EMPTY)
return true; return true;
if (!this.getStackInSlot(output).isItemEqual(itemstack)) if (!this.getStackInSlot(output).isItemEqual(itemstack))
return false; return false;
@ -181,12 +181,12 @@ public class TileAlloyFurnace extends TileLegacyMachineBase implements IWrenchab
itemstack = recipeType.getOutput(0); itemstack = recipeType.getOutput(0);
break; break;
} }
if (itemstack != null) { if (itemstack != ItemStack.EMPTY) {
break; break;
} }
} }
if (this.getStackInSlot(output) == null) { if (this.getStackInSlot(output) == ItemStack.EMPTY) {
setInventorySlotContents(output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
} else if (this.getStackInSlot(output).getItem() == itemstack.getItem()) { } else if (this.getStackInSlot(output).getItem() == itemstack.getItem()) {
decrStackSize(output, -itemstack.getCount()); decrStackSize(output, -itemstack.getCount());

View file

@ -52,7 +52,7 @@ public class TileCentrifuge extends TilePowerAcceptor
super.updateEntity(); super.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
charge(6); charge(6);
if (inventory.getStackInSlot(6) != null) { if (inventory.getStackInSlot(6) != ItemStack.EMPTY) {
ItemStack stack = inventory.getStackInSlot(6); ItemStack stack = inventory.getStackInSlot(6);
if (stack.getItem() instanceof IEnergyItemInfo) { if (stack.getItem() instanceof IEnergyItemInfo) {
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem(); IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();

View file

@ -26,7 +26,7 @@ public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, I
super.updateEntity(); super.updateEntity();
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
if (inventory.getStackInSlot(i) != null) { if (inventory.getStackInSlot(i) != ItemStack.EMPTY) {
if (getEnergy() > 0) { if (getEnergy() > 0) {
ItemStack stack = inventory.getStackInSlot(i); ItemStack stack = inventory.getStackInSlot(i);
if (stack.getItem() instanceof IEnergyInterfaceItem) { if (stack.getItem() instanceof IEnergyInterfaceItem) {

View file

@ -15,6 +15,7 @@ import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class TileDigitalChest extends TileLegacyMachineBase implements IInventoryProvider, IWrenchable, IListInfoProvider { public class TileDigitalChest extends TileLegacyMachineBase implements IInventoryProvider, IWrenchable, IListInfoProvider {
@ -23,6 +24,7 @@ public class TileDigitalChest extends TileLegacyMachineBase implements IInventor
// Slot 1 = Output // Slot 1 = Output
// Slot 2 = Fake Item // Slot 2 = Fake Item
@Nonnull
public ItemStack storedItem = ItemStack.EMPTY; public ItemStack storedItem = ItemStack.EMPTY;
// TODO use long so we can have 9,223,372,036,854,775,807 items instead of // TODO use long so we can have 9,223,372,036,854,775,807 items instead of
// 2,147,483,647 // 2,147,483,647
@ -32,7 +34,7 @@ public class TileDigitalChest extends TileLegacyMachineBase implements IInventor
@Override @Override
public void updateEntity() { public void updateEntity() {
if (!world.isRemote) { if (!world.isRemote) {
if (storedItem != null) { if (storedItem != ItemStack.EMPTY) {
ItemStack fakeStack = storedItem.copy(); ItemStack fakeStack = storedItem.copy();
fakeStack.setCount(1); fakeStack.setCount(1);
setInventorySlotContents(2, fakeStack); setInventorySlotContents(2, fakeStack);
@ -41,11 +43,11 @@ public class TileDigitalChest extends TileLegacyMachineBase implements IInventor
fakeStack.setCount(1); fakeStack.setCount(1);
setInventorySlotContents(2, fakeStack); setInventorySlotContents(2, fakeStack);
} else { } else {
setInventorySlotContents(2, null); setInventorySlotContents(2, ItemStack.EMPTY);
} }
if (getStackInSlot(0) != null) { if (getStackInSlot(0) != ItemStack.EMPTY) {
if (storedItem == null) { if (storedItem == ItemStack.EMPTY) {
storedItem = getStackInSlot(0); storedItem = getStackInSlot(0);
setInventorySlotContents(0, ItemStack.EMPTY); setInventorySlotContents(0, ItemStack.EMPTY);
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true)) { } else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true)) {
@ -56,7 +58,7 @@ public class TileDigitalChest extends TileLegacyMachineBase implements IInventor
} }
} }
if (storedItem != null && getStackInSlot(1) == null) { if (storedItem != ItemStack.EMPTY && getStackInSlot(1) == ItemStack.EMPTY) {
ItemStack itemStack = storedItem.copy(); ItemStack itemStack = storedItem.copy();
itemStack.setCount(itemStack.getMaxStackSize()); itemStack.setCount(itemStack.getMaxStackSize());
setInventorySlotContents(1, itemStack); setInventorySlotContents(1, itemStack);
@ -68,7 +70,7 @@ public class TileDigitalChest extends TileLegacyMachineBase implements IInventor
storedItem.shrink(wanted); storedItem.shrink(wanted);
} else { } else {
decrStackSize(1, -storedItem.getCount()); decrStackSize(1, -storedItem.getCount());
storedItem = null; storedItem = ItemStack.EMPTY;
} }
} }
} }
@ -89,13 +91,13 @@ public class TileDigitalChest extends TileLegacyMachineBase implements IInventor
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
storedItem = null; storedItem = ItemStack.EMPTY;
if (tagCompound.hasKey("storedStack")) { if (tagCompound.hasKey("storedStack")) {
storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack")); storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack"));
} }
if (storedItem != null) { if (storedItem != ItemStack.EMPTY) {
storedItem.setCount(tagCompound.getInteger("storedQuantity")); storedItem.setCount(tagCompound.getInteger("storedQuantity"));
} }
} }
@ -108,7 +110,7 @@ public class TileDigitalChest extends TileLegacyMachineBase implements IInventor
} }
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
if (storedItem != null) { if (storedItem != ItemStack.EMPTY) {
tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound())); tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound()));
tagCompound.setInteger("storedQuantity", storedItem.getCount()); tagCompound.setInteger("storedQuantity", storedItem.getCount());
} else } else
@ -154,11 +156,11 @@ public class TileDigitalChest extends TileLegacyMachineBase implements IInventor
public void addInfo(List<String> info, boolean isRealTile) { public void addInfo(List<String> info, boolean isRealTile) {
int size = 0; int size = 0;
String name = "of nothing"; String name = "of nothing";
if (storedItem != null) { if (storedItem != ItemStack.EMPTY) {
name = storedItem.getDisplayName(); name = storedItem.getDisplayName();
size += storedItem.getCount(); size += storedItem.getCount();
} }
if (getStackInSlot(1) != null) { if (getStackInSlot(1) != ItemStack.EMPTY) {
name = getStackInSlot(1).getDisplayName(); name = getStackInSlot(1).getDisplayName();
size += getStackInSlot(1).getCount(); size += getStackInSlot(1).getCount();
} }

View file

@ -51,12 +51,11 @@ public class TileIronFurnace extends TileLegacyMachineBase implements IInventory
if (getStackInSlot(fuelslot).getItem().hasContainerItem()) // Fuel if (getStackInSlot(fuelslot).getItem().hasContainerItem()) // Fuel
// slot // slot
{ {
setInventorySlotContents(fuelslot, setInventorySlotContents(fuelslot, new ItemStack(getStackInSlot(fuelslot).getItem().getContainerItem()));
new ItemStack(getStackInSlot(fuelslot).getItem().getContainerItem()));
} else if (getStackInSlot(fuelslot).getCount() > 1) { } else if (getStackInSlot(fuelslot).getCount() > 1) {
decrStackSize(fuelslot, 1); decrStackSize(fuelslot, 1);
} else if (getStackInSlot(fuelslot).getCount() == 1) { } else if (getStackInSlot(fuelslot).getCount() == 1) {
setInventorySlotContents(fuelslot, null); setInventorySlotContents(fuelslot, ItemStack.EMPTY);
} }
updateInventory = true; updateInventory = true;
} }
@ -83,7 +82,7 @@ public class TileIronFurnace extends TileLegacyMachineBase implements IInventory
if (this.canSmelt()) { if (this.canSmelt()) {
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (getStackInSlot(output) == null) { if (getStackInSlot(output) == ItemStack.EMPTY) {
setInventorySlotContents(output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
} else if (getStackInSlot(output).isItemEqual(itemstack)) { } else if (getStackInSlot(output).isItemEqual(itemstack)) {
getStackInSlot(output).grow(itemstack.getCount()); getStackInSlot(output).grow(itemstack.getCount());
@ -91,19 +90,19 @@ public class TileIronFurnace extends TileLegacyMachineBase implements IInventory
if (getStackInSlot(input1).getCount() > 1) { if (getStackInSlot(input1).getCount() > 1) {
this.decrStackSize(input1, 1); this.decrStackSize(input1, 1);
} else { } else {
setInventorySlotContents(input1, null); setInventorySlotContents(input1, ItemStack.EMPTY);
} }
} }
} }
public boolean canSmelt() { public boolean canSmelt() {
if (getStackInSlot(input1) == null) { if (getStackInSlot(input1) == ItemStack.EMPTY) {
return false; return false;
} else { } else {
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (itemstack == null) if (itemstack == ItemStack.EMPTY)
return false; return false;
if (getStackInSlot(output) == null) if (getStackInSlot(output) == ItemStack.EMPTY)
return true; return true;
if (!getStackInSlot(output).isItemEqual(itemstack)) if (!getStackInSlot(output).isItemEqual(itemstack))
return false; return false;

View file

@ -87,7 +87,7 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
if (!super.world.isRemote) { if (!super.world.isRemote) {
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
ItemStack stack = inventory.getStackInSlot(i); ItemStack stack = inventory.getStackInSlot(i);
if (this.amplifier < 10000 && stack != null) { if (this.amplifier < 10000 && stack != ItemStack.EMPTY) {
int amp = (int) ((long) (getValue(stack) / 32)); int amp = (int) ((long) (getValue(stack) / 32));
if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) { if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) {
if (canUseEnergy(1)) { if (canUseEnergy(1)) {
@ -120,14 +120,14 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
} }
private boolean spaceForOutput() { private boolean spaceForOutput() {
return inventory.getStackInSlot(6) == null return inventory.getStackInSlot(6) == ItemStack.EMPTY
|| ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true) || ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true)
&& inventory.getStackInSlot(6).getCount() < 64; && inventory.getStackInSlot(6).getCount() < 64;
} }
private void addOutputProducts() { private void addOutputProducts() {
if (inventory.getStackInSlot(6) == null) { if (inventory.getStackInSlot(6) == ItemStack.EMPTY) {
inventory.setInventorySlotContents(6, new ItemStack(ModItems.uuMatter)); inventory.setInventorySlotContents(6, new ItemStack(ModItems.uuMatter));
} else if (ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true)) { } else if (ItemUtils.isItemEqual(inventory.getStackInSlot(6), new ItemStack(ModItems.uuMatter), true, true)) {
inventory.getStackInSlot(6).setCount(Math.min(64, 1 + inventory.getStackInSlot(6).getCount())); inventory.getStackInSlot(6).setCount(Math.min(64, 1 + inventory.getStackInSlot(6).getCount()));

View file

@ -16,6 +16,7 @@ import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils; import reborncore.common.util.ItemUtils;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class TileQuantumChest extends TileLegacyMachineBase public class TileQuantumChest extends TileLegacyMachineBase
@ -25,7 +26,8 @@ public class TileQuantumChest extends TileLegacyMachineBase
// Slot 1 = Output // Slot 1 = Output
// Slot 2 = Fake Item // Slot 2 = Fake Item
public ItemStack storedItem; @Nonnull
public ItemStack storedItem = ItemStack.EMPTY;
// TODO use long so we can have 9,223,372,036,854,775,807 items instead of // TODO use long so we can have 9,223,372,036,854,775,807 items instead of
// 2,147,483,647 // 2,147,483,647
int storage = (int) Double.MAX_VALUE; int storage = (int) Double.MAX_VALUE;
@ -34,7 +36,7 @@ public class TileQuantumChest extends TileLegacyMachineBase
@Override @Override
public void updateEntity() { public void updateEntity() {
if (!world.isRemote) { if (!world.isRemote) {
if (storedItem != null) { if (storedItem != ItemStack.EMPTY) {
ItemStack fakeStack = storedItem.copy(); ItemStack fakeStack = storedItem.copy();
fakeStack.setCount(1); fakeStack.setCount(1);
setInventorySlotContents(2, fakeStack); setInventorySlotContents(2, fakeStack);
@ -43,11 +45,11 @@ public class TileQuantumChest extends TileLegacyMachineBase
fakeStack.setCount(1); fakeStack.setCount(1);
setInventorySlotContents(2, fakeStack); setInventorySlotContents(2, fakeStack);
} else { } else {
setInventorySlotContents(2, null); setInventorySlotContents(2, ItemStack.EMPTY);
} }
if (getStackInSlot(0) != null) { if (getStackInSlot(0) != ItemStack.EMPTY) {
if (storedItem == null) { if (storedItem == ItemStack.EMPTY) {
storedItem = getStackInSlot(0); storedItem = getStackInSlot(0);
setInventorySlotContents(0, ItemStack.EMPTY); setInventorySlotContents(0, ItemStack.EMPTY);
} else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true)) { } else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true)) {
@ -58,7 +60,7 @@ public class TileQuantumChest extends TileLegacyMachineBase
} }
} }
if (storedItem != null && getStackInSlot(1) == null) { if (storedItem != ItemStack.EMPTY && getStackInSlot(1) == ItemStack.EMPTY) {
ItemStack itemStack = storedItem.copy(); ItemStack itemStack = storedItem.copy();
itemStack.setCount(itemStack.getMaxStackSize()); itemStack.setCount(itemStack.getMaxStackSize());
setInventorySlotContents(1, itemStack); setInventorySlotContents(1, itemStack);
@ -70,7 +72,7 @@ public class TileQuantumChest extends TileLegacyMachineBase
storedItem.shrink(wanted); storedItem.shrink(wanted);
} else { } else {
decrStackSize(1, -storedItem.getCount()); decrStackSize(1, -storedItem.getCount());
storedItem = null; storedItem = ItemStack.EMPTY;
} }
} }
} }
@ -91,13 +93,13 @@ public class TileQuantumChest extends TileLegacyMachineBase
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
storedItem = null; storedItem = ItemStack.EMPTY;
if (tagCompound.hasKey("storedStack")) { if (tagCompound.hasKey("storedStack")) {
storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack")); storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack"));
} }
if (storedItem != null) { if (storedItem != ItemStack.EMPTY) {
storedItem.setCount(tagCompound.getInteger("storedQuantity")); storedItem.setCount(tagCompound.getInteger("storedQuantity"));
} }
} }
@ -110,7 +112,7 @@ public class TileQuantumChest extends TileLegacyMachineBase
} }
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
if (storedItem != null) { if (storedItem != ItemStack.EMPTY) {
tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound())); tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound()));
tagCompound.setInteger("storedQuantity", storedItem.getCount()); tagCompound.setInteger("storedQuantity", storedItem.getCount());
} else { } else {
@ -182,11 +184,11 @@ public class TileQuantumChest extends TileLegacyMachineBase
if (isRealTile) { if (isRealTile) {
int size = 0; int size = 0;
String name = "of nothing"; String name = "of nothing";
if (storedItem != null) { if (storedItem != ItemStack.EMPTY) {
name = storedItem.getDisplayName(); name = storedItem.getDisplayName();
size += storedItem.getCount(); size += storedItem.getCount();
} }
if (getStackInSlot(1) != null) { if (getStackInSlot(1) != ItemStack.EMPTY) {
name = getStackInSlot(1).getDisplayName(); name = getStackInSlot(1).getDisplayName();
size += getStackInSlot(1).getCount(); size += getStackInSlot(1).getCount();
} }

View file

@ -61,10 +61,10 @@ public class TileQuantumTank extends TileLegacyMachineBase
if (!world.isRemote) { if (!world.isRemote) {
FluidUtils.drainContainers(tank, inventory, 0, 1); FluidUtils.drainContainers(tank, inventory, 0, 1);
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType()); FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType());
if (tank.getFluidType() != null && getStackInSlot(2) == null) { if (tank.getFluidType() != null && getStackInSlot(2) == ItemStack.EMPTY) {
// inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); // inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) { } else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, null); setInventorySlotContents(2, ItemStack.EMPTY);
} }
tank.compareAndUpdate(); tank.compareAndUpdate();
} }

View file

@ -72,7 +72,7 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world); currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world);
if (currentRecipe != null) { if (currentRecipe != null) {
boolean hasCrafted = false; boolean hasCrafted = false;
if (inventory.getStackInSlot(0) == null) { if (inventory.getStackInSlot(0) == ItemStack.EMPTY) {
inventory.setInventorySlotContents(0, currentRecipe); inventory.setInventorySlotContents(0, currentRecipe);
tickTime = -1; tickTime = -1;
hasCrafted = true; hasCrafted = true;
@ -109,7 +109,7 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
if (currentRecipe != null) { if (currentRecipe != null) {
inventory.setInventorySlotContents(1, currentRecipe); inventory.setInventorySlotContents(1, currentRecipe);
} else { } else {
inventory.setInventorySlotContents(1, null); inventory.setInventorySlotContents(1, ItemStack.EMPTY);
} }
} }
} }

View file

@ -81,13 +81,13 @@ public class TileScrapboxinator extends TilePowerAcceptor implements IWrenchable
this.decrStackSize(input1, 1); this.decrStackSize(input1, 1);
} else { } else {
useEnergy(cost); useEnergy(cost);
setInventorySlotContents(input1, null); setInventorySlotContents(input1, ItemStack.EMPTY);
} }
} }
} }
public boolean canOpen() { public boolean canOpen() {
return getStackInSlot(input1) != null && getStackInSlot(output) == null; return getStackInSlot(input1) != ItemStack.EMPTY && getStackInSlot(output) == ItemStack.EMPTY;
} }
public boolean isBurning() { public boolean isBurning() {

View file

@ -202,13 +202,13 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
} }
} else { } else {
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) { if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) {
if (getStackInSlot(outputStackSlot) == null) { if (getStackInSlot(outputStackSlot) == ItemStack.EMPTY) {
setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy()); setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy());
} else { } else {
decrStackSize(outputStackSlot, -currentRecipe.getOutput().getCount()); decrStackSize(outputStackSlot, -currentRecipe.getOutput().getCount());
} }
decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount()); decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount());
if (currentRecipe.getBottomInput() != null) { if (currentRecipe.getBottomInput() != ItemStack.EMPTY) {
decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount()); decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount());
} }
resetCrafter(); resetCrafter();
@ -252,10 +252,10 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
} }
public boolean canFitStack(ItemStack stack, int slot, boolean oreDic) {// Checks to see if it can fit the stack public boolean canFitStack(ItemStack stack, int slot, boolean oreDic) {// Checks to see if it can fit the stack
if (stack == null) { if (stack == ItemStack.EMPTY) {
return true; return true;
} }
if (inventory.getStackInSlot(slot) == null) { if (inventory.getStackInSlot(slot) == ItemStack.EMPTY) {
return true; return true;
} }
if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic)) { if (ItemUtils.isItemEqual(inventory.getStackInSlot(slot), stack, true, true, oreDic)) {

View file

@ -97,11 +97,11 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
if (!world.isRemote) { if (!world.isRemote) {
FluidUtils.drainContainers(tank, inventory, 0, 1); FluidUtils.drainContainers(tank, inventory, 0, 1);
FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType()); FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluidType());
if (tank.getFluidType() != null && getStackInSlot(2) == null) { if (tank.getFluidType() != null && getStackInSlot(2) == ItemStack.EMPTY) {
inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
syncWithAll(); syncWithAll();
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) { } else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, null); setInventorySlotContents(2, ItemStack.EMPTY);
syncWithAll(); syncWithAll();
} }

View file

@ -128,9 +128,9 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, II
tank.drain(currentWithdraw, true); tank.drain(currentWithdraw, true);
addEnergy(euTick); addEnergy(euTick);
} }
if (tank.getFluidType() != null && getStackInSlot(2) == null) { if (tank.getFluidType() != null && getStackInSlot(2) == ItemStack.EMPTY) {
inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) { } else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, null); setInventorySlotContents(2, null);
} }
} }

View file

@ -61,7 +61,7 @@ public class TileGenerator extends TilePowerAcceptor implements IWrenchable, IIn
if(getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket){ if(getStackInSlot(fuelSlot).getItem() == Items.LAVA_BUCKET || getStackInSlot(fuelSlot).getItem() == ForgeModContainer.getInstance().universalBucket){
setInventorySlotContents(fuelSlot, new ItemStack(Items.BUCKET)); setInventorySlotContents(fuelSlot, new ItemStack(Items.BUCKET));
} else { } else {
setInventorySlotContents(fuelSlot, null); setInventorySlotContents(fuelSlot, ItemStack.EMPTY);
} }
} else { } else {

View file

@ -132,10 +132,10 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
tank.drain(currentWithdraw, true); tank.drain(currentWithdraw, true);
addEnergy(euTick); addEnergy(euTick);
} }
if (tank.getFluidType() != null && getStackInSlot(2) == null) { if (tank.getFluidType() != null && getStackInSlot(2) == ItemStack.EMPTY) {
inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) { } else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, null); setInventorySlotContents(2, ItemStack.EMPTY);
} }
} }

View file

@ -124,10 +124,10 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab
tank.drain(1, true); tank.drain(1, true);
addEnergy(euTick); addEnergy(euTick);
} }
if (tank.getFluidType() != null && getStackInSlot(2) == null) { if (tank.getFluidType() != null && getStackInSlot(2) == ItemStack.EMPTY) {
// inventory.setInventorySlotContents(2, new ItemStack(tank // inventory.setInventorySlotContents(2, new ItemStack(tank
// .getFluidType().getBlock())); // .getFluidType().getBlock()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) { } else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, null); setInventorySlotContents(2, null);
} }
} }

View file

@ -86,14 +86,14 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrencha
} }
public void addOutput(int slot, ItemStack stack) { public void addOutput(int slot, ItemStack stack) {
if (getStackInSlot(slot) == null) if (getStackInSlot(slot) == ItemStack.EMPTY)
setInventorySlotContents(slot, stack); setInventorySlotContents(slot, stack);
getStackInSlot(slot).grow(stack.getCount()); getStackInSlot(slot).grow(stack.getCount());
} }
public boolean canAddOutput(int slot, int amount) { public boolean canAddOutput(int slot, int amount) {
ItemStack stack = getStackInSlot(slot); ItemStack stack = getStackInSlot(slot);
return stack == null || getInventoryStackLimit() - stack.getCount() >= amount; return stack == ItemStack.EMPTY || getInventoryStackLimit() - stack.getCount() >= amount;
} }
@Override @Override

View file

@ -55,7 +55,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
@Override @Override
public void updateEntity() { public void updateEntity() {
if (inventory.getStackInSlot(0) != null) { if (inventory.getStackInSlot(0) != ItemStack.EMPTY) {
ItemStack stack = inventory.getStackInSlot(0); ItemStack stack = inventory.getStackInSlot(0);
if (!(stack.getItem() instanceof IEnergyItemInfo)) { if (!(stack.getItem() instanceof IEnergyItemInfo)) {
return; return;
@ -68,7 +68,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
} }
} }
} }
if (inventory.getStackInSlot(1) != null) { if (inventory.getStackInSlot(1) != ItemStack.EMPTY) {
ItemStack stack = inventory.getStackInSlot(1); ItemStack stack = inventory.getStackInSlot(1);
if (!(stack.getItem() instanceof IEnergyItemInfo)) { if (!(stack.getItem() instanceof IEnergyItemInfo)) {
return; return;

View file

@ -68,7 +68,7 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
if (this.canSmelt()) { if (this.canSmelt()) {
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (getStackInSlot(output) == null) { if (getStackInSlot(output) == ItemStack.EMPTY) {
setInventorySlotContents(output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
} else if (getStackInSlot(output).isItemEqual(itemstack)) { } else if (getStackInSlot(output).isItemEqual(itemstack)) {
getStackInSlot(output).grow(itemstack.getCount()); getStackInSlot(output).grow(itemstack.getCount());
@ -82,13 +82,13 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
} }
public boolean canSmelt() { public boolean canSmelt() {
if (getStackInSlot(input1) == null) { if (getStackInSlot(input1) == ItemStack.EMPTY) {
return false; return false;
} else { } else {
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1)); ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(getStackInSlot(input1));
if (itemstack == null) if (itemstack == null)
return false; return false;
if (getStackInSlot(output) == null) if (getStackInSlot(output) == ItemStack.EMPTY)
return true; return true;
if (!getStackInSlot(output).isItemEqual(itemstack)) if (!getStackInSlot(output).isItemEqual(itemstack))
return false; return false;
@ -103,7 +103,7 @@ public class TileElectricFurnace extends TilePowerAcceptor implements IWrenchabl
public ItemStack getResultFor(ItemStack stack) { public ItemStack getResultFor(ItemStack stack) {
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack); ItemStack result = FurnaceRecipes.instance().getSmeltingResult(stack);
if (result != null) { if (result != ItemStack.EMPTY) {
return result.copy(); return result.copy();
} }
return null; return null;

View file

@ -72,7 +72,7 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInv
ItemStack itemstack = ItemParts.getPartByName("scrap"); ItemStack itemstack = ItemParts.getPartByName("scrap");
int randomchance = world.rand.nextInt(chance); int randomchance = world.rand.nextInt(chance);
if (getStackInSlot(output) == null) { if (getStackInSlot(output) == ItemStack.EMPTY) {
useEnergy(cost); useEnergy(cost);
if (randomchance == 1) { if (randomchance == 1) {
setInventorySlotContents(output, itemstack.copy()); setInventorySlotContents(output, itemstack.copy());
@ -98,7 +98,7 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInv
} }
public boolean hasSlotGotSpace(int slot) { public boolean hasSlotGotSpace(int slot) {
if (getStackInSlot(slot) == null) { if (getStackInSlot(slot) == ItemStack.EMPTY) {
return true; return true;
} else if (getStackInSlot(slot).getCount() < getStackInSlot(slot).getMaxStackSize()) { } else if (getStackInSlot(slot).getCount() < getStackInSlot(slot).getMaxStackSize()) {
return true; return true;

View file

@ -6,6 +6,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
public class OreDictUtils { public class OreDictUtils {
@ -54,6 +55,7 @@ public class OreDictUtils {
return false; return false;
} }
@Nonnull
public static ItemStack getDictOreOrNull(String name, int amount) { public static ItemStack getDictOreOrNull(String name, int amount) {
List<ItemStack> ores = OreDictionary.getOres(name); List<ItemStack> ores = OreDictionary.getOres(name);
if (ores.isEmpty()) if (ores.isEmpty())
@ -77,8 +79,8 @@ public class OreDictUtils {
return isOre(new ItemStack(item), oreName); return isOre(new ItemStack(item), oreName);
} }
public static boolean isOre(ItemStack stack, String oreName) { public static boolean isOre(@Nonnull ItemStack stack, String oreName) {
if (stack != null && !stack.isEmpty() && oreName != null) { if (stack != ItemStack.EMPTY && !stack.isEmpty() && oreName != null) {
int id = OreDictionary.getOreID(oreName); int id = OreDictionary.getOreID(oreName);
int[] ids = OreDictionary.getOreIDs(stack); int[] ids = OreDictionary.getOreIDs(stack);

View file

@ -3,7 +3,10 @@ package techreborn.utils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import techreborn.items.DynamicCell; import techreborn.items.DynamicCell;
import javax.annotation.Nonnull;
public class RecipeUtils { public class RecipeUtils {
@Nonnull
public static ItemStack getEmptyCell(int stackSize) { public static ItemStack getEmptyCell(int stackSize) {
return DynamicCell.getEmptyCell(stackSize); return DynamicCell.getEmptyCell(stackSize);
} }

View file

@ -29,7 +29,7 @@ public class UpgradeHandler {
crafter.resetSpeedMulti(); crafter.resetSpeedMulti();
for (int slot : this.slots) { for (int slot : this.slots) {
ItemStack stack = inventory.getStackInSlot(slot); ItemStack stack = inventory.getStackInSlot(slot);
if (stack != null && stack.getItem() instanceof IMachineUpgrade) { if (stack != ItemStack.EMPTY && stack.getItem() instanceof IMachineUpgrade) {
((IMachineUpgrade) stack.getItem()).processUpgrade(crafter, stack); ((IMachineUpgrade) stack.getItem()).processUpgrade(crafter, stack);
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B