From d8e735ef3b75aa4d1ca511a35195af3126258b58 Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 30 Dec 2016 23:39:42 -0800 Subject: [PATCH] API javadoc cleanup, use NonNullList for ItemStack lists --- .../java/forestry/api/apiculture/IBee.java | 2 - .../forestry/api/apiculture/IBeeRoot.java | 7 ++- .../api/apiculture/IBeekeepingMode.java | 9 ---- .../forestry/api/apiculture/IHiveDrop.java | 5 +- .../forestry/api/arboriculture/ITree.java | 3 +- .../api/arboriculture/ITreeModifier.java | 6 --- .../forestry/api/arboriculture/ITreeRoot.java | 4 +- .../api/arboriculture/ITreekeepingMode.java | 4 +- .../forestry/api/core/ICamouflageAccess.java | 2 - .../api/farming/DefaultFarmListener.java | 2 +- .../forestry/api/farming/IFarmListener.java | 2 +- .../forestry/api/genetics/IAlleleEffect.java | 1 - .../api/genetics/IAlleleRegistry.java | 8 +--- .../forestry/api/genetics/IAlleleSpecies.java | 10 ++-- .../api/genetics/IBreedingTracker.java | 8 ---- .../api/genetics/IClassification.java | 2 - .../forestry/api/genetics/IIndividual.java | 1 - .../api/genetics/IIndividualLiving.java | 3 -- .../java/forestry/api/genetics/IMutation.java | 2 - .../forestry/api/genetics/ISpeciesRoot.java | 6 --- .../api/greenhouse/GreenhouseEvents.java | 3 +- .../IAlleleButterflyEffect.java | 1 - .../api/lepidopterology/IButterfly.java | 18 +------ .../lepidopterology/IButterflyNursery.java | 4 +- .../api/lepidopterology/IButterflyRoot.java | 1 - .../api/recipes/ICentrifugeRecipe.java | 4 +- .../api/recipes/IDescriptiveRecipe.java | 2 +- .../api/recipes/IFabricatorRecipe.java | 1 + .../forestry/api/recipes/ISqueezerRecipe.java | 2 +- .../api/recipes/IVariableFermentable.java | 1 - .../apiculture/commands/BeeModeHelper.java | 20 +++----- .../forestry/apiculture/genetics/BeeRoot.java | 12 +++-- .../apiculture/genetics/HiveDrop.java | 9 ++-- .../genetics/alleles/AlleleBeeSpecies.java | 11 ++--- .../blocks/BlockForestryLeaves.java | 2 +- .../commands/TreeModeHelper.java | 19 ++++---- .../forestry/arboriculture/genetics/Tree.java | 6 +-- .../arboriculture/genetics/TreeRoot.java | 11 +++-- .../genetics/TreekeepingMode.java | 5 +- .../arboriculture/tiles/TileLeaves.java | 8 ++-- .../java/forestry/core/CamouflageAccess.java | 48 +++++++------------ .../core/commands/CommandModeInfo.java | 2 +- .../core/commands/CommandModeSet.java | 13 ++--- .../core/commands/ICommandModeHelper.java | 7 +-- .../core/genetics/alleles/AlleleRegistry.java | 4 +- .../core/genetics/alleles/AlleleSpecies.java | 9 ++-- .../factory/recipes/CentrifugeRecipe.java | 8 ++-- .../alleles/AlleleButterflySpecies.java | 8 +++- 48 files changed, 119 insertions(+), 207 deletions(-) diff --git a/src/main/java/forestry/api/apiculture/IBee.java b/src/main/java/forestry/api/apiculture/IBee.java index 44043ddf1..f51c085aa 100644 --- a/src/main/java/forestry/api/apiculture/IBee.java +++ b/src/main/java/forestry/api/apiculture/IBee.java @@ -49,8 +49,6 @@ public interface IBee extends IIndividualLiving { /** * Set the natural flag on this bee. - * - * @param flag */ void setIsNatural(boolean flag); diff --git a/src/main/java/forestry/api/apiculture/IBeeRoot.java b/src/main/java/forestry/api/apiculture/IBeeRoot.java index 404e40421..c38a2182b 100644 --- a/src/main/java/forestry/api/apiculture/IBeeRoot.java +++ b/src/main/java/forestry/api/apiculture/IBeeRoot.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; public interface IBeeRoot extends ISpeciesRoot { /** - * @return true if passed item is a Forestry bee. Equal to getType(ItemStack stack) != EnumBeeType.NONE + * @return true if passed item is a Forestry bee. Equal to getType(ItemStack stack) != null */ @Override boolean isMember(ItemStack stack); @@ -49,7 +49,6 @@ public interface IBeeRoot extends ISpeciesRoot { /* BREEDING TRACKER */ /** - * @param world * @return {@link IApiaristTracker} associated with the passed world. */ @Override @@ -58,7 +57,7 @@ public interface IBeeRoot extends ISpeciesRoot { /* BEE SPECIFIC */ /** - * @return type of bee encoded on the itemstack. EnumBeeType.NONE if it isn't a bee. + * @return type of bee encoded on the itemstack. null if it isn't a bee. */ @Nullable @Override @@ -110,7 +109,7 @@ public interface IBeeRoot extends ISpeciesRoot { void registerBeekeepingMode(IBeekeepingMode mode); - void setBeekeepingMode(World world, String name); + void setBeekeepingMode(World world, IBeekeepingMode mode); /* MISC */ diff --git a/src/main/java/forestry/api/apiculture/IBeekeepingMode.java b/src/main/java/forestry/api/apiculture/IBeekeepingMode.java index 602db3557..3bb76f776 100644 --- a/src/main/java/forestry/api/apiculture/IBeekeepingMode.java +++ b/src/main/java/forestry/api/apiculture/IBeekeepingMode.java @@ -28,40 +28,31 @@ public interface IBeekeepingMode { float getWearModifier(); /** - * @param queen * @return fertility taking into account the birthing queen and surroundings. */ int getFinalFertility(IBee queen, World world, BlockPos pos); /** - * @param queen * @return true if the queen is genetically "fatigued" and should not be reproduced anymore. */ boolean isFatigued(IBee queen, IBeeHousing housing); /** - * @param queen - * @param housing * @return true if the queen is being overworked in the bee housing (with chance). will trigger a negative effect. */ boolean isOverworked(IBee queen, IBeeHousing housing); /** - * @param queen - * @param offspring - * @param housing * @return true if the genetic structure of the queen is breaking down during spawning of the offspring (with chance). will trigger a negative effect. */ boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing); /** - * @param queen * @return true if an offspring of this queen is considered a natural */ boolean isNaturalOffspring(IBee queen); /** - * @param queen * @return true if this mode allows the passed queen or princess to be multiplied */ boolean mayMultiplyPrincess(IBee queen); diff --git a/src/main/java/forestry/api/apiculture/IHiveDrop.java b/src/main/java/forestry/api/apiculture/IHiveDrop.java index 20ee85461..4dd0da87c 100644 --- a/src/main/java/forestry/api/apiculture/IHiveDrop.java +++ b/src/main/java/forestry/api/apiculture/IHiveDrop.java @@ -5,9 +5,8 @@ ******************************************************************************/ package forestry.api.apiculture; -import java.util.Collection; - import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -22,7 +21,7 @@ public interface IHiveDrop { IBee getBeeType(IBlockAccess world, BlockPos pos); - Collection getExtraItems(IBlockAccess world, BlockPos pos, int fortune); + NonNullList getExtraItems(IBlockAccess world, BlockPos pos, int fortune); /** * Chance to drop a bee or extra items. Default drops have 0.80 (= 80 %). diff --git a/src/main/java/forestry/api/arboriculture/ITree.java b/src/main/java/forestry/api/arboriculture/ITree.java index 06fa2d7e6..ee9a29a0b 100644 --- a/src/main/java/forestry/api/arboriculture/ITree.java +++ b/src/main/java/forestry/api/arboriculture/ITree.java @@ -6,6 +6,7 @@ package forestry.api.arboriculture; import javax.annotation.Nullable; +import java.util.List; import java.util.Map; import com.mojang.authlib.GameProfile; @@ -36,7 +37,7 @@ public interface ITree extends IIndividual, ITreeGenData { /** * @since Forestry 4.0 */ - ITree[] getSaplings(World world, @Nullable GameProfile playerProfile, BlockPos pos, float modifier); + List getSaplings(World world, @Nullable GameProfile playerProfile, BlockPos pos, float modifier); // Products, Chance Map getProducts(); diff --git a/src/main/java/forestry/api/arboriculture/ITreeModifier.java b/src/main/java/forestry/api/arboriculture/ITreeModifier.java index 4a4b724cd..735314e72 100644 --- a/src/main/java/forestry/api/arboriculture/ITreeModifier.java +++ b/src/main/java/forestry/api/arboriculture/ITreeModifier.java @@ -8,32 +8,26 @@ package forestry.api.arboriculture; public interface ITreeModifier { /** - * @param genome * @return Float used to modify the height. */ float getHeightModifier(ITreeGenome genome, float currentModifier); /** - * @param genome * @return Float used to modify the yield. */ float getYieldModifier(ITreeGenome genome, float currentModifier); /** - * @param genome * @return Float used to modify the sappiness. */ float getSappinessModifier(ITreeGenome genome, float currentModifier); /** - * @param genome * @return Float used to modify the maturation. */ float getMaturationModifier(ITreeGenome genome, float currentModifier); /** - * @param genome0 - * @param genome1 * @return Float used to modify the base mutation chance. */ float getMutationModifier(ITreeGenome genome0, ITreeGenome genome1, float currentModifier); diff --git a/src/main/java/forestry/api/arboriculture/ITreeRoot.java b/src/main/java/forestry/api/arboriculture/ITreeRoot.java index 505dc7cb3..99483aae9 100644 --- a/src/main/java/forestry/api/arboriculture/ITreeRoot.java +++ b/src/main/java/forestry/api/arboriculture/ITreeRoot.java @@ -43,7 +43,6 @@ public interface ITreeRoot extends ISpeciesRootPollinatable { ITreeGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive); /** - * @param world * @return {@link IArboristTracker} associated with the passed world. */ @Override @@ -87,11 +86,12 @@ public interface ITreeRoot extends ISpeciesRootPollinatable { ITreekeepingMode getTreekeepingMode(World world); + @Nullable ITreekeepingMode getTreekeepingMode(String name); void registerTreekeepingMode(ITreekeepingMode mode); - void setTreekeepingMode(World world, String name); + void setTreekeepingMode(World world, ITreekeepingMode mode); /* TEMPLATES */ diff --git a/src/main/java/forestry/api/arboriculture/ITreekeepingMode.java b/src/main/java/forestry/api/arboriculture/ITreekeepingMode.java index f366c65a0..f836de6a0 100644 --- a/src/main/java/forestry/api/arboriculture/ITreekeepingMode.java +++ b/src/main/java/forestry/api/arboriculture/ITreekeepingMode.java @@ -5,7 +5,7 @@ ******************************************************************************/ package forestry.api.arboriculture; -import java.util.ArrayList; +import java.util.List; public interface ITreekeepingMode extends ITreeModifier { @@ -17,6 +17,6 @@ public interface ITreekeepingMode extends ITreeModifier { /** * @return Localized list of strings outlining the behaviour of this treekeeping mode. */ - ArrayList getDescription(); + List getDescription(); } diff --git a/src/main/java/forestry/api/core/ICamouflageAccess.java b/src/main/java/forestry/api/core/ICamouflageAccess.java index 478593fb8..d18dc2021 100644 --- a/src/main/java/forestry/api/core/ICamouflageAccess.java +++ b/src/main/java/forestry/api/core/ICamouflageAccess.java @@ -5,7 +5,6 @@ ******************************************************************************/ package forestry.api.core; -import javax.annotation.Nullable; import java.util.List; import net.minecraft.item.ItemStack; @@ -22,7 +21,6 @@ public interface ICamouflageAccess { /** * @return A list of all item camouflage handler's that are registered for that camouflage type. */ - @Nullable List getCamouflageItemHandler(String type); void addItemToBlackList(String type, ItemStack camouflageBlock); diff --git a/src/main/java/forestry/api/farming/DefaultFarmListener.java b/src/main/java/forestry/api/farming/DefaultFarmListener.java index 0caaba217..f6450a7b5 100644 --- a/src/main/java/forestry/api/farming/DefaultFarmListener.java +++ b/src/main/java/forestry/api/farming/DefaultFarmListener.java @@ -23,7 +23,7 @@ public class DefaultFarmListener implements IFarmListener { } @Override - public void afterCropHarvest(Collection harvested, ICrop crop) { + public void afterCropHarvest(NonNullList harvested, ICrop crop) { } diff --git a/src/main/java/forestry/api/farming/IFarmListener.java b/src/main/java/forestry/api/farming/IFarmListener.java index 29b975132..571877869 100644 --- a/src/main/java/forestry/api/farming/IFarmListener.java +++ b/src/main/java/forestry/api/farming/IFarmListener.java @@ -27,7 +27,7 @@ public interface IFarmListener { * @param harvested Collection of harvested stacks. May be manipulated. Ensure removal of stacks with 0 or less items! * @param crop Harvested {@link ICrop} */ - void afterCropHarvest(Collection harvested, ICrop crop); + void afterCropHarvest(NonNullList harvested, ICrop crop); /** * Called after the stack of collected items has been returned by the farm logic, but before it is added to the farm's pending queue. diff --git a/src/main/java/forestry/api/genetics/IAlleleEffect.java b/src/main/java/forestry/api/genetics/IAlleleEffect.java index aa5388b7e..54330cbc6 100644 --- a/src/main/java/forestry/api/genetics/IAlleleEffect.java +++ b/src/main/java/forestry/api/genetics/IAlleleEffect.java @@ -18,7 +18,6 @@ public interface IAlleleEffect extends IAllele { /** * Returns the passed data storage if it is valid for this effect or a new one if the passed storage object was invalid for this effect. * - * @param storedData * @return {@link IEffectData} for the next cycle. */ IEffectData validateStorage(IEffectData storedData); diff --git a/src/main/java/forestry/api/genetics/IAlleleRegistry.java b/src/main/java/forestry/api/genetics/IAlleleRegistry.java index 448739cc1..5c760bf50 100644 --- a/src/main/java/forestry/api/genetics/IAlleleRegistry.java +++ b/src/main/java/forestry/api/genetics/IAlleleRegistry.java @@ -55,11 +55,11 @@ public interface IAlleleRegistry { /** * Retrieve a matching {@link ISpeciesRoot} for the given {@link IIndividual}-class. * - * @param clz Class extending {@link IIndividual}. + * @param individualClass Class extending {@link IIndividual}. * @return {@link ISpeciesRoot} if found, null otherwise. */ @Nullable - ISpeciesRoot getSpeciesRoot(Class clz); + ISpeciesRoot getSpeciesRoot(Class individualClass); /** * Retrieve a matching {@link ISpeciesRoot} for the given {@link IIndividual} @@ -71,7 +71,6 @@ public interface IAlleleRegistry { /** * Tests the itemstack for genetic information. * - * @param stack * @return true if the itemstack is an individual. */ boolean isIndividual(ItemStack stack); @@ -183,15 +182,12 @@ public interface IAlleleRegistry { /** * Registers a new fruit family. - * - * @param family */ void registerFruitFamily(IFruitFamily family); /** * Retrieves a fruit family identified by uid. * - * @param uid * @return {IFruitFamily} if found, false otherwise. */ IFruitFamily getFruitFamily(String uid); diff --git a/src/main/java/forestry/api/genetics/IAlleleSpecies.java b/src/main/java/forestry/api/genetics/IAlleleSpecies.java index 956e344e4..05be22801 100644 --- a/src/main/java/forestry/api/genetics/IAlleleSpecies.java +++ b/src/main/java/forestry/api/genetics/IAlleleSpecies.java @@ -9,6 +9,7 @@ import com.mojang.authlib.GameProfile; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; /** @@ -57,19 +58,14 @@ public interface IAlleleSpecies extends IAllele { int getComplexity(); /** - * @param itemstack * @return A float signifying the chance for the passed itemstack to yield a research success. */ float getResearchSuitability(ItemStack itemstack); /** - * @param world - * @param gameProfile - * @param individual - * @param bountyLevel - * @return Array of itemstacks representing the bounty for this research success. + * @return itemstacks representing the bounty for this research success. */ - ItemStack[] getResearchBounty(World world, GameProfile gameProfile, IIndividual individual, int bountyLevel); + NonNullList getResearchBounty(World world, GameProfile gameProfile, IIndividual individual, int bountyLevel); /* CLIMATE */ diff --git a/src/main/java/forestry/api/genetics/IBreedingTracker.java b/src/main/java/forestry/api/genetics/IBreedingTracker.java index cda17f8ea..969307431 100644 --- a/src/main/java/forestry/api/genetics/IBreedingTracker.java +++ b/src/main/java/forestry/api/genetics/IBreedingTracker.java @@ -33,29 +33,21 @@ public interface IBreedingTracker { /** * Register the birth of an individual. Will mark it as discovered. - * - * @param individual */ void registerBirth(IIndividual individual); /** * Register the pickup of an individual. - * - * @param individual */ void registerPickup(IIndividual individual); /** * Marks a species as discovered. Should only be called from registerIndividual normally. - * - * @param species */ void registerSpecies(IAlleleSpecies species); /** * Register a successful mutation. Will mark it as discovered. - * - * @param mutation */ void registerMutation(IMutation mutation); diff --git a/src/main/java/forestry/api/genetics/IClassification.java b/src/main/java/forestry/api/genetics/IClassification.java index 85be1c607..2c2597eec 100644 --- a/src/main/java/forestry/api/genetics/IClassification.java +++ b/src/main/java/forestry/api/genetics/IClassification.java @@ -90,8 +90,6 @@ public interface IClassification { /** * Used by the allele registry to populate internal collection of branch members on the fly. - * - * @param species */ void addMemberSpecies(IAlleleSpecies species); diff --git a/src/main/java/forestry/api/genetics/IIndividual.java b/src/main/java/forestry/api/genetics/IIndividual.java index 09b594ae5..e080f79fd 100644 --- a/src/main/java/forestry/api/genetics/IIndividual.java +++ b/src/main/java/forestry/api/genetics/IIndividual.java @@ -40,7 +40,6 @@ public interface IIndividual extends INbtWritable { /** * Check whether the genetic makeup of two IIndividuals is identical. Ignores additional data like generations, irregular mating, etc.. * - * @param other * @return true if the given other IIndividual has the amount of chromosomes and their alleles are identical. */ boolean isGeneticEqual(IIndividual other); diff --git a/src/main/java/forestry/api/genetics/IIndividualLiving.java b/src/main/java/forestry/api/genetics/IIndividualLiving.java index ae45f2f60..836e3d45c 100644 --- a/src/main/java/forestry/api/genetics/IIndividualLiving.java +++ b/src/main/java/forestry/api/genetics/IIndividualLiving.java @@ -34,9 +34,6 @@ public interface IIndividualLiving extends IIndividual { /** * Age the individual. - * - * @param world - * @param ageModifier */ void age(World world, float ageModifier); diff --git a/src/main/java/forestry/api/genetics/IMutation.java b/src/main/java/forestry/api/genetics/IMutation.java index 65f1ad1e7..48b11071d 100644 --- a/src/main/java/forestry/api/genetics/IMutation.java +++ b/src/main/java/forestry/api/genetics/IMutation.java @@ -49,13 +49,11 @@ public interface IMutation { Collection getSpecialConditions(); /** - * @param allele * @return true if the passed allele is one of the alleles participating in this mutation. */ boolean isPartner(IAllele allele); /** - * @param allele * @return the other allele which was not passed as argument. */ IAllele getPartner(IAllele allele); diff --git a/src/main/java/forestry/api/genetics/ISpeciesRoot.java b/src/main/java/forestry/api/genetics/ISpeciesRoot.java index 71eb6d629..8460c93b5 100644 --- a/src/main/java/forestry/api/genetics/ISpeciesRoot.java +++ b/src/main/java/forestry/api/genetics/ISpeciesRoot.java @@ -96,15 +96,11 @@ public interface ISpeciesRoot { /** * Registers a bee template using the UID of the first allele as identifier. - * - * @param template */ void registerTemplate(IAllele[] template); /** * Registers a bee template using the passed identifier. - * - * @param template */ void registerTemplate(String identifier, IAllele[] template); @@ -144,8 +140,6 @@ public interface ISpeciesRoot { /** * Use to register mutations. - * - * @param mutation */ void registerMutation(IMutation mutation); diff --git a/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java b/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java index 4bbeb8e63..f6d4716c2 100644 --- a/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java +++ b/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java @@ -14,10 +14,9 @@ import net.minecraftforge.fml.common.eventhandler.Event; public class GreenhouseEvents extends Event { - @Nullable public final IGreenhouseController controller; - public GreenhouseEvents(@Nullable IGreenhouseController state) { + public GreenhouseEvents(IGreenhouseController state) { this.controller = state; } diff --git a/src/main/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java b/src/main/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java index 07841e5fe..0fe6b07b6 100644 --- a/src/main/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java +++ b/src/main/java/forestry/api/lepidopterology/IAlleleButterflyEffect.java @@ -14,7 +14,6 @@ public interface IAlleleButterflyEffect extends IAlleleEffect { * Used by butterflies to trigger effects in the world. * * @param butterfly {@link IEntityButterfly} - * @param storedData * @return {@link forestry.api.genetics.IEffectData} for the next cycle. */ IEffectData doEffect(IEntityButterfly butterfly, IEffectData storedData); diff --git a/src/main/java/forestry/api/lepidopterology/IButterfly.java b/src/main/java/forestry/api/lepidopterology/IButterfly.java index 6f03633f1..1725f9e0c 100644 --- a/src/main/java/forestry/api/lepidopterology/IButterfly.java +++ b/src/main/java/forestry/api/lepidopterology/IButterfly.java @@ -29,41 +29,27 @@ public interface IButterfly extends IIndividualLiving { float getSize(); /** - * @param world - * @param x - * @param y - * @param z * @return true if the butterfly can naturally spawn at the given location at this time. (Used to auto-spawn butterflies from tree leaves.) */ boolean canSpawn(World world, double x, double y, double z); /** - * @param world - * @param x - * @param y - * @param z * @return true if the butterfly can take flight at the given location at this time. (Used to auto-spawn butterflies from dropped items.) */ boolean canTakeFlight(World world, double x, double y, double z); /** - * @param world - * @param x - * @param y - * @param z * @return true if the environment (temperature, humidity) is valid for the butterfly at the given location. */ boolean isAcceptedEnvironment(World world, double x, double y, double z); /** - * @param world * @return create a caterpillar with the two genome's from the nursery. */ @Nullable IButterfly spawnCaterpillar(World world, IButterflyNursery nursery); /** - * @param entity * @param playerKill Whether or not the butterfly was killed by a player. * @param lootLevel Loot level according to the weapon used to kill the butterfly. * @return Array of itemstacks to drop on death of the given entity. @@ -71,7 +57,6 @@ public interface IButterfly extends IIndividualLiving { NonNullList getLootDrop(IEntityButterfly entity, boolean playerKill, int lootLevel); /** - * @param nursery * @param playerKill Whether or not the nursery was broken by a player. * @param lootLevel Fortune level. * @return Array of itemstacks to drop on breaking of the nursery. @@ -79,8 +64,7 @@ public interface IButterfly extends IIndividualLiving { NonNullList getCaterpillarDrop(IButterflyNursery nursery, boolean playerKill, int lootLevel); /** - * @param cocoon - * @return Array of itemstacks to drop on breaking of the cocoon. + * @return itemstacks to drop on breaking of the cocoon. */ NonNullList getCocoonDrop(IButterflyCocoon cocoon); diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java b/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java index bfceeec65..9f76952d9 100644 --- a/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java +++ b/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java @@ -17,8 +17,8 @@ public interface IButterflyNursery extends IHousing, IClimateProvider { IIndividual getNanny(); - void setCaterpillar(@Nullable IButterfly butterfly); + void setCaterpillar(@Nullable IButterfly caterpillar); - boolean canNurse(IButterfly butterfly); + boolean canNurse(IButterfly caterpillar); } diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java b/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java index 1dd016fe7..b3eb4597f 100644 --- a/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java +++ b/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java @@ -48,7 +48,6 @@ public interface IButterflyRoot extends ISpeciesRoot { /** * Spawns the given butterfly in the world. * - * @param butterfly * @return butterfly entity on success, null otherwise. */ EntityLiving spawnButterflyInWorld(World world, IButterfly butterfly, double x, double y, double z); diff --git a/src/main/java/forestry/api/recipes/ICentrifugeRecipe.java b/src/main/java/forestry/api/recipes/ICentrifugeRecipe.java index 466c34c1b..6fb7c8aca 100644 --- a/src/main/java/forestry/api/recipes/ICentrifugeRecipe.java +++ b/src/main/java/forestry/api/recipes/ICentrifugeRecipe.java @@ -5,11 +5,11 @@ ******************************************************************************/ package forestry.api.recipes; -import java.util.Collection; import java.util.Map; import java.util.Random; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public interface ICentrifugeRecipe extends IForestryRecipe { @@ -26,7 +26,7 @@ public interface ICentrifugeRecipe extends IForestryRecipe { /** * Returns the randomized products from processing one input item. **/ - Collection getProducts(Random random); + NonNullList getProducts(Random random); /** * Returns a list of all possible products and their estimated probabilities (0.0 to 1.0], diff --git a/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java b/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java index 9054e8c9a..54a9922a6 100644 --- a/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java +++ b/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java @@ -27,7 +27,7 @@ public interface IDescriptiveRecipe { /** * @return array of all the ingredients in the crafting table. - * Ingredients may be null, ItemStack, ItemStack[], or a List of ItemStack + * Each inner list represents one slot's accepted ItemStacks */ NonNullList> getIngredients(); diff --git a/src/main/java/forestry/api/recipes/IFabricatorRecipe.java b/src/main/java/forestry/api/recipes/IFabricatorRecipe.java index d13f4a541..9389d51bc 100644 --- a/src/main/java/forestry/api/recipes/IFabricatorRecipe.java +++ b/src/main/java/forestry/api/recipes/IFabricatorRecipe.java @@ -18,6 +18,7 @@ public interface IFabricatorRecipe extends IForestryRecipe { /** * @return the list of ingredients in the crafting grid to create this recipe. + * Each inner list represents one slot's accepted ItemStacks */ NonNullList> getIngredients(); diff --git a/src/main/java/forestry/api/recipes/ISqueezerRecipe.java b/src/main/java/forestry/api/recipes/ISqueezerRecipe.java index bc0e7688c..253a66d53 100644 --- a/src/main/java/forestry/api/recipes/ISqueezerRecipe.java +++ b/src/main/java/forestry/api/recipes/ISqueezerRecipe.java @@ -12,7 +12,7 @@ import net.minecraftforge.fluids.FluidStack; public interface ISqueezerRecipe extends IForestryRecipe { /** - * @return Array of item stacks representing the required resources for one process. Stack size will be taken into account. + * @return item stacks representing the required resources for one process. Stack size will be taken into account. */ NonNullList getResources(); diff --git a/src/main/java/forestry/api/recipes/IVariableFermentable.java b/src/main/java/forestry/api/recipes/IVariableFermentable.java index b2fcdbf2e..f24a67980 100644 --- a/src/main/java/forestry/api/recipes/IVariableFermentable.java +++ b/src/main/java/forestry/api/recipes/IVariableFermentable.java @@ -14,7 +14,6 @@ import net.minecraft.item.ItemStack; public interface IVariableFermentable { /** - * @param itemstack * @return Float representing the modification to be applied to the matching recipe's biomass output. */ float getFermentationModifier(ItemStack itemstack); diff --git a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java index 8ad1de7e5..4a062ac05 100644 --- a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java +++ b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.apiculture.commands; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -34,24 +33,19 @@ public class BeeModeHelper implements ICommandModeHelper { return modeStrings.toArray(new String[modeStringCount]); } - @Override - @Nullable - public String getModeNameMatching(String desired) { - IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(desired); - if (mode == null) { - return null; - } - return mode.getName(); - } - @Override public String getModeName(World world) { return BeeManager.beeRoot.getBeekeepingMode(world).getName(); } @Override - public void setMode(World world, String modeName) { - BeeManager.beeRoot.setBeekeepingMode(world, modeName); + public boolean setMode(World world, String modeName) { + IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(modeName); + if (mode != null) { + BeeManager.beeRoot.setBeekeepingMode(world, mode); + return true; + } + return false; } @Override diff --git a/src/main/java/forestry/apiculture/genetics/BeeRoot.java b/src/main/java/forestry/apiculture/genetics/BeeRoot.java index b71c29b1b..570539e17 100644 --- a/src/main/java/forestry/apiculture/genetics/BeeRoot.java +++ b/src/main/java/forestry/apiculture/genetics/BeeRoot.java @@ -293,7 +293,9 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot { // No beekeeping mode yet, get it. IApiaristTracker tracker = getBreedingTracker(world, null); - String mode = tracker.getModeName(); + String modeName = tracker.getModeName(); + IBeekeepingMode mode = getBeekeepingMode(modeName); + Preconditions.checkNotNull(mode); setBeekeepingMode(world, mode); FMLCommonHandler.instance().getFMLLogger().debug("Set beekeeping mode for a world to " + mode); @@ -307,9 +309,11 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot { } @Override - public void setBeekeepingMode(World world, String name) { - activeBeekeepingMode = getBeekeepingMode(name); - getBreedingTracker(world, null).setModeName(name); + public void setBeekeepingMode(World world, IBeekeepingMode mode) { + Preconditions.checkNotNull(world); + Preconditions.checkNotNull(mode); + activeBeekeepingMode = mode; + getBreedingTracker(world, null).setModeName(mode.getName()); } @Override diff --git a/src/main/java/forestry/apiculture/genetics/HiveDrop.java b/src/main/java/forestry/apiculture/genetics/HiveDrop.java index 8b3ad68bd..e6328d35a 100755 --- a/src/main/java/forestry/apiculture/genetics/HiveDrop.java +++ b/src/main/java/forestry/apiculture/genetics/HiveDrop.java @@ -10,20 +10,19 @@ ******************************************************************************/ package forestry.apiculture.genetics; -import java.util.ArrayList; import java.util.Collections; -import java.util.List; import forestry.api.apiculture.IBee; import forestry.api.apiculture.IHiveDrop; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; public class HiveDrop implements IHiveDrop { private final IBeeDefinition beeTemplate; - private final ArrayList additional = new ArrayList<>(); + private final NonNullList additional = NonNullList.create(); private final double chance; private double ignobleShare = 0.0; @@ -45,8 +44,8 @@ public class HiveDrop implements IHiveDrop { } @Override - public List getExtraItems(IBlockAccess world, BlockPos pos, int fortune) { - List ret = new ArrayList<>(); + public NonNullList getExtraItems(IBlockAccess world, BlockPos pos, int fortune) { + NonNullList ret = NonNullList.create(); for (ItemStack stack : additional) { ret.add(stack.copy()); } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java index a98b80416..0f5b550d5 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java @@ -10,8 +10,6 @@ ******************************************************************************/ package forestry.apiculture.genetics.alleles; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -39,6 +37,7 @@ import forestry.core.utils.ItemStackUtil; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; 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; @@ -141,9 +140,9 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies } @Override - public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { - ArrayList bounty = new ArrayList<>(); - Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel)); + public NonNullList getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { + NonNullList bounty = NonNullList.create(); + bounty.addAll(super.getResearchBounty(world, researcher, individual, bountyLevel)); if (bountyLevel > 10) { for (ItemStack stack : specialtyChances.keySet()) { @@ -153,7 +152,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies for (ItemStack stack : productChances.keySet()) { bounty.add(ItemStackUtil.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand)); } - return bounty.toArray(new ItemStack[bounty.size()]); + return bounty; } /* OTHER */ diff --git a/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java b/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java index 3632639c8..cb553172a 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java @@ -175,7 +175,7 @@ public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvi } // Add saplings - ITree[] saplings = tree.getSaplings((World) world, playerProfile, pos, saplingModifier); + List saplings = tree.getSaplings((World) world, playerProfile, pos, saplingModifier); for (ITree sapling : saplings) { if (sapling != null) { diff --git a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java index 9bc19fd87..b9419dd77 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeModeHelper.java @@ -11,6 +11,7 @@ package forestry.arboriculture.commands; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import forestry.api.arboriculture.ITreekeepingMode; @@ -32,25 +33,27 @@ public class TreeModeHelper implements ICommandModeHelper { return modeStrings.toArray(new String[modeStringCount]); } - @Override - public String getModeNameMatching(String desired) { - ITreekeepingMode mode = TreeManager.treeRoot.getTreekeepingMode(desired); - return mode.getName(); - } - @Override public String getModeName(World world) { return TreeManager.treeRoot.getTreekeepingMode(world).getName(); } @Override - public void setMode(World world, String modeName) { - TreeManager.treeRoot.setTreekeepingMode(world, modeName); + public boolean setMode(World world, String modeName) { + ITreekeepingMode mode = TreeManager.treeRoot.getTreekeepingMode(modeName); + if (mode != null) { + TreeManager.treeRoot.setTreekeepingMode(world, mode); + return true; + } + return false; } @Override public Iterable getDescription(String modeName) { ITreekeepingMode mode = TreeManager.treeRoot.getTreekeepingMode(modeName); + if (mode == null) { + return Collections.emptyList(); + } return mode.getDescription(); } diff --git a/src/main/java/forestry/arboriculture/genetics/Tree.java b/src/main/java/forestry/arboriculture/genetics/Tree.java index 69fb0dc9c..4b6cc89d9 100755 --- a/src/main/java/forestry/arboriculture/genetics/Tree.java +++ b/src/main/java/forestry/arboriculture/genetics/Tree.java @@ -279,8 +279,8 @@ public class Tree extends Individual implements ITree, IPlantable { /* REPRODUCTION */ @Override - public ITree[] getSaplings(World world, @Nullable GameProfile playerProfile, BlockPos pos, float modifier) { - ArrayList prod = new ArrayList<>(); + public List getSaplings(World world, @Nullable GameProfile playerProfile, BlockPos pos, float modifier) { + List prod = new ArrayList<>(); float chance = genome.getFertility() * modifier; @@ -292,7 +292,7 @@ public class Tree extends Individual implements ITree, IPlantable { } } - return prod.toArray(new ITree[prod.size()]); + return prod; } private ITree createOffspring(World world, ITreeGenome mate, @Nullable GameProfile playerProfile, BlockPos pos) { diff --git a/src/main/java/forestry/arboriculture/genetics/TreeRoot.java b/src/main/java/forestry/arboriculture/genetics/TreeRoot.java index 9b8841f22..9f50cda6f 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeRoot.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeRoot.java @@ -325,8 +325,9 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot { // No Treekeeping mode yet, item it. IArboristTracker tracker = getBreedingTracker(world, null); - String mode = tracker.getModeName(); - + String modeName = tracker.getModeName(); + ITreekeepingMode mode = getTreekeepingMode(modeName); + Preconditions.checkNotNull(mode); setTreekeepingMode(world, mode); FMLCommonHandler.instance().getFMLLogger().debug("Set Treekeeping mode for a world to " + mode); @@ -339,9 +340,9 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot { } @Override - public void setTreekeepingMode(World world, String name) { - activeTreekeepingMode = getTreekeepingMode(name); - getBreedingTracker(world, null).setModeName(name); + public void setTreekeepingMode(World world, ITreekeepingMode mode) { + activeTreekeepingMode = mode; + getBreedingTracker(world, null).setModeName(mode.getName()); } @Override diff --git a/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java b/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java index 60ea456b9..93c95cada 100755 --- a/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java +++ b/src/main/java/forestry/arboriculture/genetics/TreekeepingMode.java @@ -12,6 +12,7 @@ package forestry.arboriculture.genetics; import javax.annotation.Nullable; import java.util.ArrayList; +import java.util.List; import java.util.Locale; import forestry.api.arboriculture.ITreeGenome; @@ -45,8 +46,8 @@ public class TreekeepingMode implements ITreekeepingMode { } @Override - public ArrayList getDescription() { - ArrayList ret = new ArrayList<>(); + public List getDescription() { + List ret = new ArrayList<>(); ret.add("treemode." + name.toLowerCase(Locale.ENGLISH) + ".desc"); return ret; } diff --git a/src/main/java/forestry/arboriculture/tiles/TileLeaves.java b/src/main/java/forestry/arboriculture/tiles/TileLeaves.java index 9b47d007d..d704a05cd 100644 --- a/src/main/java/forestry/arboriculture/tiles/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/tiles/TileLeaves.java @@ -488,16 +488,16 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } @Override - public void setCaterpillar(@Nullable IButterfly butterfly) { + public void setCaterpillar(@Nullable IButterfly caterpillar) { maturationTime = 0; - caterpillar = butterfly; + this.caterpillar = caterpillar; sendNetworkUpdate(); } @Override - public boolean canNurse(IButterfly butterfly) { + public boolean canNurse(IButterfly caterpillar) { ITree tree = getTree(); - return !isDestroyed(tree, damage) && caterpillar == null; + return !isDestroyed(tree, damage) && this.caterpillar == null; } @Override diff --git a/src/main/java/forestry/core/CamouflageAccess.java b/src/main/java/forestry/core/CamouflageAccess.java index ea7ea04a9..31b41db9c 100644 --- a/src/main/java/forestry/core/CamouflageAccess.java +++ b/src/main/java/forestry/core/CamouflageAccess.java @@ -10,12 +10,11 @@ ******************************************************************************/ package forestry.core; -import javax.annotation.Nullable; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; import forestry.api.core.CamouflageManager; import forestry.api.core.ICamouflageAccess; import forestry.api.core.ICamouflageItemHandler; @@ -27,17 +26,14 @@ import net.minecraftforge.fml.common.Loader; public class CamouflageAccess implements ICamouflageAccess { - private static final Map> camouflageItemHandlers = new HashMap<>(); - private static final Map> camouflageItemBlacklist = new HashMap<>(); - private static final Map> blacklistedMods = new HashMap<>(); + private static final ListMultimap camouflageItemHandlers = ArrayListMultimap.create(); + private static final ListMultimap camouflageItemBlacklist = ArrayListMultimap.create(); + private static final ListMultimap blacklistedMods = ArrayListMultimap.create(); public static final ICamouflageItemHandler NONE = new CamouflageHandlerNone(); @Override public void registerCamouflageItemHandler(ICamouflageItemHandler itemHandler) { String type = itemHandler.getType(); - if (!camouflageItemHandlers.containsKey(type)) { - camouflageItemHandlers.put(type, new ArrayList<>()); - } List handlers = camouflageItemHandlers.get(type); if (!handlers.contains(itemHandler)) { @@ -48,13 +44,10 @@ public class CamouflageAccess implements ICamouflageAccess { } @Override - @Nullable public List getCamouflageItemHandler(String type) { if (type.equals(CamouflageManager.NONE)) { List handlers = new ArrayList<>(); - for (List handler : camouflageItemHandlers.values()) { - handlers.addAll(handler); - } + handlers.addAll(camouflageItemHandlers.values()); return handlers; } @@ -63,11 +56,8 @@ public class CamouflageAccess implements ICamouflageAccess { @Override public void addModIdToBlackList(String type, String modID) { - if (!blacklistedMods.containsKey(type)) { - blacklistedMods.put(type, new ArrayList<>()); - } if (!blacklistedMods.get(type).contains(modID)) { - blacklistedMods.get(type).add(modID); + blacklistedMods.put(type, modID); } } @@ -84,15 +74,13 @@ public class CamouflageAccess implements ICamouflageAccess { return; } } - if (!camouflageItemBlacklist.containsKey(type)) { - camouflageItemBlacklist.put(type, new ArrayList<>()); - } - camouflageItemBlacklist.get(type).add(camouflageBlock); + + camouflageItemBlacklist.put(type, camouflageBlock); } @Override public boolean isItemBlackListed(String type, ItemStack camouflageBlock) { - if (camouflageBlock.isEmpty() || Block.getBlockFromItem(camouflageBlock.getItem()) == Blocks.AIR || type != null && !camouflageItemBlacklist.containsKey(type)) { + if (camouflageBlock.isEmpty() || Block.getBlockFromItem(camouflageBlock.getItem()) == Blocks.AIR || !type.equals(CamouflageManager.NONE) && !camouflageItemBlacklist.containsKey(type)) { return false; } String modId = camouflageBlock.getItem().getRegistryName().getResourceDomain(); @@ -100,11 +88,9 @@ public class CamouflageAccess implements ICamouflageAccess { return true; } List camouflageItemBlacklisted; - if (type == null) { + if (type.equals(CamouflageManager.NONE)) { camouflageItemBlacklisted = new ArrayList<>(); - for (List stacks : camouflageItemBlacklist.values()) { - camouflageItemBlacklisted.addAll(stacks); - } + camouflageItemBlacklisted.addAll(camouflageItemBlacklist.values()); } else { camouflageItemBlacklisted = camouflageItemBlacklist.get(type); } @@ -116,7 +102,7 @@ public class CamouflageAccess implements ICamouflageAccess { return false; } - + @Override public ICamouflageItemHandler getNoneItemHandler() { return NONE; @@ -127,11 +113,9 @@ public class CamouflageAccess implements ICamouflageAccess { if (stack.isEmpty()) { return NONE; } - for (List handlers : camouflageItemHandlers.values()) { - for (ICamouflageItemHandler handler : handlers) { - if (handler.canHandle(stack)) { - return handler; - } + for (ICamouflageItemHandler handler : camouflageItemHandlers.values()) { + if (handler.canHandle(stack)) { + return handler; } } return NONE; diff --git a/src/main/java/forestry/core/commands/CommandModeInfo.java b/src/main/java/forestry/core/commands/CommandModeInfo.java index 63516b969..bc3f91a0d 100644 --- a/src/main/java/forestry/core/commands/CommandModeInfo.java +++ b/src/main/java/forestry/core/commands/CommandModeInfo.java @@ -42,7 +42,7 @@ public class CommandModeInfo extends SubCommand { return; } - String modeName = modeHelper.getModeNameMatching(args[0]); + String modeName = args[0]; if (modeName == null) { CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.info.error", args[0]); diff --git a/src/main/java/forestry/core/commands/CommandModeSet.java b/src/main/java/forestry/core/commands/CommandModeSet.java index 2d8d77cbb..973f3308b 100644 --- a/src/main/java/forestry/core/commands/CommandModeSet.java +++ b/src/main/java/forestry/core/commands/CommandModeSet.java @@ -41,17 +41,14 @@ public final class CommandModeSet extends SubCommand { World world = sender.getEntityWorld(); - String desired = args[args.length - 1]; + String modeName = args[args.length - 1]; - String modeName = modeSetter.getModeNameMatching(desired); - if (modeName == null) { - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.set.error", desired); + if (modeSetter.setMode(world, modeName)) { + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.set.success", modeName); + } else { + CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.set.error", modeName); printHelp(sender); - return; } - - modeSetter.setMode(world, modeName); - CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.mode.set.success", modeName); } @Override diff --git a/src/main/java/forestry/core/commands/ICommandModeHelper.java b/src/main/java/forestry/core/commands/ICommandModeHelper.java index 70574e258..798c2e0f4 100644 --- a/src/main/java/forestry/core/commands/ICommandModeHelper.java +++ b/src/main/java/forestry/core/commands/ICommandModeHelper.java @@ -10,19 +10,14 @@ ******************************************************************************/ package forestry.core.commands; -import javax.annotation.Nullable; - import net.minecraft.world.World; public interface ICommandModeHelper { String[] getModeNames(); - @Nullable - String getModeNameMatching(String desired); - String getModeName(World world); - void setMode(World world, String modeName); + boolean setMode(World world, String modeName); Iterable getDescription(String modeName); } diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleRegistry.java b/src/main/java/forestry/core/genetics/alleles/AlleleRegistry.java index 6b6d5df7d..783321883 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleRegistry.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleRegistry.java @@ -90,9 +90,9 @@ public class AlleleRegistry implements IAlleleRegistry { @Override @Nullable - public ISpeciesRoot getSpeciesRoot(Class clz) { + public ISpeciesRoot getSpeciesRoot(Class individualClass) { for (ISpeciesRoot root : rootMap.values()) { - if (root.getMemberClass().isAssignableFrom(clz)) { + if (root.getMemberClass().isAssignableFrom(individualClass)) { return root; } } diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleSpecies.java b/src/main/java/forestry/core/genetics/alleles/AlleleSpecies.java index 904a075ab..05fc98714 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleSpecies.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleSpecies.java @@ -34,6 +34,7 @@ import forestry.core.utils.Translator; import forestry.plugins.ForestryPluginUids; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuilder, IAlleleSpecies { @@ -115,7 +116,7 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil } @Override - public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { + public NonNullList getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { if (world.rand.nextFloat() < bountyLevel / 16.0f) { List allMutations = getRoot().getCombinations(this); if (!allMutations.isEmpty()) { @@ -135,11 +136,13 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil } ItemStack researchNote = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, chosenMutation); - return new ItemStack[]{researchNote}; + NonNullList bounty = NonNullList.create(); + bounty.add(researchNote); + return bounty; } } - return ItemStackUtil.EMPTY_STACK_ARRAY; + return NonNullList.create(); } @Override diff --git a/src/main/java/forestry/factory/recipes/CentrifugeRecipe.java b/src/main/java/forestry/factory/recipes/CentrifugeRecipe.java index ff20e2311..34657d30a 100644 --- a/src/main/java/forestry/factory/recipes/CentrifugeRecipe.java +++ b/src/main/java/forestry/factory/recipes/CentrifugeRecipe.java @@ -10,15 +10,13 @@ ******************************************************************************/ package forestry.factory.recipes; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.Random; import com.google.common.collect.ImmutableMap; import forestry.api.recipes.ICentrifugeRecipe; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class CentrifugeRecipe implements ICentrifugeRecipe { @@ -49,8 +47,8 @@ public class CentrifugeRecipe implements ICentrifugeRecipe { } @Override - public Collection getProducts(Random random) { - List products = new ArrayList<>(); + public NonNullList getProducts(Random random) { + NonNullList products = NonNullList.create(); for (Map.Entry entry : this.outputs.entrySet()) { float probability = entry.getValue(); diff --git a/src/main/java/forestry/lepidopterology/genetics/alleles/AlleleButterflySpecies.java b/src/main/java/forestry/lepidopterology/genetics/alleles/AlleleButterflySpecies.java index bbf6d02f8..c42f29d3b 100644 --- a/src/main/java/forestry/lepidopterology/genetics/alleles/AlleleButterflySpecies.java +++ b/src/main/java/forestry/lepidopterology/genetics/alleles/AlleleButterflySpecies.java @@ -32,6 +32,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.BiomeDictionary; @@ -149,8 +150,11 @@ public class AlleleButterflySpecies extends AlleleSpecies implements IAlleleButt } @Override - public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { - return new ItemStack[]{getRoot().getMemberStack(individual.copy(), EnumFlutterType.SERUM)}; + public NonNullList getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) { + ItemStack serum = getRoot().getMemberStack(individual.copy(), EnumFlutterType.SERUM); + NonNullList bounty = NonNullList.create(); + bounty.add(serum); + return bounty; } /* OTHER */