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
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

View file

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

View file

@ -10,6 +10,6 @@ public abstract class ItemTextureBase extends ItemTR implements ITexturedItem {
@Override
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.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -68,7 +69,7 @@ public class ItemLapotronPack extends ItemArmor implements IEnergyItemInfo, ITex
@SuppressWarnings({ "rawtypes", "unchecked" })
@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);
itemList.add(itemStack);
@ -87,7 +88,7 @@ public class ItemLapotronPack extends ItemArmor implements IEnergyItemInfo, ITex
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
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);
if (item.getItem() instanceof IEnergyItemInfo) {
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem();

View file

@ -38,7 +38,7 @@ public class ItemLithiumBatpack extends ItemArmor implements IEnergyItemInfo, IT
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
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);
if (item.getItem() instanceof IEnergyItemInfo) {
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -87,7 +87,7 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
if (!super.world.isRemote) {
for (int i = 0; i < 6; 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));
if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) {
if (canUseEnergy(1)) {
@ -120,14 +120,14 @@ public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchab
}
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)
&& inventory.getStackInSlot(6).getCount() < 64;
}
private void addOutputProducts() {
if (inventory.getStackInSlot(6) == null) {
if (inventory.getStackInSlot(6) == ItemStack.EMPTY) {
inventory.setInventorySlotContents(6, new ItemStack(ModItems.uuMatter));
} 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()));

View file

@ -16,6 +16,7 @@ import reborncore.common.util.Inventory;
import reborncore.common.util.ItemUtils;
import techreborn.init.ModBlocks;
import javax.annotation.Nonnull;
import java.util.List;
public class TileQuantumChest extends TileLegacyMachineBase
@ -25,7 +26,8 @@ public class TileQuantumChest extends TileLegacyMachineBase
// Slot 1 = Output
// 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
// 2,147,483,647
int storage = (int) Double.MAX_VALUE;
@ -34,7 +36,7 @@ public class TileQuantumChest extends TileLegacyMachineBase
@Override
public void updateEntity() {
if (!world.isRemote) {
if (storedItem != null) {
if (storedItem != ItemStack.EMPTY) {
ItemStack fakeStack = storedItem.copy();
fakeStack.setCount(1);
setInventorySlotContents(2, fakeStack);
@ -43,11 +45,11 @@ public class TileQuantumChest extends TileLegacyMachineBase
fakeStack.setCount(1);
setInventorySlotContents(2, fakeStack);
} else {
setInventorySlotContents(2, null);
setInventorySlotContents(2, ItemStack.EMPTY);
}
if (getStackInSlot(0) != null) {
if (storedItem == null) {
if (getStackInSlot(0) != ItemStack.EMPTY) {
if (storedItem == ItemStack.EMPTY) {
storedItem = getStackInSlot(0);
setInventorySlotContents(0, ItemStack.EMPTY);
} 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.setCount(itemStack.getMaxStackSize());
setInventorySlotContents(1, itemStack);
@ -70,7 +72,7 @@ public class TileQuantumChest extends TileLegacyMachineBase
storedItem.shrink(wanted);
} else {
decrStackSize(1, -storedItem.getCount());
storedItem = null;
storedItem = ItemStack.EMPTY;
}
}
}
@ -91,13 +93,13 @@ public class TileQuantumChest extends TileLegacyMachineBase
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
storedItem = null;
storedItem = ItemStack.EMPTY;
if (tagCompound.hasKey("storedStack")) {
storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack"));
}
if (storedItem != null) {
if (storedItem != ItemStack.EMPTY) {
storedItem.setCount(tagCompound.getInteger("storedQuantity"));
}
}
@ -110,7 +112,7 @@ public class TileQuantumChest extends TileLegacyMachineBase
}
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
if (storedItem != null) {
if (storedItem != ItemStack.EMPTY) {
tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound()));
tagCompound.setInteger("storedQuantity", storedItem.getCount());
} else {
@ -182,11 +184,11 @@ public class TileQuantumChest extends TileLegacyMachineBase
if (isRealTile) {
int size = 0;
String name = "of nothing";
if (storedItem != null) {
if (storedItem != ItemStack.EMPTY) {
name = storedItem.getDisplayName();
size += storedItem.getCount();
}
if (getStackInSlot(1) != null) {
if (getStackInSlot(1) != ItemStack.EMPTY) {
name = getStackInSlot(1).getDisplayName();
size += getStackInSlot(1).getCount();
}

View file

@ -61,10 +61,10 @@ public class TileQuantumTank extends TileLegacyMachineBase
if (!world.isRemote) {
FluidUtils.drainContainers(tank, inventory, 0, 1);
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()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
setInventorySlotContents(2, null);
} else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, ItemStack.EMPTY);
}
tank.compareAndUpdate();
}

View file

@ -72,7 +72,7 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, world);
if (currentRecipe != null) {
boolean hasCrafted = false;
if (inventory.getStackInSlot(0) == null) {
if (inventory.getStackInSlot(0) == ItemStack.EMPTY) {
inventory.setInventorySlotContents(0, currentRecipe);
tickTime = -1;
hasCrafted = true;
@ -109,7 +109,7 @@ public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable
if (currentRecipe != null) {
inventory.setInventorySlotContents(1, currentRecipe);
} 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);
} else {
useEnergy(cost);
setInventorySlotContents(input1, null);
setInventorySlotContents(input1, ItemStack.EMPTY);
}
}
}
public boolean canOpen() {
return getStackInSlot(input1) != null && getStackInSlot(output) == null;
return getStackInSlot(input1) != ItemStack.EMPTY && getStackInSlot(output) == ItemStack.EMPTY;
}
public boolean isBurning() {

View file

@ -202,13 +202,13 @@ public class TileEntityFusionController extends TilePowerAcceptor implements IIn
}
} else {
if (canFitStack(currentRecipe.getOutput(), outputStackSlot, true)) {
if (getStackInSlot(outputStackSlot) == null) {
if (getStackInSlot(outputStackSlot) == ItemStack.EMPTY) {
setInventorySlotContents(outputStackSlot, currentRecipe.getOutput().copy());
} else {
decrStackSize(outputStackSlot, -currentRecipe.getOutput().getCount());
}
decrStackSize(topStackSlot, currentRecipe.getTopInput().getCount());
if (currentRecipe.getBottomInput() != null) {
if (currentRecipe.getBottomInput() != ItemStack.EMPTY) {
decrStackSize(bottomStackSlot, currentRecipe.getBottomInput().getCount());
}
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
if (stack == null) {
if (stack == ItemStack.EMPTY) {
return true;
}
if (inventory.getStackInSlot(slot) == null) {
if (inventory.getStackInSlot(slot) == ItemStack.EMPTY) {
return true;
}
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) {
FluidUtils.drainContainers(tank, inventory, 0, 1);
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()));
syncWithAll();
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
setInventorySlotContents(2, null);
} else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, ItemStack.EMPTY);
syncWithAll();
}

View file

@ -128,9 +128,9 @@ public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable, II
tank.drain(currentWithdraw, true);
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()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
} else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
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){
setInventorySlotContents(fuelSlot, new ItemStack(Items.BUCKET));
} else {
setInventorySlotContents(fuelSlot, null);
setInventorySlotContents(fuelSlot, ItemStack.EMPTY);
}
} else {

View file

@ -132,10 +132,10 @@ public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrench
tank.drain(currentWithdraw, true);
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()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
setInventorySlotContents(2, null);
} else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, ItemStack.EMPTY);
}
}

View file

@ -124,10 +124,10 @@ public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchab
tank.drain(1, true);
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()));
} else if (tank.getFluidType() == null && getStackInSlot(2) != null) {
} else if (tank.getFluidType() == null && getStackInSlot(2) != ItemStack.EMPTY) {
setInventorySlotContents(2, null);
}
}

View file

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

View file

@ -55,7 +55,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IWrenchable,
@Override
public void updateEntity() {
if (inventory.getStackInSlot(0) != null) {
if (inventory.getStackInSlot(0) != ItemStack.EMPTY) {
ItemStack stack = inventory.getStackInSlot(0);
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
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);
if (!(stack.getItem() instanceof IEnergyItemInfo)) {
return;

View file

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

View file

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

View file

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

View file

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

View file

@ -29,7 +29,7 @@ public class UpgradeHandler {
crafter.resetSpeedMulti();
for (int slot : this.slots) {
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);
}
}

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