More null annotations

This commit is contained in:
mezz committed 2017-02-07 00:05:24 -08:00
1 parent da8a833485
commit a5daa93bf1
163 files changed
+952 -849

No files matched your search

+2 -2
View File
@@ -261,14 +261,14 @@ public class Botany extends AbstractMod {
return;
}
if (player != null && heldItem != null) {
if (heldItem != null) {
Block block = world.getBlockState(pos).getBlock();
int py = -1;
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
py = 1;
}
if (py >= 0) {
IFlower flower = BotanyCore.getFlowerRoot().getConversion(event.getEntityPlayer().getHeldItemMainhand());
IFlower flower = BotanyCore.getFlowerRoot().getConversion(heldItem);
if (flower != null && Gardening.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) {
--heldItem.stackSize;
}
@@ -4,18 +4,17 @@ import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import javax.annotation.Nullable;
public enum EnumAcidity implements IStringSerializable {
Acid(TextFormatting.RED),
Neutral,
Neutral(null),
Alkaline(TextFormatting.AQUA);
@Nullable
final TextFormatting color;
EnumAcidity() {
this(null);
}
EnumAcidity(TextFormatting color) {
EnumAcidity(@Nullable TextFormatting color) {
this.color = color;
}
@@ -4,18 +4,17 @@ import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import javax.annotation.Nullable;
public enum EnumMoisture implements IStringSerializable {
Dry(TextFormatting.YELLOW),
Normal,
Normal(null),
Damp(TextFormatting.DARK_BLUE);
@Nullable
final TextFormatting color;
EnumMoisture() {
this(null);
}
EnumMoisture(TextFormatting color) {
EnumMoisture(@Nullable TextFormatting color) {
this.color = color;
}
@@ -4,6 +4,7 @@ import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import javax.annotation.Nullable;
import java.util.Locale;
public enum EnumSoilType implements IStringSerializable {
@@ -11,13 +12,10 @@ public enum EnumSoilType implements IStringSerializable {
LOAM(TextFormatting.GOLD),
FLOWERBED(TextFormatting.LIGHT_PURPLE);
@Nullable
final TextFormatting color;
EnumSoilType() {
this(null);
}
EnumSoilType(TextFormatting color) {
EnumSoilType(@Nullable TextFormatting color) {
this.color = color;
}
@@ -167,6 +167,7 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
}
@Override
@Nullable
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return BlockMetadata.getPickBlock(world, pos);
}
@@ -90,6 +90,7 @@ public class CeramicDesignSystem implements IDesignSystem {
}
@Override
@Nullable
public IDesignMaterial getMaterial(final ItemStack itemStack) {
return (itemStack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? this.getMaterial(itemStack.getItemDamage()) : null;
}
@@ -25,6 +25,7 @@ public class CeramicTileRecipe implements IRecipe {
}
@Override
@Nullable
public ItemStack getCraftingResult(final InventoryCrafting inv) {
final Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
final Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
@@ -10,6 +10,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class PigmentRecipe implements IRecipe {
@Override
@@ -18,11 +19,13 @@ public class PigmentRecipe implements IRecipe {
}
@Override
@Nullable
public ItemStack getRecipeOutput() {
return null;
}
@Override
@Nullable
public ItemStack getCraftingResult(final InventoryCrafting crafting) {
int n = 0;
ItemStack stack = null;
@@ -20,12 +20,10 @@ public class ItemCeramicBrick extends ItemBlock implements IColoredItem {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
CeramicBrickPair ceramic = new CeramicBrickPair(stack.getItemDamage());
if(ceramic != null){
if (tintIndex == 1) {
return ceramic.colorFirst.getColor(false);
}else if (tintIndex == 2) {
return ceramic.colorSecond.getColor(false);
}
if (tintIndex == 1) {
return ceramic.colorFirst.getColor(false);
} else if (tintIndex == 2) {
return ceramic.colorSecond.getColor(false);
}
return 16777215;
}
@@ -7,9 +7,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class TileCeramicBrick extends TileEntity{
import javax.annotation.Nullable;
public class TileCeramicBrick extends TileEntity{
@Nullable
private EnumFlowerColor colorFirst;
@Nullable
private EnumFlowerColor colorSecond;
public void setColors(EnumFlowerColor colorFirst, EnumFlowerColor colorSecond) {
@@ -35,6 +35,7 @@ import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -68,6 +69,7 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
}
@Override
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
return null;
}
@@ -113,7 +115,9 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
if (!BinnieCore.getBinnieProxy().isSimulating(world)) {
if (flower != null && flower instanceof TileEntityFlower) {
final IFlower f = BotanyCore.getFlowerRoot().getMember(stack);
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
if (f != null) {
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
}
}
return;
}
@@ -12,6 +12,7 @@ import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import binnie.botany.genetics.Flower;
import binnie.core.BinnieCore;
import com.google.common.base.Preconditions;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.genetics.IIndividual;
@@ -29,6 +30,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
@@ -40,6 +42,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.List;
public class ItemBotany extends Item implements IColoredItem, IItemModelRegister {
@@ -77,7 +80,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
return false;
}
final IIndividual individual = this.getIndividual(itemstack);
return individual != null && individual.getGenome() != null && individual.hasEffect();
return individual != null && individual.hasEffect();
}
@Override
@@ -86,7 +89,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
return;
}
IFlower individual = (IFlower) this.getIndividual(itemStack);
if (individual == null || individual.getGenome() == null) {
if (individual == null) {
list.add(TextFormatting.DARK_RED + Binnie.LANGUAGE.localise("botany.flower.destroy"));
return;
}
@@ -114,8 +117,13 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
}
}
@Nullable
protected IIndividual getIndividual(final ItemStack itemstack) {
return new Flower(itemstack.getTagCompound());
NBTTagCompound tagCompound = itemstack.getTagCompound();
if (tagCompound == null) {
return null;
}
return new Flower(tagCompound);
}
private IAlleleFlowerSpecies getPrimarySpecies(final ItemStack itemstack) {
@@ -132,7 +140,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
return Binnie.LANGUAGE.localise("item.botany.flower.corrupted.name");
}
IIndividual individual = this.getIndividual(itemstack);
if (individual != null && individual.getGenome() != null) {
if (individual != null) {
return individual.getDisplayName() + (!tag.isEmpty() ? " " + Binnie.LANGUAGE.localise("item.botany." + tag + ".name") : "");
}
return Binnie.LANGUAGE.localise("item.botany.flower.corrupted.name");
@@ -155,7 +163,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
if (flower == null || flower.getGenome() == null) {
if (flower == null) {
return 16777215;
}
return (tintIndex == 0) ? flower.getGenome().getStemColor().getColor(flower.isWilted()) : ((tintIndex == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : flower.getGenome().getSecondaryColor().getColor(flower.isWilted()));
@@ -175,9 +183,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
return null;
}
Preconditions.checkNotNull(flower);
IAlleleFlowerSpecies flowerSpecies = flower.getGenome().getPrimary();
IFlowerType flowerType = flowerSpecies.getType();
return flowerSpecies.getFlowerModel(type, flower.hasFlowered());
@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.List;
public class ItemInsulatedTube extends ItemCore implements IColoredItem {
@@ -147,7 +148,7 @@ public class ItemInsulatedTube extends ItemCore implements IColoredItem {
return new ItemStack(Blocks.STONE);
}
default: {
return null;
throw new IllegalStateException("Unknown insulated tube type: " + this);
}
}
}
@@ -111,11 +111,12 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
return super.writeToNBT(nbtCompound);
}
public void create(final ItemStack stack, final GameProfile owner) {
this.create(BotanyCore.getFlowerRoot().getMember(stack), owner);
public void create(final ItemStack stack, @Nullable final GameProfile owner) {
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
this.create(flower, owner);
}
public void create(final IFlower flower, final GameProfile owner) {
public void create(final IFlower flower, @Nullable final GameProfile owner) {
this.flower = flower;
if (this.flower.getAge() == 0) {
this.flower.setFlowered(false);
@@ -130,6 +131,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
}
@Override
@Nullable
public IIndividual getPollen() {
return this.getFlower();
}
@@ -323,6 +325,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
}
}
@Nullable
public ItemStack getItemStack() {
if (this.flower == null) {
return null;
@@ -330,6 +333,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
return Binnie.GENETICS.getFlowerRoot().getMemberStack(this.getFlower(), EnumFlowerStage.getStage(getFlower()));
}
@Nullable
private TileEntityFlower getRoot() {
if (this.getSection() == 0) {
return null;
@@ -600,6 +604,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
public void setErrorState(final IErrorState state) {
}
@Nullable
public IErrorState getErrorState() {
return null;
}
@@ -38,6 +38,7 @@ import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
@@ -158,18 +159,18 @@ public class ModuleGardening implements IInitializable {
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Botany.pigment, 2, EnumFlowerColor.Black.ordinal()), "pigment", "pigment", "dyeBlack"));
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.SulphurPowder.get(1), 1);
ModuleGardening.queuedAcidFertilisers.put(BotanyItems.MulchPowder.get(1), 1);
ModuleGardening.queuedAcidFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "mulch")), 2);
ModuleGardening.queuedAcidFertilisers.put(Mods.Forestry.stack("mulch"), 2);
for (final ItemStack stack : OreDictionary.getOres("dustSulfur")) {
ModuleGardening.queuedAcidFertilisers.put(stack, 2);
}
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.AshPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(BotanyItems.PulpPowder.get(1), 1);
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "ash")), 2);
ModuleGardening.queuedAlkalineFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "woodPulp")), 2);
ModuleGardening.queuedAlkalineFertilisers.put(Mods.Forestry.stack("ash"), 2);
ModuleGardening.queuedAlkalineFertilisers.put(Mods.Forestry.stack( "woodPulp"), 2);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.CompostPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(BotanyItems.FertiliserPowder.get(1), 1);
ModuleGardening.queuedNutrientFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "fertilizerBio")), 2);
ModuleGardening.queuedNutrientFertilisers.put(new ItemStack(GameRegistry.findItem("forestry", "fertilizerCompound")), 2);
ModuleGardening.queuedNutrientFertilisers.put(Mods.Forestry.stack( "fertilizerBio"), 2);
ModuleGardening.queuedNutrientFertilisers.put(Mods.Forestry.stack("fertilizerCompound"), 2);
for (final Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
this.addAcidFertiliser(entry.getKey(), entry.getValue());
}
@@ -192,17 +193,15 @@ public class ModuleGardening implements IInitializable {
GameRegistry.addRecipe(new PigmentRecipe());
}
@Nullable
private ItemStack getStack(final int type, final int pH, final int moisture) {
if (type < 0 || type > 2 || pH < 0 || pH > 2 || moisture < 0 || moisture > 2) {
return null;
if (type >= 0 && type <= 2 && pH >= 0 && pH <= 2 && moisture >= 0 && moisture <= 2) {
return new ItemStack(Gardening.getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
}
return new ItemStack(Gardening.getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
return null;
}
private void addAcidFertiliser(final ItemStack stack, final int strengthMax) {
if (stack == null) {
return;
}
Gardening.fertiliserAcid.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
@@ -211,7 +210,7 @@ public class ModuleGardening implements IInitializable {
for (int strength = 1; strength < strengthMax; ++strength) {
final ItemStack start = this.getStack(type, pH, moisture);
final ItemStack end = this.getStack(type, pH - strength, moisture);
if (end != null) {
if (start != null && end != null) {
end.stackSize = numOfBlocks;
final Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
@@ -228,9 +227,6 @@ public class ModuleGardening implements IInitializable {
}
private void addAlkalineFertiliser(final ItemStack stack, final int strengthMax) {
if (stack == null) {
return;
}
Gardening.fertiliserAlkaline.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
@@ -256,9 +252,6 @@ public class ModuleGardening implements IInitializable {
}
private void addNutrientFertiliser(final ItemStack stack, final int strengthMax) {
if (stack == null) {
return;
}
Gardening.fertiliserNutrient.put(stack, strengthMax);
for (int moisture = 0; moisture < 3; ++moisture) {
for (int pH = 0; pH < 3; ++pH) {
@@ -70,7 +70,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
@Override
public boolean isDNAManipulable(final ItemStack member) {
ISpeciesType type = this.getSpeciesRoot().getType(member);
return isDNAManipulable(type);
return type != null && isDNAManipulable(type);
}
@Override
@@ -26,6 +26,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -941,6 +942,7 @@ public enum FlowerDefinition implements IFlowerDefinition {
String binomial;
String branchName;
List<IAllele[]> variantTemplates;
@Nullable
IClassification branch;
EnumFlowerColor primaryColor, secondaryColor;
@@ -996,7 +998,7 @@ public enum FlowerDefinition implements IFlowerDefinition {
IAlleleFlowerSpeciesBuilder speciesBuilder = FlowerManager.flowerFactory.createSpecies(uid, unlocalizedName, "Binnie's Mod Team", unlocalizedDescription, isDominant, getBranch(), binomial, flowerType);
setSpeciesProperties(speciesBuilder);
this.species = speciesBuilder.build();
if (branch != null) {
if (this.branch != null) {
this.branch.addMemberSpecies(species);
}
}
@@ -21,6 +21,8 @@ import forestry.core.genetics.Genome;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
public class FlowerGenome extends Genome implements IFlowerGenome {
public FlowerGenome(final NBTTagCompound nbttagcompound) {
super(nbttagcompound);
@@ -30,6 +32,7 @@ public class FlowerGenome extends Genome implements IFlowerGenome {
super(chromosomes);
}
@Nullable
public static IAlleleFlowerSpecies getSpecies(ItemStack itemStack) {
if (!FlowerManager.flowerRoot.isMember(itemStack)) {
return null;