pickFruit(ItemStack tool);
/**
* @return float indicating the ripeness of the fruit with >= 1.0f indicating full ripeness.
diff --git a/src/main/java/forestry/api/genetics/IGenome.java b/src/main/java/forestry/api/genetics/IGenome.java
index a74bad3ac..156fe2d7e 100644
--- a/src/main/java/forestry/api/genetics/IGenome.java
+++ b/src/main/java/forestry/api/genetics/IGenome.java
@@ -5,34 +5,26 @@
******************************************************************************/
package forestry.api.genetics;
-import javax.annotation.Nonnull;
-
import forestry.api.core.INbtWritable;
/**
* Holds the {@link IChromosome}s which comprise the traits of a given individual.
- *
+ *
* Only the default implementation is supported.
*/
public interface IGenome extends INbtWritable {
- @Nonnull
IAlleleSpecies getPrimary();
- @Nonnull
IAlleleSpecies getSecondary();
- @Nonnull
IChromosome[] getChromosomes();
- @Nonnull
IAllele getActiveAllele(IChromosomeType chromosomeType);
- @Nonnull
IAllele getInactiveAllele(IChromosomeType chromosomeType);
boolean isGeneticEqual(IGenome other);
- @Nonnull
ISpeciesRoot getSpeciesRoot();
}
diff --git a/src/main/java/forestry/api/genetics/IIndividual.java b/src/main/java/forestry/api/genetics/IIndividual.java
index 0e473f157..e470860dd 100644
--- a/src/main/java/forestry/api/genetics/IIndividual.java
+++ b/src/main/java/forestry/api/genetics/IIndividual.java
@@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.genetics;
-import javax.annotation.Nonnull;
import java.util.List;
import forestry.api.core.INbtWritable;
@@ -35,7 +34,6 @@ public interface IIndividual extends INbtWritable {
boolean isSecret();
- @Nonnull
IGenome getGenome();
/**
diff --git a/src/main/java/forestry/api/genetics/IIndividualLiving.java b/src/main/java/forestry/api/genetics/IIndividualLiving.java
index a1f8c7598..e90737630 100644
--- a/src/main/java/forestry/api/genetics/IIndividualLiving.java
+++ b/src/main/java/forestry/api/genetics/IIndividualLiving.java
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.genetics;
+import javax.annotation.Nullable;
+
import net.minecraft.world.World;
public interface IIndividualLiving extends IIndividual {
@@ -12,6 +14,7 @@ public interface IIndividualLiving extends IIndividual {
/**
* @return Genetic information of the mate, null if unmated.
*/
+ @Nullable
IGenome getMate();
/**
diff --git a/src/main/java/forestry/api/genetics/ISpeciesRoot.java b/src/main/java/forestry/api/genetics/ISpeciesRoot.java
index 9b3caea73..bc694c1bc 100644
--- a/src/main/java/forestry/api/genetics/ISpeciesRoot.java
+++ b/src/main/java/forestry/api/genetics/ISpeciesRoot.java
@@ -6,7 +6,6 @@
package forestry.api.genetics;
import javax.annotation.Nullable;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -39,6 +38,7 @@ public interface ISpeciesRoot {
/**
* Used to check whether a given itemstack contains genetic data corresponding to an {@link IIndividual} of this class.
+ *
* @param stack itemstack to check.
* @return true if the itemstack contains an {@link IIndividual} of this class, false otherwise.
*/
@@ -46,14 +46,16 @@ public interface ISpeciesRoot {
/**
* Used to check whether a given itemstack contains genetic data corresponding to an {@link IIndividual} of this class and matches the given type.
+ *
* @param stack itemstack to check.
- * @param type Integer denoting the type needed to match. (i.e. butterfly vs. butterfly serum; bee queens, princesses, drones; etc.)
+ * @param type Integer denoting the type needed to match. (i.e. butterfly vs. butterfly serum; bee queens, princesses, drones; etc.)
* @return true if the itemstack contains an {@link IIndividual} of this class, false otherwise.
*/
boolean isMember(ItemStack stack, ISpeciesType type);
/**
* Used to check whether the given {@link IIndividual} is member of this class.
+ *
* @param individual {@link IIndividual} to check.
* @return true if the individual is member of this class, false otherwise.
*/
@@ -66,13 +68,15 @@ public interface ISpeciesRoot {
@Nullable
ISpeciesType getType(ItemStack itemStack);
- /** Species type used to represent this species in icons */
+ /**
+ * Species type used to represent this species in icons
+ */
ISpeciesType getIconType();
ItemStack getMemberStack(IIndividual individual, ISpeciesType type);
/* BREEDING TRACKER */
- IBreedingTracker getBreedingTracker(World world, GameProfile player);
+ IBreedingTracker getBreedingTracker(World world, @Nullable GameProfile player);
/* GENOME MANIPULATION */
IIndividual templateAsIndividual(IAllele[] template);
@@ -109,6 +113,7 @@ public interface ISpeciesRoot {
* @param identifier species UID
* @return Array of {@link IAllele} representing a genome.
*/
+ @Nullable
IAllele[] getTemplate(String identifier);
/**
@@ -124,7 +129,7 @@ public interface ISpeciesRoot {
Map getGenomeTemplates();
- ArrayList extends IIndividual> getIndividualTemplates();
+ List extends IIndividual> getIndividualTemplates();
/* MUTATIONS */
@@ -147,8 +152,8 @@ public interface ISpeciesRoot {
List extends IMutation> getCombinations(IAllele other);
/**
- * @since Forestry 3.7
* @return all possible mutations that result from breeding two species
+ * @since Forestry 3.7
*/
List getCombinations(IAlleleSpecies parentSpecies0, IAlleleSpecies parentSpecies1, boolean shuffle);
@@ -163,7 +168,8 @@ public interface ISpeciesRoot {
/**
* Sets an item stack as a valid (generic) research catalyst for this class.
- * @param itemstack ItemStack to set as suitable.
+ *
+ * @param itemstack ItemStack to set as suitable.
* @param suitability Float between 0 and 1 to indicate suitability.
*/
void setResearchSuitability(ItemStack itemstack, float suitability);
diff --git a/src/main/java/forestry/api/genetics/ISpeciesRootPollinatable.java b/src/main/java/forestry/api/genetics/ISpeciesRootPollinatable.java
index 368517582..76cecc295 100644
--- a/src/main/java/forestry/api/genetics/ISpeciesRootPollinatable.java
+++ b/src/main/java/forestry/api/genetics/ISpeciesRootPollinatable.java
@@ -1,5 +1,7 @@
package forestry.api.genetics;
+import javax.annotation.Nullable;
+
import com.mojang.authlib.GameProfile;
import net.minecraft.util.math.BlockPos;
@@ -12,7 +14,8 @@ import net.minecraft.world.World;
public interface ISpeciesRootPollinatable extends ISpeciesRoot {
ICheckPollinatable createPollinatable(IIndividual individual);
-
- IPollinatable tryConvertToPollinatable(GameProfile owner, World world, final BlockPos pos, final IIndividual pollen);
+
+ @Nullable
+ IPollinatable tryConvertToPollinatable(@Nullable GameProfile owner, World world, final BlockPos pos, final IIndividual pollen);
}
diff --git a/src/main/java/forestry/api/genetics/package-info.java b/src/main/java/forestry/api/genetics/package-info.java
index 58ecf21d7..845f5a609 100644
--- a/src/main/java/forestry/api/genetics/package-info.java
+++ b/src/main/java/forestry/api/genetics/package-info.java
@@ -3,7 +3,12 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
@API(apiVersion = "4.7.1", owner = "ForestryAPI|core", provides = "ForestryAPI|genetics")
package forestry.api.genetics;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import mcp.MethodsReturnNonnullByDefault;
import net.minecraftforge.fml.common.API;
diff --git a/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java b/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java
index 390e83261..4bbeb8e63 100644
--- a/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java
+++ b/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java
@@ -5,71 +5,64 @@
******************************************************************************/
package forestry.api.greenhouse;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.minecraftforge.fml.common.eventhandler.Event;
-
import forestry.api.core.ICamouflageHandler;
import forestry.api.core.ICamouflagedTile;
import forestry.api.multiblock.IGreenhouseController;
+import net.minecraftforge.fml.common.eventhandler.Event;
public class GreenhouseEvents extends Event {
-
+
@Nullable
public final IGreenhouseController controller;
-
+
public GreenhouseEvents(@Nullable IGreenhouseController state) {
this.controller = state;
}
-
- public static class CamouflageChangeEvent extends GreenhouseEvents{
+
+ public static class CamouflageChangeEvent extends GreenhouseEvents {
@Nullable
- public ICamouflagedTile camouflagedBlock;
- @Nonnull
- public ICamouflageHandler camouflageHandler;
- @Nonnull
+ public final ICamouflagedTile camouflagedBlock;
+
+ public final ICamouflageHandler camouflageHandler;
+
public final String camouflageType;
-
- public CamouflageChangeEvent(IGreenhouseController controller, @Nullable ICamouflagedTile camouflagedBlock, @Nonnull ICamouflageHandler camouflageHandler, @Nonnull String camouflageType) {
+
+ public CamouflageChangeEvent(IGreenhouseController controller, @Nullable ICamouflagedTile camouflagedBlock, ICamouflageHandler camouflageHandler, String camouflageType) {
super(controller);
-
+
this.camouflagedBlock = camouflagedBlock;
this.camouflageHandler = camouflageHandler;
this.camouflageType = camouflageType;
}
}
-
- public static class InternalBlockEvent extends GreenhouseEvents{
- @Nonnull
- public IInternalBlock internalBlock;
-
- public InternalBlockEvent(IGreenhouseController controller, @Nonnull IInternalBlock internalBlock) {
+ public static class InternalBlockEvent extends GreenhouseEvents {
+ public final IInternalBlock internalBlock;
+
+ public InternalBlockEvent(IGreenhouseController controller, IInternalBlock internalBlock) {
super(controller);
-
- this.internalBlock = internalBlock;
- }
- }
-
- public static class CreateInternalBlockEvent extends InternalBlockEvent{
+ this.internalBlock = internalBlock;
+ }
+ }
+
+ public static class CreateInternalBlockEvent extends InternalBlockEvent {
public CreateInternalBlockEvent(IGreenhouseController controller, IInternalBlock internalBlock) {
super(controller, internalBlock);
}
}
-
- public static class CheckInternalBlockFaceEvent extends InternalBlockEvent{
- @Nonnull
+ public static class CheckInternalBlockFaceEvent extends InternalBlockEvent {
public final IInternalBlockFace face;
-
- public CheckInternalBlockFaceEvent(IGreenhouseController controller, IInternalBlock internalBlock, @Nonnull IInternalBlockFace face) {
+
+ public CheckInternalBlockFaceEvent(IGreenhouseController controller, IInternalBlock internalBlock, IInternalBlockFace face) {
super(controller, internalBlock);
-
+
this.face = face;
}
}
-
+
}
diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java b/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java
index d83cdbcd0..3ee9eb4ff 100644
--- a/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java
+++ b/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java
@@ -5,6 +5,7 @@
******************************************************************************/
package forestry.api.greenhouse;
+import javax.annotation.Nullable;
import java.util.List;
import forestry.api.multiblock.IGreenhouseController;
@@ -16,6 +17,7 @@ public interface IGreenhouseHelper {
/**
* @return A {@link IGreenhouseController} of a greenhouse, when the pos is a greenhouse
*/
+ @Nullable
IGreenhouseController getGreenhouseController(World world, BlockPos pos);
void addGreenhouseLogic(Class extends IGreenhouseLogic> logic);
diff --git a/src/main/java/forestry/api/greenhouse/IInternalBlock.java b/src/main/java/forestry/api/greenhouse/IInternalBlock.java
index 1adf10009..b2dfdea62 100644
--- a/src/main/java/forestry/api/greenhouse/IInternalBlock.java
+++ b/src/main/java/forestry/api/greenhouse/IInternalBlock.java
@@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.greenhouse;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
@@ -13,14 +12,12 @@ import java.util.Collection;
import net.minecraft.util.math.BlockPos;
public interface IInternalBlock {
-
- @Nonnull
+
BlockPos getPos();
@Nullable
IInternalBlock getRoot();
-
- @Nonnull
+
Collection getFaces();
}
diff --git a/src/main/java/forestry/api/greenhouse/IInternalBlockFace.java b/src/main/java/forestry/api/greenhouse/IInternalBlockFace.java
index 2845b18aa..5878b4995 100644
--- a/src/main/java/forestry/api/greenhouse/IInternalBlockFace.java
+++ b/src/main/java/forestry/api/greenhouse/IInternalBlockFace.java
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.greenhouse;
-import javax.annotation.Nonnull;
-
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
@@ -15,11 +13,9 @@ public interface IInternalBlockFace {
boolean isTested();
void setTested(boolean tested);
-
- @Nonnull
+
EnumFacing getFace();
-
- @Nonnull
+
BlockPos getPos();
}
diff --git a/src/main/java/forestry/api/greenhouse/package-info.java b/src/main/java/forestry/api/greenhouse/package-info.java
index 5a7854a19..277b4b76c 100644
--- a/src/main/java/forestry/api/greenhouse/package-info.java
+++ b/src/main/java/forestry/api/greenhouse/package-info.java
@@ -3,7 +3,12 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
@API(apiVersion = "5.2.0", owner = "ForestryAPI|core", provides = "ForestryAPI|greenhouse")
package forestry.api.greenhouse;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import mcp.MethodsReturnNonnullByDefault;
import net.minecraftforge.fml.common.API;
diff --git a/src/main/java/forestry/api/lepidopterology/EnumButterflyChromosome.java b/src/main/java/forestry/api/lepidopterology/EnumButterflyChromosome.java
index 7939ab472..145f5da72 100644
--- a/src/main/java/forestry/api/lepidopterology/EnumButterflyChromosome.java
+++ b/src/main/java/forestry/api/lepidopterology/EnumButterflyChromosome.java
@@ -72,15 +72,15 @@ public enum EnumButterflyChromosome implements IChromosomeType {
COCOON(IAlleleButterflyCocoon.class);
- Class extends IAllele> clss;
+ private final Class extends IAllele> alleleClass;
- EnumButterflyChromosome(Class extends IAllele> clss) {
- this.clss = clss;
+ EnumButterflyChromosome(Class extends IAllele> alleleClass) {
+ this.alleleClass = alleleClass;
}
@Override
public Class extends IAllele> getAlleleClass() {
- return clss;
+ return alleleClass;
}
@Override
diff --git a/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java b/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java
index b4765a054..504e281cd 100644
--- a/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java
+++ b/src/main/java/forestry/api/lepidopterology/IAlleleButterflySpecies.java
@@ -5,19 +5,17 @@
******************************************************************************/
package forestry.api.lepidopterology;
-import java.util.EnumSet;
import java.util.Map;
+import java.util.Set;
+import forestry.api.genetics.IAlleleSpecies;
import net.minecraft.item.ItemStack;
-
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-import forestry.api.genetics.IAlleleSpecies;
-
public interface IAlleleButterflySpecies extends IAlleleSpecies {
-
+
/**
* @return the IBeeRoot
*/
@@ -28,46 +26,46 @@ public interface IAlleleButterflySpecies extends IAlleleSpecies {
* @return Path of the texture to use for entity rendering.
*/
String getEntityTexture();
-
+
/**
* @return Path of the texture to use for item model.
*/
String getItemTexture();
-
+
/**
* Allows butterflies to restrict random spawns beyond the restrictions set by getTemperature() and getHumidity().
*
* @return EnumSet of biome tags this butterfly species can be spawned in.
*/
- EnumSet getSpawnBiomes();
-
+ Set getSpawnBiomes();
+
/**
* @return true if a prospective spawn biome must not match a biome tag outside of getSpawnBiomes.
*/
boolean strictSpawnMatch();
-
+
/**
* @return Float between 0 and 1 representing the rarity of the species, will affect spawn rate.
*/
float getRarity();
-
+
/**
* @return Float representing the distance below which this butterfly will take flight if it detects a player which is not sneaking.
*/
float getFlightDistance();
-
+
/**
* @return true if this species is only active at night.
*/
boolean isNocturnal();
-
+
Map getButterflyLoot();
-
+
Map getCaterpillarLoot();
-
+
@SideOnly(Side.CLIENT)
void registerSprites();
-
+
/**
* @return The modid from the mod of the species.
*/
diff --git a/src/main/java/forestry/api/lepidopterology/IButterfly.java b/src/main/java/forestry/api/lepidopterology/IButterfly.java
index cce055e83..6f03633f1 100644
--- a/src/main/java/forestry/api/lepidopterology/IButterfly.java
+++ b/src/main/java/forestry/api/lepidopterology/IButterfly.java
@@ -5,16 +5,15 @@
******************************************************************************/
package forestry.api.lepidopterology;
-import javax.annotation.Nonnull;
-
-import net.minecraft.item.ItemStack;
-import net.minecraft.world.World;
+import javax.annotation.Nullable;
import forestry.api.genetics.IIndividualLiving;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
+import net.minecraft.world.World;
public interface IButterfly extends IIndividualLiving {
- @Nonnull
@Override
IButterflyGenome getGenome();
@@ -28,7 +27,7 @@ public interface IButterfly extends IIndividualLiving {
* @return Physical size of the butterfly.
*/
float getSize();
-
+
/**
* @param world
* @param x
@@ -60,30 +59,31 @@ public interface IButterfly extends IIndividualLiving {
* @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.
+ * @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.
*/
- ItemStack[] getLootDrop(IEntityButterfly entity, boolean playerKill, int lootLevel);
+ 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.
+ * @param lootLevel Fortune level.
* @return Array of itemstacks to drop on breaking of the nursery.
*/
- ItemStack[] getCaterpillarDrop(IButterflyNursery nursery, boolean playerKill, int lootLevel);
-
+ NonNullList getCaterpillarDrop(IButterflyNursery nursery, boolean playerKill, int lootLevel);
+
/**
* @param cocoon
* @return Array of itemstacks to drop on breaking of the cocoon.
*/
- ItemStack[] getCocoonDrop(IButterflyCocoon cocoon);
-
+ NonNullList getCocoonDrop(IButterflyCocoon cocoon);
+
/**
* Create an exact copy of this butterfly.
*/
diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyCocoon.java b/src/main/java/forestry/api/lepidopterology/IButterflyCocoon.java
index 170eb786b..c6f1731e3 100644
--- a/src/main/java/forestry/api/lepidopterology/IButterflyCocoon.java
+++ b/src/main/java/forestry/api/lepidopterology/IButterflyCocoon.java
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.api.lepidopterology;
+import javax.annotation.Nullable;
+
import forestry.api.genetics.IHousing;
public interface IButterflyCocoon extends IHousing{
@@ -17,7 +19,8 @@ public interface IButterflyCocoon extends IHousing{
IButterfly getCaterpillar();
void setCaterpillar(IButterfly butterfly);
-
+
+ @Nullable
IButterflyNursery getNursery();
void setNursery(IButterflyNursery nursery);
diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyGenome.java b/src/main/java/forestry/api/lepidopterology/IButterflyGenome.java
index 03c4e75ac..5d29db942 100644
--- a/src/main/java/forestry/api/lepidopterology/IButterflyGenome.java
+++ b/src/main/java/forestry/api/lepidopterology/IButterflyGenome.java
@@ -5,20 +5,16 @@
******************************************************************************/
package forestry.api.lepidopterology;
-import javax.annotation.Nonnull;
-
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IGenome;
public interface IButterflyGenome extends IGenome {
-
+
@Override
- @Nonnull
IAlleleButterflySpecies getPrimary();
@Override
- @Nonnull
IAlleleButterflySpecies getSecondary();
float getSize();
@@ -26,7 +22,7 @@ public interface IButterflyGenome extends IGenome {
int getLifespan();
int getMetabolism();
-
+
int getFertility();
float getSpeed();
@@ -44,7 +40,7 @@ public interface IButterflyGenome extends IGenome {
IFlowerProvider getFlowerProvider();
IAlleleButterflyEffect getEffect();
-
+
IAlleleButterflyCocoon getCocoon();
}
diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java b/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java
index eb956030e..2a03c3b9b 100644
--- a/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java
+++ b/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java
@@ -5,17 +5,19 @@
******************************************************************************/
package forestry.api.lepidopterology;
+import javax.annotation.Nullable;
+
import forestry.api.climate.IClimateProvider;
import forestry.api.genetics.IHousing;
import forestry.api.genetics.IIndividual;
public interface IButterflyNursery extends IHousing, IClimateProvider {
-
+ @Nullable
IButterfly getCaterpillar();
IIndividual getNanny();
- void setCaterpillar(IButterfly butterfly);
+ void setCaterpillar(@Nullable IButterfly butterfly);
boolean canNurse(IButterfly butterfly);
diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java b/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java
index c0aff0bdb..d6a73355c 100644
--- a/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java
+++ b/src/main/java/forestry/api/lepidopterology/IButterflyRoot.java
@@ -6,7 +6,6 @@
package forestry.api.lepidopterology;
import javax.annotation.Nullable;
-import java.util.ArrayList;
import java.util.List;
import com.mojang.authlib.GameProfile;
@@ -43,15 +42,16 @@ public interface IButterflyRoot extends ISpeciesRoot {
/* BUTTERFLY SPECIFIC */
@Override
- ILepidopteristTracker getBreedingTracker(World world, GameProfile player);
+ ILepidopteristTracker getBreedingTracker(World world, @Nullable GameProfile player);
/**
* 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);
-
+
boolean plantCocoon(World world, IButterflyNursery nursery, GameProfile owner, int age);
/**
@@ -61,7 +61,7 @@ public interface IButterflyRoot extends ISpeciesRoot {
/* TEMPLATES */
@Override
- ArrayList getIndividualTemplates();
+ List getIndividualTemplates();
/* MUTATIONS */
@Override
diff --git a/src/main/java/forestry/api/lepidopterology/IEntityButterfly.java b/src/main/java/forestry/api/lepidopterology/IEntityButterfly.java
index 7716170f0..328cc584d 100644
--- a/src/main/java/forestry/api/lepidopterology/IEntityButterfly.java
+++ b/src/main/java/forestry/api/lepidopterology/IEntityButterfly.java
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.lepidopterology;
+import javax.annotation.Nullable;
+
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
@@ -23,9 +25,10 @@ public interface IEntityButterfly extends IAnimals {
*/
EntityCreature getEntity();
+ @Nullable
IIndividual getPollen();
- void setPollen(IIndividual pollen);
+ void setPollen(@Nullable IIndividual pollen);
boolean canMateWith(IEntityButterfly butterfly);
diff --git a/src/main/java/forestry/api/lepidopterology/package-info.java b/src/main/java/forestry/api/lepidopterology/package-info.java
index ad9aef2e9..4610d9a33 100644
--- a/src/main/java/forestry/api/lepidopterology/package-info.java
+++ b/src/main/java/forestry/api/lepidopterology/package-info.java
@@ -3,7 +3,12 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
@API(apiVersion = "1.3.0", owner = "ForestryAPI|core", provides = "ForestryAPI|lepidopterology")
package forestry.api.lepidopterology;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import mcp.MethodsReturnNonnullByDefault;
import net.minecraftforge.fml.common.API;
diff --git a/src/main/java/forestry/api/mail/EnumAddressee.java b/src/main/java/forestry/api/mail/EnumAddressee.java
index 7b4482d36..7327e4465 100644
--- a/src/main/java/forestry/api/mail/EnumAddressee.java
+++ b/src/main/java/forestry/api/mail/EnumAddressee.java
@@ -5,11 +5,13 @@
******************************************************************************/
package forestry.api.mail;
+import javax.annotation.Nullable;
import java.util.Locale;
public enum EnumAddressee {
PLAYER, TRADER;
-
+
+ @Nullable
public static EnumAddressee fromString(String ident) {
ident = ident.toLowerCase(Locale.ENGLISH);
for (EnumAddressee addr : values()) {
diff --git a/src/main/java/forestry/api/mail/EnumTradeStationState.java b/src/main/java/forestry/api/mail/EnumTradeStationState.java
index 609a20bf3..139d762b6 100644
--- a/src/main/java/forestry/api/mail/EnumTradeStationState.java
+++ b/src/main/java/forestry/api/mail/EnumTradeStationState.java
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.mail;
-import javax.annotation.Nonnull;
-
import net.minecraft.util.text.translation.I18n;
public enum EnumTradeStationState implements IPostalState {
@@ -19,7 +17,7 @@ public enum EnumTradeStationState implements IPostalState {
private final String unlocalizedDescription;
- EnumTradeStationState(@Nonnull String unlocalizedDescription) {
+ EnumTradeStationState(String unlocalizedDescription) {
this.unlocalizedDescription = unlocalizedDescription;
}
diff --git a/src/main/java/forestry/api/mail/ILetter.java b/src/main/java/forestry/api/mail/ILetter.java
index 661ebb5ae..016143927 100644
--- a/src/main/java/forestry/api/mail/ILetter.java
+++ b/src/main/java/forestry/api/mail/ILetter.java
@@ -5,16 +5,18 @@
******************************************************************************/
package forestry.api.mail;
+import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import forestry.api.core.INbtWritable;
+import net.minecraft.util.NonNullList;
public interface ILetter extends IInventory, INbtWritable {
- ItemStack[] getPostage();
+ NonNullList getPostage();
void setProcessed(boolean flag);
@@ -28,9 +30,10 @@ public interface ILetter extends IInventory, INbtWritable {
boolean hasRecipient();
- void setRecipient(IMailAddress address);
+ void setRecipient(@Nullable IMailAddress address);
- IMailAddress[] getRecipients();
+ @Nullable
+ IMailAddress getRecipient();
String getRecipientString();
@@ -46,11 +49,11 @@ public interface ILetter extends IInventory, INbtWritable {
void invalidatePostage();
- ItemStack[] getAttachments();
+ NonNullList getAttachments();
void addAttachment(ItemStack itemstack);
- void addAttachments(ItemStack[] itemstacks);
+ void addAttachments(NonNullList itemstacks);
int countAttachments();
diff --git a/src/main/java/forestry/api/mail/IMailAddress.java b/src/main/java/forestry/api/mail/IMailAddress.java
index 956245ca6..5733d97c3 100644
--- a/src/main/java/forestry/api/mail/IMailAddress.java
+++ b/src/main/java/forestry/api/mail/IMailAddress.java
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.mail;
+import javax.annotation.Nullable;
+
import com.mojang.authlib.GameProfile;
import forestry.api.core.INbtWritable;
@@ -17,5 +19,6 @@ public interface IMailAddress extends INbtWritable {
boolean isValid();
+ @Nullable
GameProfile getPlayerProfile();
}
diff --git a/src/main/java/forestry/api/mail/IPostOffice.java b/src/main/java/forestry/api/mail/IPostOffice.java
index b97a0715b..298bec0c2 100644
--- a/src/main/java/forestry/api/mail/IPostOffice.java
+++ b/src/main/java/forestry/api/mail/IPostOffice.java
@@ -8,11 +8,12 @@ package forestry.api.mail;
import java.util.Map;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
public interface IPostOffice {
- void collectPostage(ItemStack[] stamps);
+ void collectPostage(NonNullList stamps);
IPostalState lodgeLetter(World world, ItemStack itemstack, boolean doLodge);
diff --git a/src/main/java/forestry/api/mail/IPostRegistry.java b/src/main/java/forestry/api/mail/IPostRegistry.java
index a5561d25c..15bd4af18 100644
--- a/src/main/java/forestry/api/mail/IPostRegistry.java
+++ b/src/main/java/forestry/api/mail/IPostRegistry.java
@@ -5,30 +5,29 @@
******************************************************************************/
package forestry.api.mail;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.Map;
+import com.mojang.authlib.GameProfile;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-import com.mojang.authlib.GameProfile;
-
public interface IPostRegistry {
/* POST OFFICE */
IPostOffice getPostOffice(World world);
/* MAIL ADDRESSES */
- @Nonnull
- IMailAddress getMailAddress(@Nonnull GameProfile gameProfile);
-
- IMailAddress getMailAddress(@Nonnull String traderName);
+ IMailAddress getMailAddress(GameProfile gameProfile);
+
+ IMailAddress getMailAddress(String traderName);
/* LETTERS */
boolean isLetter(ItemStack itemstack);
ILetter createLetter(IMailAddress sender, IMailAddress recipient);
+ @Nullable
ILetter getLetter(ItemStack itemstack);
ItemStack createLetterStack(ILetter letter);
@@ -37,10 +36,12 @@ public interface IPostRegistry {
/**
* Registers a new {@link IPostalCarrier}. See {@link IPostalCarrier} for details.
+ *
* @param carrier {@link IPostalCarrier} to register.
*/
void registerCarrier(IPostalCarrier carrier);
+ @Nullable
IPostalCarrier getCarrier(EnumAddressee uid);
Map getRegisteredCarriers();
@@ -50,6 +51,7 @@ public interface IPostRegistry {
ITradeStation getOrCreateTradeStation(World world, GameProfile owner, IMailAddress address);
+ @Nullable
ITradeStation getTradeStation(World world, IMailAddress address);
boolean isAvailableTradeAddress(World world, IMailAddress address);
diff --git a/src/main/java/forestry/api/mail/ITradeStationInfo.java b/src/main/java/forestry/api/mail/ITradeStationInfo.java
index cc0597cef..905acfb39 100644
--- a/src/main/java/forestry/api/mail/ITradeStationInfo.java
+++ b/src/main/java/forestry/api/mail/ITradeStationInfo.java
@@ -8,6 +8,7 @@ package forestry.api.mail;
import net.minecraft.item.ItemStack;
import com.mojang.authlib.GameProfile;
+import net.minecraft.util.NonNullList;
public interface ITradeStationInfo {
IMailAddress getAddress();
@@ -16,7 +17,7 @@ public interface ITradeStationInfo {
ItemStack getTradegood();
- ItemStack[] getRequired();
+ NonNullList getRequired();
EnumTradeStationState getState();
}
diff --git a/src/main/java/forestry/api/mail/package-info.java b/src/main/java/forestry/api/mail/package-info.java
index e191eccbb..6e927a554 100644
--- a/src/main/java/forestry/api/mail/package-info.java
+++ b/src/main/java/forestry/api/mail/package-info.java
@@ -3,7 +3,12 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
@API(apiVersion = "3.1.0", owner = "ForestryAPI|core", provides = "ForestryAPI|mail")
package forestry.api.mail;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import mcp.MethodsReturnNonnullByDefault;
import net.minecraftforge.fml.common.API;
diff --git a/src/main/java/forestry/api/multiblock/ICharcoalPileComponent.java b/src/main/java/forestry/api/multiblock/ICharcoalPileComponent.java
index 0f0ab76c3..f85d7cc3e 100644
--- a/src/main/java/forestry/api/multiblock/ICharcoalPileComponent.java
+++ b/src/main/java/forestry/api/multiblock/ICharcoalPileComponent.java
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.multiblock;
-import javax.annotation.Nonnull;
-
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.IAlleleTreeSpecies;
@@ -19,22 +17,21 @@ import net.minecraftforge.fml.relauncher.SideOnly;
* They are automatically detected and handled by the charcoal pile when they join its structure.
*/
public interface ICharcoalPileComponent extends IMultiblockComponent {
-
+
@Override
T getMultiblockLogic();
IAlleleTreeSpecies getTreeSpecies();
- void setTreeSpecies(@Nonnull IAlleleTreeSpecies treeSpecies);
-
+ void setTreeSpecies(IAlleleTreeSpecies treeSpecies);
+
@Override
- @Nonnull
GameProfile getOwner();
-
- void setOwner(@Nonnull GameProfile owner);
-
+
+ void setOwner(GameProfile owner);
+
EnumPileType getPileType();
-
+
@SideOnly(Side.CLIENT)
IAlleleTreeSpecies getNextWoodPile();
diff --git a/src/main/java/forestry/api/multiblock/IGreenhouseComponent.java b/src/main/java/forestry/api/multiblock/IGreenhouseComponent.java
index ae61c7997..cb55e69b3 100644
--- a/src/main/java/forestry/api/multiblock/IGreenhouseComponent.java
+++ b/src/main/java/forestry/api/multiblock/IGreenhouseComponent.java
@@ -12,6 +12,7 @@ import forestry.api.climate.IClimatiserDefinition;
import forestry.api.greenhouse.IGreenhouseListener;
import forestry.api.lepidopterology.IButterflyCocoon;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
public interface IGreenhouseComponent extends IMultiblockComponent {
@Override
@@ -35,7 +36,7 @@ public interface IGreenhouseComponent exte
}
interface ButterflyHatch extends IGreenhouseComponent {
- ItemStack[] addCocoonLoot(IButterflyCocoon cocoon);
+ NonNullList addCocoonLoot(IButterflyCocoon cocoon);
}
interface Active extends IGreenhouseComponent {
diff --git a/src/main/java/forestry/api/multiblock/IGreenhouseController.java b/src/main/java/forestry/api/multiblock/IGreenhouseController.java
index 1a9bba142..bc00e2de0 100644
--- a/src/main/java/forestry/api/multiblock/IGreenhouseController.java
+++ b/src/main/java/forestry/api/multiblock/IGreenhouseController.java
@@ -7,7 +7,6 @@ package forestry.api.multiblock;
import java.util.List;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import forestry.api.climate.IClimateControl;
@@ -34,7 +33,6 @@ public interface IGreenhouseController extends IMultiblockController, IGreenhous
IClimateRegion getRegion();
@Override
- @Nonnull
IClimateControl getClimateControl();
}
diff --git a/src/main/java/forestry/api/multiblock/IMultiblockComponent.java b/src/main/java/forestry/api/multiblock/IMultiblockComponent.java
index 42388c04c..d5744ee15 100644
--- a/src/main/java/forestry/api/multiblock/IMultiblockComponent.java
+++ b/src/main/java/forestry/api/multiblock/IMultiblockComponent.java
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.multiblock;
+import javax.annotation.Nullable;
+
import net.minecraft.util.math.BlockPos;
import com.mojang.authlib.GameProfile;
@@ -24,6 +26,7 @@ public interface IMultiblockComponent {
/**
* @return the gameProfile of the player who owns this single component (not the entire multiblock)
*/
+ @Nullable
GameProfile getOwner();
/**
diff --git a/src/main/java/forestry/api/multiblock/IMultiblockController.java b/src/main/java/forestry/api/multiblock/IMultiblockController.java
index f9e86bdd8..0b1d08a69 100644
--- a/src/main/java/forestry/api/multiblock/IMultiblockController.java
+++ b/src/main/java/forestry/api/multiblock/IMultiblockController.java
@@ -5,7 +5,7 @@
******************************************************************************/
package forestry.api.multiblock;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.Collection;
/**
@@ -31,11 +31,11 @@ public interface IMultiblockController {
* @return A string representing the last error encountered when trying to assemble this
* multiblock, or null if there is no error.
*/
+ @Nullable
String getLastValidationError();
/**
* @return all the multiblock components attached to this controller
*/
- @Nonnull
Collection getComponents();
}
diff --git a/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java b/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java
index baa2a15c3..9df5cc248 100644
--- a/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java
+++ b/src/main/java/forestry/api/multiblock/MultiblockTileEntityBase.java
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.multiblock;
-import javax.annotation.Nonnull;
-
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
@@ -46,8 +44,7 @@ public abstract class MultiblockTileEntityBase exten
super.readFromNBT(data);
multiblockLogic.readFromNBT(data);
}
-
- @Nonnull
+
@Override
public NBTTagCompound writeToNBT(NBTTagCompound data) {
data = super.writeToNBT(data);
@@ -58,30 +55,28 @@ public abstract class MultiblockTileEntityBase exten
@Override
public final void invalidate() {
super.invalidate();
- multiblockLogic.invalidate(worldObj, this);
+ multiblockLogic.invalidate(world, this);
}
@Override
public final void onChunkUnload() {
super.onChunkUnload();
- multiblockLogic.onChunkUnload(worldObj, this);
+ multiblockLogic.onChunkUnload(world, this);
}
@Override
public final void validate() {
super.validate();
- multiblockLogic.validate(worldObj, this);
+ multiblockLogic.validate(world, this);
}
/* Network Communication */
- @Nonnull
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
return new SPacketUpdateTileEntity(getPos(), 0, getUpdateTag());
}
- @Nonnull
@Override
public NBTTagCompound getUpdateTag() {
NBTTagCompound updateTag = super.getUpdateTag();
@@ -99,7 +94,7 @@ public abstract class MultiblockTileEntityBase exten
}
@Override
- public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
+ public void handleUpdateTag(NBTTagCompound tag) {
super.handleUpdateTag(tag);
multiblockLogic.decodeDescriptionPacket(tag);
this.decodeDescriptionPacket(tag);
diff --git a/src/main/java/forestry/api/multiblock/package-info.java b/src/main/java/forestry/api/multiblock/package-info.java
index d13db8ce3..d0cce41fb 100644
--- a/src/main/java/forestry/api/multiblock/package-info.java
+++ b/src/main/java/forestry/api/multiblock/package-info.java
@@ -3,7 +3,12 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
@API(apiVersion = "3.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|multiblock")
package forestry.api.multiblock;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import mcp.MethodsReturnNonnullByDefault;
import net.minecraftforge.fml.common.API;
diff --git a/src/main/java/forestry/api/recipes/ICarpenterManager.java b/src/main/java/forestry/api/recipes/ICarpenterManager.java
index accc0c199..62a22de91 100644
--- a/src/main/java/forestry/api/recipes/ICarpenterManager.java
+++ b/src/main/java/forestry/api/recipes/ICarpenterManager.java
@@ -5,6 +5,8 @@
******************************************************************************/
package forestry.api.recipes;
+import javax.annotation.Nullable;
+
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapedRecipes;
@@ -41,7 +43,7 @@ public interface ICarpenterManager extends ICraftingProvider {
* @param packagingTime
* Number of work cycles required to craft the recipe once.
* @param box
- * ItemStack of one item representing the required box (carton, crate) for this recipe. May be null.
+ * ItemStack of one item representing the required box (carton, crate) for this recipe. May be empty.
* @param product
* Crafting result.
* @param materials
@@ -57,11 +59,11 @@ public interface ICarpenterManager extends ICraftingProvider {
* @param liquid
* Liquid required in carpenter's tank.
* @param box
- * ItemStack of one item representing the required box (carton, crate) for this recipe. May be null.
+ * ItemStack of one item representing the required box (carton, crate) for this recipe. May be empty.
* @param product
* Crafting result.
* @param materials
* Materials needed in the crafting matrix. This gets passed directly to {@link ShapedRecipes}. Notation is the same.
*/
- void addRecipe(int packagingTime, FluidStack liquid, ItemStack box, ItemStack product, Object... materials);
+ void addRecipe(int packagingTime, @Nullable FluidStack liquid, ItemStack box, ItemStack product, Object... materials);
}
diff --git a/src/main/java/forestry/api/recipes/ICarpenterRecipe.java b/src/main/java/forestry/api/recipes/ICarpenterRecipe.java
index 12a465ee6..ba7558670 100644
--- a/src/main/java/forestry/api/recipes/ICarpenterRecipe.java
+++ b/src/main/java/forestry/api/recipes/ICarpenterRecipe.java
@@ -23,10 +23,9 @@ public interface ICarpenterRecipe extends IForestryRecipe {
IDescriptiveRecipe getCraftingGridRecipe();
/**
- * @return the box required for this recipe. return null if there is no required box.
+ * @return the box required for this recipe. return empty stack if there is no required box.
* Examples of boxes are the Forestry cartons and crates.
*/
- @Nullable
ItemStack getBox();
/**
diff --git a/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java b/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java
index 4fc8753ac..9054e8c9a 100644
--- a/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java
+++ b/src/main/java/forestry/api/recipes/IDescriptiveRecipe.java
@@ -5,17 +5,15 @@
******************************************************************************/
package forestry.api.recipes;
-import javax.annotation.Nonnull;
-
import net.minecraft.item.ItemStack;
-import net.minecraft.item.crafting.IRecipe;
+import net.minecraft.util.NonNullList;
/**
- * Extension of IRecipe to give better access to the expected crafting inputs.
+ * Replacement for IRecipe to give better access to the expected crafting inputs.
* It can be matched against regular IInventory instead of just InventoryCrafting.
* Useful for displaying crafting recipes.
*/
-public interface IDescriptiveRecipe extends IRecipe {
+public interface IDescriptiveRecipe {
/**
* @return width of the crafting ingredients in the crafting table
@@ -31,9 +29,7 @@ public interface IDescriptiveRecipe extends IRecipe {
* @return array of all the ingredients in the crafting table.
* Ingredients may be null, ItemStack, ItemStack[], or a List of ItemStack
*/
- Object[] getIngredients();
+ NonNullList> getIngredients();
- @Nonnull
- @Override
ItemStack getRecipeOutput();
}
diff --git a/src/main/java/forestry/api/recipes/IFabricatorRecipe.java b/src/main/java/forestry/api/recipes/IFabricatorRecipe.java
index d8bacaf80..7153d7541 100644
--- a/src/main/java/forestry/api/recipes/IFabricatorRecipe.java
+++ b/src/main/java/forestry/api/recipes/IFabricatorRecipe.java
@@ -5,10 +5,9 @@
******************************************************************************/
package forestry.api.recipes;
-import javax.annotation.Nullable;
-
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
public interface IFabricatorRecipe extends IForestryRecipe {
@@ -21,7 +20,7 @@ public interface IFabricatorRecipe extends IForestryRecipe {
/**
* @return the list of ingredients in the crafting grid to create this recipe.
*/
- Object[] getIngredients();
+ NonNullList> getIngredients();
/**
* @return the width of ingredients in the crafting grid to create this recipe.
@@ -34,9 +33,8 @@ public interface IFabricatorRecipe extends IForestryRecipe {
int getHeight();
/**
- * @return the plan for this recipe (the item in the top right slot).
+ * @return the plan for this recipe (the item in the top right slot). may be an empty ItemStack
*/
- @Nullable
ItemStack getPlan();
/**
diff --git a/src/main/java/forestry/api/recipes/ISqueezerManager.java b/src/main/java/forestry/api/recipes/ISqueezerManager.java
index 0635c4dff..c2fdff64a 100644
--- a/src/main/java/forestry/api/recipes/ISqueezerManager.java
+++ b/src/main/java/forestry/api/recipes/ISqueezerManager.java
@@ -5,10 +5,9 @@
******************************************************************************/
package forestry.api.recipes;
-import javax.annotation.Nullable;
-
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
/**
@@ -29,10 +28,21 @@ public interface ISqueezerManager extends ICraftingProvider {
* @param timePerItem Number of work cycles required to squeeze one set of resources.
* @param resources Array of item stacks representing the required resources for one process. Stack size will be taken into account.
* @param liquid {@link FluidStack} representing the output of this recipe.
- * @param remnants Item stack representing the possible remnants from this recipe.
+ * @param remnants Item stack representing the possible remnants from this recipe. May be empty.
* @param chance Chance remnants will be produced by a single recipe cycle, from 0 to 100.
*/
- void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid, ItemStack remnants, int chance);
+ void addRecipe(int timePerItem, NonNullList resources, FluidStack liquid, ItemStack remnants, int chance);
+
+ /**
+ * Add a recipe to the squeezer.
+ *
+ * @param timePerItem Number of work cycles required to squeeze one set of resources.
+ * @param resources item stack representing the required resources for one process. Stack size will be taken into account.
+ * @param liquid {@link FluidStack} representing the output of this recipe.
+ * @param remnants Item stack representing the possible remnants from this recipe. May be empty.
+ * @param chance Chance remnants will be produced by a single recipe cycle, from 0 to 100.
+ */
+ void addRecipe(int timePerItem, ItemStack resources, FluidStack liquid, ItemStack remnants, int chance);
/**
* Add a recipe to the squeezer.
@@ -41,7 +51,16 @@ public interface ISqueezerManager extends ICraftingProvider {
* @param resources Array of item stacks representing the required resources for one process. Stack size will be taken into account.
* @param liquid {@link FluidStack} representing the output of this recipe.
*/
- void addRecipe(int timePerItem, ItemStack[] resources, FluidStack liquid);
+ void addRecipe(int timePerItem, NonNullList resources, FluidStack liquid);
+
+ /**
+ * Add a recipe to the squeezer.
+ *
+ * @param timePerItem Number of work cycles required to squeeze one set of resources.
+ * @param resources item stack representing the required resources for one process. Stack size will be taken into account.
+ * @param liquid {@link FluidStack} representing the output of this recipe.
+ */
+ void addRecipe(int timePerItem, ItemStack resources, FluidStack liquid);
/**
* Add a recipe for a fluid container to the squeezer.
@@ -49,8 +68,8 @@ public interface ISqueezerManager extends ICraftingProvider {
*
* @param timePerItem Number of work cycles required to squeeze one set of resources.
* @param emptyContainer The empty version of the fluid container that will be squeezed.
- * @param remnants Item stack representing the possible remnants from this recipe.
+ * @param remnants Item stack representing the possible remnants from this recipe. May be empty.
* @param chance Chance remnants will be produced by a single recipe cycle, from 0 to 1.
*/
- void addContainerRecipe(int timePerItem, ItemStack emptyContainer, @Nullable ItemStack remnants, float chance);
+ void addContainerRecipe(int timePerItem, ItemStack emptyContainer, ItemStack remnants, float chance);
}
diff --git a/src/main/java/forestry/api/recipes/ISqueezerRecipe.java b/src/main/java/forestry/api/recipes/ISqueezerRecipe.java
index 820dc56b2..4cc23e9db 100644
--- a/src/main/java/forestry/api/recipes/ISqueezerRecipe.java
+++ b/src/main/java/forestry/api/recipes/ISqueezerRecipe.java
@@ -5,10 +5,9 @@
******************************************************************************/
package forestry.api.recipes;
-import javax.annotation.Nullable;
-
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.FluidStack;
public interface ISqueezerRecipe extends IForestryRecipe {
@@ -16,7 +15,7 @@ public interface ISqueezerRecipe extends IForestryRecipe {
/**
* @return Array of item stacks representing the required resources for one process. Stack size will be taken into account.
*/
- ItemStack[] getResources();
+ NonNullList getResources();
/**
* @return Number of work cycles required to squeeze one set of resources.
@@ -26,7 +25,6 @@ public interface ISqueezerRecipe extends IForestryRecipe {
/**
* @return Item stack representing the possible remnants from this recipe. (i.e. tin left over from tin cans)
*/
- @Nullable
ItemStack getRemnants();
/**
diff --git a/src/main/java/forestry/api/recipes/package-info.java b/src/main/java/forestry/api/recipes/package-info.java
index 9e4ec065c..33d4ca245 100644
--- a/src/main/java/forestry/api/recipes/package-info.java
+++ b/src/main/java/forestry/api/recipes/package-info.java
@@ -3,7 +3,12 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
@API(apiVersion = "5.4.0", owner = "ForestryAPI|core", provides = "ForestryAPI|recipes")
package forestry.api.recipes;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import mcp.MethodsReturnNonnullByDefault;
import net.minecraftforge.fml.common.API;
diff --git a/src/main/java/forestry/api/storage/BackpackEvent.java b/src/main/java/forestry/api/storage/BackpackEvent.java
index b7d4719d6..9bbe05b35 100644
--- a/src/main/java/forestry/api/storage/BackpackEvent.java
+++ b/src/main/java/forestry/api/storage/BackpackEvent.java
@@ -10,7 +10,6 @@ import net.minecraft.inventory.IInventory;
import net.minecraftforge.fml.common.eventhandler.Event;
-
public abstract class BackpackEvent extends Event {
public final EntityPlayer player;
diff --git a/src/main/java/forestry/api/storage/IBackpackDefinition.java b/src/main/java/forestry/api/storage/IBackpackDefinition.java
index 5bb2a6fa0..526451f7a 100644
--- a/src/main/java/forestry/api/storage/IBackpackDefinition.java
+++ b/src/main/java/forestry/api/storage/IBackpackDefinition.java
@@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.storage;
-import javax.annotation.Nonnull;
import java.util.function.Predicate;
import net.minecraft.item.ItemStack;
@@ -18,7 +17,6 @@ public interface IBackpackDefinition {
/**
* @return Human-readable name of the backpack.
*/
- @Nonnull
String getName(ItemStack backpack);
/**
@@ -41,6 +39,5 @@ public interface IBackpackDefinition {
*
* @return the backpack's item filter.
*/
- @Nonnull
Predicate getFilter();
}
diff --git a/src/main/java/forestry/api/storage/IBackpackInterface.java b/src/main/java/forestry/api/storage/IBackpackInterface.java
index 1e4234661..3683b90e8 100644
--- a/src/main/java/forestry/api/storage/IBackpackInterface.java
+++ b/src/main/java/forestry/api/storage/IBackpackInterface.java
@@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.storage;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.function.Predicate;
@@ -38,18 +37,18 @@ public interface IBackpackInterface {
* @param itemStack The itemStack that the backpack should accept.
* {@link OreDictionary#WILDCARD_VALUE} can be used for meta value.
*/
- void addItemToForestryBackpack(@Nonnull String backpackUid, @Nonnull ItemStack itemStack);
+ void addItemToForestryBackpack(String backpackUid, ItemStack itemStack);
/**
* Register a backpack definition with a given uid.
*/
- void registerBackpackDefinition(@Nonnull String backpackUid, @Nonnull IBackpackDefinition definition);
+ void registerBackpackDefinition(String backpackUid, IBackpackDefinition definition);
/**
* Get a backpack definition with a given uid.
*/
@Nullable
- IBackpackDefinition getBackpackDefinition(@Nonnull String backpackUid);
+ IBackpackDefinition getBackpackDefinition(String backpackUid);
/**
* Creates a backpack with the given UID and type, returning the item.
@@ -59,8 +58,7 @@ public interface IBackpackInterface {
* @param type Type of backpack.
* @return Created backpack item.
*/
- @Nonnull
- Item createBackpack(@Nonnull String backpackUid, @Nonnull EnumBackpackType type);
+ Item createBackpack(String backpackUid, EnumBackpackType type);
/**
* Create a backpack that can hold items from a specific {@link ISpeciesRoot}.
@@ -70,7 +68,7 @@ public interface IBackpackInterface {
* @param speciesRoot The species root.
* @return Created backpack item.
*/
- Item createNaturalistBackpack(@Nonnull String backpackUid, @Nonnull ISpeciesRoot speciesRoot);
+ Item createNaturalistBackpack(String backpackUid, ISpeciesRoot speciesRoot);
/**
* Makes a new configurable backpack filter. Useful for implementing {@link IBackpackDefinition}.
diff --git a/src/main/java/forestry/api/storage/ICrateRegistry.java b/src/main/java/forestry/api/storage/ICrateRegistry.java
index dd0240850..5aa2f479c 100644
--- a/src/main/java/forestry/api/storage/ICrateRegistry.java
+++ b/src/main/java/forestry/api/storage/ICrateRegistry.java
@@ -5,8 +5,6 @@
******************************************************************************/
package forestry.api.storage;
-import javax.annotation.Nonnull;
-
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -16,17 +14,17 @@ import net.minecraft.item.ItemStack;
* and creates crating and uncrating recipes for the Carpenter.
* The icon is rendered automatically from the contained item.
* If an oreDictName is specified, it will make recipes using that.
- *
+ *
* Can only be called during the Init stage.
*/
public interface ICrateRegistry {
- void registerCrate(@Nonnull Item item);
+ void registerCrate(Item item);
- void registerCrate(@Nonnull Block block);
+ void registerCrate(Block block);
- void registerCrate(@Nonnull ItemStack stack);
+ void registerCrate(ItemStack stack);
- void registerCrate(@Nonnull String oreDictName);
+ void registerCrate(String oreDictName);
}
diff --git a/src/main/java/forestry/api/storage/package-info.java b/src/main/java/forestry/api/storage/package-info.java
index 1dbd576ac..016e2a1e0 100644
--- a/src/main/java/forestry/api/storage/package-info.java
+++ b/src/main/java/forestry/api/storage/package-info.java
@@ -3,7 +3,12 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
+@ParametersAreNonnullByDefault
+@MethodsReturnNonnullByDefault
@API(apiVersion = "5.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|storage")
package forestry.api.storage;
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import mcp.MethodsReturnNonnullByDefault;
import net.minecraftforge.fml.common.API;
diff --git a/src/main/java/forestry/api/world/ITreeGenData.java b/src/main/java/forestry/api/world/ITreeGenData.java
index b5fec434c..da73cd3fe 100644
--- a/src/main/java/forestry/api/world/ITreeGenData.java
+++ b/src/main/java/forestry/api/world/ITreeGenData.java
@@ -29,7 +29,7 @@ public interface ITreeGenData {
@Nullable
BlockPos canGrow(World world, BlockPos pos, int expectedGirth, int expectedHeight);
- boolean setLeaves(World world, GameProfile owner, BlockPos pos);
+ boolean setLeaves(World world, @Nullable GameProfile owner, BlockPos pos);
boolean setLogBlock(World world, BlockPos pos, EnumFacing facing);
diff --git a/src/main/java/forestry/apiculture/ArmorApiaristHelper.java b/src/main/java/forestry/apiculture/ArmorApiaristHelper.java
index e5238813b..60e4cbf19 100644
--- a/src/main/java/forestry/apiculture/ArmorApiaristHelper.java
+++ b/src/main/java/forestry/apiculture/ArmorApiaristHelper.java
@@ -35,7 +35,7 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
return false;
}
- return armorApiarist.protectEntity(entity, stack, cause, doProtect);
+ return armorApiarist != null && armorApiarist.protectEntity(entity, stack, cause, doProtect);
}
@Override
diff --git a/src/main/java/forestry/apiculture/BeekeepingLogic.java b/src/main/java/forestry/apiculture/BeekeepingLogic.java
old mode 100755
new mode 100644
index 410cce86b..c130e872d
--- a/src/main/java/forestry/apiculture/BeekeepingLogic.java
+++ b/src/main/java/forestry/apiculture/BeekeepingLogic.java
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
@@ -20,20 +19,12 @@ import java.util.List;
import java.util.Set;
import java.util.Stack;
-import net.minecraft.client.Minecraft;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.World;
-
+import com.google.common.base.Preconditions;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBee;
+import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
@@ -47,11 +38,18 @@ import forestry.apiculture.network.packets.PacketBeeLogicActive;
import forestry.apiculture.network.packets.PacketBeeLogicActiveEntity;
import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
+import forestry.core.network.PacketBufferForestry;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Log;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
@@ -65,6 +63,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
private int beeProgressMax;
private int queenWorkCycleThrottle;
+ @Nullable
private IEffectData effectData[] = new IEffectData[2];
private final Stack spawn = new Stack<>();
@@ -75,8 +74,9 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
// Client
private boolean active;
+ @Nullable
private IBee queen;
- private ItemStack queenStack; // used to detect server changes and sync clientQueen
+ private ItemStack queenStack = ItemStack.EMPTY; // used to detect server changes and sync clientQueen
public BeekeepingLogic(IBeeHousing housing) {
this.housing = housing;
@@ -91,7 +91,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
queenWorkCycleThrottle = nbttagcompound.getInteger("Throttle");
NBTTagCompound queenNBT = nbttagcompound.getCompoundTag("queen");
- queenStack = ItemStack.loadItemStackFromNBT(queenNBT);
+ queenStack = new ItemStack(queenNBT);
queen = BeeManager.beeRoot.getMember(queenStack);
setActive(nbttagcompound.getBoolean("Active"));
@@ -100,7 +100,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
NBTTagList nbttaglist = nbttagcompound.getTagList("Offspring", 10);
for (int i = 0; i < nbttaglist.tagCount(); i++) {
- spawn.add(ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i)));
+ spawn.add(new ItemStack(nbttaglist.getCompoundTagAt(i)));
}
}
@@ -109,7 +109,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
nbttagcompound.setInteger("BreedingTime", beeProgress);
nbttagcompound.setInteger("Throttle", queenWorkCycleThrottle);
- if (queenStack != null) {
+ if (!queenStack.isEmpty()) {
NBTTagCompound queenNBT = new NBTTagCompound();
queenStack.writeToNBT(queenNBT);
nbttagcompound.setTag("queen", queenNBT);
@@ -132,7 +132,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
@Override
- public void writeData(DataOutputStreamForestry data) throws IOException {
+ public void writeData(PacketBufferForestry data) {
data.writeBoolean(active);
if (active) {
data.writeItemStack(queenStack);
@@ -141,7 +141,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
@Override
- public void readData(DataInputStreamForestry data) throws IOException {
+ public void readData(PacketBufferForestry data) throws IOException {
boolean active = data.readBoolean();
setActive(active);
if (active) {
@@ -190,14 +190,18 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
IBee dyingQueen = BeeManager.beeRoot.getMember(queenStack);
Collection spawned = killQueen(dyingQueen, housing, beeListener);
spawn.addAll(spawned);
- queenStack = null;
+ queenStack = ItemStack.EMPTY;
}
} else {
- queenStack = null;
+ queenStack = ItemStack.EMPTY;
}
if (this.queenStack != queenStack) {
- this.queen = BeeManager.beeRoot.getMember(queenStack);
+ if (!queenStack.isEmpty()) {
+ this.queen = BeeManager.beeRoot.getMember(queenStack);
+ } else {
+ this.queen = null;
+ }
this.queenStack = queenStack;
hasFlowersCache.clear();
queenCanWorkCache.clear();
@@ -248,7 +252,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
}
- private void queenWorkTick(@Nullable IBee queen, @Nonnull ItemStack queenStack) {
+ private void queenWorkTick(@Nullable IBee queen, ItemStack queenStack) {
if (queen == null) {
beeProgress = 0;
beeProgressMax = 0;
@@ -268,7 +272,9 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
pollenHandler.doPollination(queen, housing, beeListener);
// Age the queen
- float lifespanModifier = beeModifier.getLifespanModifier(queen.getGenome(), queen.getMate(), 1.0f);
+ IBeeGenome mate = queen.getMate();
+ Preconditions.checkState(mate != null);
+ float lifespanModifier = beeModifier.getLifespanModifier(queen.getGenome(), mate, 1.0f);
queen.age(housing.getWorldObj(), lifespanModifier);
// Write the changed queen back into the item stack.
@@ -284,10 +290,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
private static void doProduction(IBee queen, IBeeHousing beeHousing, IBeeListener beeListener) {
// Produce and add stacks
- ItemStack[] products = queen.produceStacks(beeHousing);
- if (products == null) {
- return;
- }
+ List products = queen.produceStacks(beeHousing);
beeListener.wearOutEquipment(1);
IBeeHousingInventory beeInventory = beeHousing.getBeeInventory();
@@ -313,9 +316,11 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
return housingHasSpace;
}
- /** Checks if a queen is alive. Much faster than reading the whole bee nbt */
+ /**
+ * Checks if a queen is alive. Much faster than reading the whole bee nbt
+ */
private static boolean isQueenAlive(ItemStack queenStack) {
- if (queenStack == null) {
+ if (queenStack.isEmpty()) {
return false;
}
NBTTagCompound nbtTagCompound = queenStack.getTagCompound();
@@ -365,10 +370,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
BeeManager.beeRoot.getBreedingTracker(housing.getWorldObj(), housing.getOwner()).registerQueen(princess);
// Remove drone
- beeInventory.getDrone().stackSize--;
- if (beeInventory.getDrone().stackSize <= 0) {
- beeInventory.setDrone(null);
- }
+ beeInventory.getDrone().shrink(1);
// Reset breeding time
queen = princess;
@@ -377,10 +379,6 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
private static Collection killQueen(IBee queen, IBeeHousing beeHousing, IBeeListener beeListener) {
- if (queen == null) {
- return Collections.emptySet();
- }
-
IBeeHousingInventory beeInventory = beeHousing.getBeeInventory();
Collection spawn;
@@ -388,8 +386,8 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
if (queen.canSpawn()) {
spawn = spawnOffspring(queen, beeHousing);
beeListener.onQueenDeath();
- beeInventory.getQueen().stackSize = 0;
- beeInventory.setQueen(null);
+ beeInventory.getQueen().setCount(0);
+ beeInventory.setQueen(ItemStack.EMPTY);
} else {
Log.warning("Tried to spawn offspring off an unmated queen. Devolving her to a princess.");
@@ -399,7 +397,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
convert.setTagCompound(nbttagcompound);
spawn = Collections.singleton(convert);
- beeInventory.setQueen(null);
+ beeInventory.setQueen(ItemStack.EMPTY);
}
return spawn;
@@ -457,9 +455,10 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
World world = housing.getWorldObj();
if (world != null && !world.isRemote) {
if (housing instanceof Entity) {
- Proxies.net.sendNetworkPacket(new PacketBeeLogicActiveEntity(housing, (Entity) housing), world);
+ Entity housingEntity = (Entity) this.housing;
+ Proxies.net.sendNetworkPacket(new PacketBeeLogicActiveEntity(this.housing, housingEntity), housingEntity.getPosition(), world);
} else {
- Proxies.net.sendNetworkPacket(new PacketBeeLogicActive(housing), world);
+ Proxies.net.sendNetworkPacket(new PacketBeeLogicActive(housing), housing.getCoordinates(), world);
}
}
}
@@ -501,7 +500,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
@Override
- @Nonnull
+
public List getFlowerPositions() {
return hasFlowersCache.getFlowerCoords();
}
@@ -532,6 +531,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
private static class PollenHandler {
private static final int MAX_POLLINATION_ATTEMPTS = 20;
+ @Nullable
private IIndividual pollen;
private int attemptedPollinations = 0;
diff --git a/src/main/java/forestry/apiculture/FakeBeekeepingLogic.java b/src/main/java/forestry/apiculture/FakeBeekeepingLogic.java
index b72108893..d08ff5a19 100644
--- a/src/main/java/forestry/apiculture/FakeBeekeepingLogic.java
+++ b/src/main/java/forestry/apiculture/FakeBeekeepingLogic.java
@@ -10,16 +10,14 @@
******************************************************************************/
package forestry.apiculture;
-import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
+import forestry.api.apiculture.IBeekeepingLogic;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
-import forestry.api.apiculture.IBeekeepingLogic;
-
public class FakeBeekeepingLogic implements IBeekeepingLogic {
public static final FakeBeekeepingLogic instance = new FakeBeekeepingLogic();
@@ -67,7 +65,6 @@ public class FakeBeekeepingLogic implements IBeekeepingLogic {
}
- @Nonnull
@Override
public List getFlowerPositions() {
return Collections.emptyList();
diff --git a/src/main/java/forestry/apiculture/HasFlowersCache.java b/src/main/java/forestry/apiculture/HasFlowersCache.java
index 21ebc9d38..c08013ad7 100644
--- a/src/main/java/forestry/apiculture/HasFlowersCache.java
+++ b/src/main/java/forestry/apiculture/HasFlowersCache.java
@@ -10,18 +10,12 @@
******************************************************************************/
package forestry.apiculture;
-import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Vec3i;
-import net.minecraft.world.World;
-
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IBee;
@@ -30,10 +24,13 @@ import forestry.api.apiculture.IBeeModifier;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import forestry.api.genetics.IFlowerProvider;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
+import forestry.core.network.PacketBufferForestry;
import forestry.core.utils.VectUtil;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Vec3i;
+import net.minecraft.world.World;
public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable {
private static final String nbtKey = "hasFlowerCache";
@@ -44,7 +41,6 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
private static final int flowerCheckInterval = 128;
private final int flowerCheckTime = random.nextInt(flowerCheckInterval);
- @Nonnull
private List flowerCoords = new ArrayList<>();
private int cooldown = 0;
@@ -102,7 +98,7 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
cooldown = 0;
}
- @Nonnull
+
public List getFlowerCoords() {
return Collections.unmodifiableList(flowerCoords);
}
@@ -128,7 +124,7 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
if (hasFlowerCacheNBT.hasKey(nbtKeyFlowers)) {
int[] flowersList = hasFlowerCacheNBT.getIntArray(nbtKeyFlowers);
- if (flowersList != null && flowersList.length % 3 == 0) {
+ if (flowersList.length % 3 == 0) {
int flowerCount = flowersList.length / 3;
for (int i = 0; i < flowerCount; i++) {
BlockPos flowerPos = new BlockPos(flowersList[i], flowersList[i + 1], flowersList[i + 2]);
@@ -165,7 +161,7 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
}
@Override
- public void writeData(DataOutputStreamForestry data) throws IOException {
+ public void writeData(PacketBufferForestry data) {
int size = flowerCoords.size();
data.writeVarInt(size);
if (size > 0) {
@@ -178,7 +174,7 @@ public class HasFlowersCache implements INbtWritable, INbtReadable, IStreamable
}
@Override
- public void readData(DataInputStreamForestry data) throws IOException {
+ public void readData(PacketBufferForestry data) throws IOException {
flowerCoords.clear();
int size = data.readVarInt();
diff --git a/src/main/java/forestry/apiculture/InventoryBeeHousing.java b/src/main/java/forestry/apiculture/InventoryBeeHousing.java
index 203e7af1b..1060249de 100644
--- a/src/main/java/forestry/apiculture/InventoryBeeHousing.java
+++ b/src/main/java/forestry/apiculture/InventoryBeeHousing.java
@@ -10,15 +10,14 @@
******************************************************************************/
package forestry.apiculture;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumFacing;
-
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.core.inventory.InventoryAdapterRestricted;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.SlotUtil;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumFacing;
public class InventoryBeeHousing extends InventoryAdapterRestricted implements IBeeHousingInventory {
public static final int SLOT_QUEEN = 0;
diff --git a/src/main/java/forestry/apiculture/PluginApiculture.java b/src/main/java/forestry/apiculture/PluginApiculture.java
index eca89ee46..f7f0e2c4e 100644
--- a/src/main/java/forestry/apiculture/PluginApiculture.java
+++ b/src/main/java/forestry/apiculture/PluginApiculture.java
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture;
+import javax.annotation.Nullable;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -17,6 +18,7 @@ import java.util.Objects;
import java.util.Random;
import java.util.Set;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import forestry.Forestry;
import forestry.api.apiculture.BeeManager;
@@ -50,7 +52,7 @@ import forestry.apiculture.genetics.BeeRoot;
import forestry.apiculture.genetics.BeekeepingMode;
import forestry.apiculture.genetics.HiveDrop;
import forestry.apiculture.genetics.JubilanceFactory;
-import forestry.apiculture.genetics.alleles.AlleleEffect;
+import forestry.apiculture.genetics.alleles.AlleleEffects;
import forestry.apiculture.items.EnumHoneyComb;
import forestry.apiculture.items.EnumPollenCluster;
import forestry.apiculture.items.EnumPropolis;
@@ -81,6 +83,8 @@ import forestry.core.config.LocalizedConfiguration;
import forestry.core.entities.ParticleSnow;
import forestry.core.fluids.Fluids;
import forestry.core.items.EnumElectronTube;
+import forestry.core.items.ItemRegistryCore;
+import forestry.core.items.ItemRegistryFluids;
import forestry.core.network.IPacketRegistry;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.EntityUtil;
@@ -95,11 +99,11 @@ import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.state.IBlockState;
-import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -124,6 +128,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
@ForestryPlugin(pluginID = ForestryPluginUids.APICULTURE, name = "Apiculture", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.apiculture.description")
public class PluginApiculture extends BlankForestryPlugin {
+ @SuppressWarnings("NullableProblems")
@SidedProxy(clientSide = "forestry.apiculture.proxy.ProxyApicultureClient", serverSide = "forestry.apiculture.proxy.ProxyApiculture")
public static ProxyApiculture proxy;
private static final String CONFIG_CATEGORY = "apiculture";
@@ -131,11 +136,13 @@ public class PluginApiculture extends BlankForestryPlugin {
private static float secondPrincessChance = 0;
public static final int ticksPerBeeWorkCycle = 550;
+ @Nullable
public static ItemRegistryApiculture items;
+ @Nullable
public static BlockRegistryApiculture blocks;
-
+ @Nullable
public static HiveRegistry hiveRegistry;
-
+ @Nullable
public static VillagerRegistry.VillagerProfession villagerApiarist;
@Override
@@ -237,6 +244,14 @@ public class PluginApiculture extends BlankForestryPlugin {
createHives();
registerBeehiveDrops();
+ if (items == null) {
+ throw new IllegalStateException("Items have not been created");
+ }
+
+ if (blocks == null) {
+ throw new IllegalArgumentException("Blocks have not been created");
+ }
+
// Inducers for swarmer
BeeManager.inducers.put(items.royalJelly.getItemStack(), 10);
@@ -250,8 +265,10 @@ public class PluginApiculture extends BlankForestryPlugin {
GameRegistry.registerTileEntity(TileAlvearySieve.class, "forestry.AlvearySieve");
GameRegistry.registerTileEntity(TileCandle.class, "forestry.Candle");
- EntityUtil.registerEntity(EntityMinecartBeehouse.class, "cart.beehouse", 1, 0x000000, 0xffffff, 256, 3, true);
- EntityUtil.registerEntity(EntityMinecartApiary.class, "cart.apiary", 2, 0x000000, 0xffffff, 256, 3, true);
+ ResourceLocation beeHouseCartResource = new ResourceLocation(Constants.MOD_ID, "cart.beehouse");
+ EntityUtil.registerEntity(beeHouseCartResource, EntityMinecartBeehouse.class, "cart.beehouse", 1, 0x000000, 0xffffff, 256, 3, true);
+ ResourceLocation apiaryCartResource = new ResourceLocation(Constants.MOD_ID, "cart.apiary");
+ EntityUtil.registerEntity(apiaryCartResource, EntityMinecartApiary.class, "cart.apiary", 2, 0x000000, 0xffffff, 256, 3, true);
BeeManager.commonVillageBees.add(BeeDefinition.FOREST.getGenome());
BeeManager.commonVillageBees.add(BeeDefinition.MEADOWS.getGenome());
@@ -279,13 +296,13 @@ public class PluginApiculture extends BlankForestryPlugin {
ItemStack provenFrames = items.frameProven.getItemStack();
ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE);
ItemStack endDrone = BeeDefinition.ENDED.getMemberStack(EnumBeeType.DRONE);
- ItemStack propolis = new ItemStack(PluginApiculture.items.propolis,1);
+ ItemStack propolis = new ItemStack(items.propolis, 1);
VillagerRegistry.VillagerCareer apiaristCareer = new VillagerRegistry.VillagerCareer(villagerApiarist, "apiarist");
apiaristCareer.addTrade(1,
- new VillagerApiaristTrades.GiveRandomCombsForItems(new ItemStack(Items.WHEAT), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)),
- new VillagerApiaristTrades.GiveRandomCombsForItems(new ItemStack(Items.CARROT), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)),
- new VillagerApiaristTrades.GiveRandomCombsForItems(new ItemStack(Items.POTATO), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4))
+ new VillagerApiaristTrades.GiveRandomCombsForItems(items.beeComb, new ItemStack(Items.WHEAT), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)),
+ new VillagerApiaristTrades.GiveRandomCombsForItems(items.beeComb, new ItemStack(Items.CARROT), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4)),
+ new VillagerApiaristTrades.GiveRandomCombsForItems(items.beeComb, new ItemStack(Items.POTATO), new EntityVillager.PriceInfo(8, 12), new EntityVillager.PriceInfo(2, 4))
);
apiaristCareer.addTrade(2,
new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 4), new ItemStack(items.smoker), null),
@@ -298,7 +315,7 @@ public class PluginApiculture extends BlankForestryPlugin {
);
apiaristCareer.addTrade(4,
new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null),
- new VillagerTradeLists.GiveItemForTwoItems(wildcardPrincess, null,new ItemStack(Items.ENDER_EYE),new EntityVillager.PriceInfo(12, 16),endDrone, null)
+ new VillagerTradeLists.GiveItemForTwoItems(wildcardPrincess, null, new ItemStack(Items.ENDER_EYE), new EntityVillager.PriceInfo(12, 16), endDrone, null)
);
}
@@ -358,8 +375,13 @@ public class PluginApiculture extends BlankForestryPlugin {
@Override
public void registerCrates() {
+ ItemRegistryCore coreItems = PluginCore.items;
+ Preconditions.checkState(coreItems != null);
+ Preconditions.checkState(items != null);
+ Preconditions.checkState(blocks != null);
+
ICrateRegistry crateRegistry = StorageManager.crateRegistry;
- crateRegistry.registerCrate(PluginCore.items.beeswax.getItemStack());
+ crateRegistry.registerCrate(coreItems.beeswax.getItemStack());
crateRegistry.registerCrate(items.pollenCluster.get(EnumPollenCluster.NORMAL, 1));
crateRegistry.registerCrate(items.pollenCluster.get(EnumPollenCluster.CRYSTALLINE, 1));
crateRegistry.registerCrate(items.propolis.getItemStack());
@@ -380,14 +402,21 @@ public class PluginApiculture extends BlankForestryPlugin {
crateRegistry.registerCrate(items.beeComb.get(EnumHoneyComb.MOSSY, 1));
crateRegistry.registerCrate(items.beeComb.get(EnumHoneyComb.MELLOW, 1));
- crateRegistry.registerCrate(PluginCore.items.refractoryWax.getItemStack());
+ crateRegistry.registerCrate(coreItems.refractoryWax.getItemStack());
}
@Override
public void registerRecipes() {
+ ItemRegistryCore coreItems = PluginCore.items;
+ ItemRegistryFluids fluidItems = PluginFluids.items;
+ Preconditions.checkState(coreItems != null);
+ Preconditions.checkState(fluidItems != null);
+ Preconditions.checkState(items != null);
+ Preconditions.checkState(blocks != null);
// / APIARIST'S ARMOR
- ItemStack wovenSilk = PluginCore.items.craftingMaterial.getWovenSilk();
+
+ ItemStack wovenSilk = coreItems.craftingMaterial.getWovenSilk();
RecipeUtil.addRecipe(items.apiaristHat,
"###", "# #",
'#', wovenSilk);
@@ -433,7 +462,7 @@ public class PluginApiculture extends BlankForestryPlugin {
'S', Items.STRING);
RecipeUtil.addRecipe(items.frameImpregnated,
"###", "#S#", "###",
- '#', PluginCore.items.stickImpregnated,
+ '#', coreItems.stickImpregnated,
'S', Items.STRING);
RecipeUtil.addRecipe(items.minecartBeehouse.getBeeHouseMinecart(),
"B",
@@ -457,41 +486,41 @@ public class PluginApiculture extends BlankForestryPlugin {
RecipeUtil.addRecipe(foodItems.honeyPot,
"# #", " X ", "# #",
'#', items.honeyDrop,
- 'X', PluginFluids.items.waxCapsuleEmpty);
+ 'X', fluidItems.waxCapsuleEmpty);
RecipeUtil.addRecipe(foodItems.ambrosia,
"#Y#", "XXX", "###",
'#', items.honeydew,
'X', items.royalJelly,
- 'Y', PluginFluids.items.waxCapsuleEmpty);
+ 'Y', fluidItems.waxCapsuleEmpty);
}
// / CAPSULES
int outputCapsuleAmount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.capsule");
if (outputCapsuleAmount > 0) {
- ItemStack capsule = PluginFluids.items.waxCapsuleEmpty.getItemStack(outputCapsuleAmount);
- RecipeUtil.addRecipe(capsule, "###", '#', PluginCore.items.beeswax);
+ ItemStack capsule = fluidItems.waxCapsuleEmpty.getItemStack(outputCapsuleAmount);
+ RecipeUtil.addRecipe(capsule, "###", '#', coreItems.beeswax);
}
int outputRefractoryAmount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.refractory");
if (outputRefractoryAmount > 0) {
- ItemStack capsule = PluginFluids.items.refractoryEmpty.getItemStack(outputRefractoryAmount);
- RecipeUtil.addRecipe(capsule, "###", '#', PluginCore.items.refractoryWax);
+ ItemStack capsule = fluidItems.refractoryEmpty.getItemStack(outputRefractoryAmount);
+ RecipeUtil.addRecipe(capsule, "###", '#', coreItems.refractoryWax);
}
// / BITUMINOUS PEAT
- RecipeUtil.addRecipe(PluginCore.items.bituminousPeat.getItemStack(),
+ RecipeUtil.addRecipe(coreItems.bituminousPeat.getItemStack(),
" # ", "XYX", " # ",
'#', OreDictUtil.DUST_ASH,
- 'X', PluginCore.items.peat,
+ 'X', coreItems.peat,
'Y', items.propolis);
// / TORCHES
RecipeUtil.addRecipe(new ItemStack(Blocks.TORCH, 3),
" # ", " # ", " Y ",
- '#', PluginCore.items.beeswax,
+ '#', coreItems.beeswax,
'Y', OreDictUtil.STICK_WOOD);
- RecipeUtil.addRecipe(PluginCore.items.craftingMaterial.getPulsatingMesh(),
+ RecipeUtil.addRecipe(coreItems.craftingMaterial.getPulsatingMesh(),
"# #", " # ", "# #",
'#', items.propolis.get(EnumPropolis.PULSATING, 1));
@@ -500,7 +529,7 @@ public class PluginApiculture extends BlankForestryPlugin {
"###",
"# #",
"###",
- '#', PluginCore.items.beeswax);
+ '#', coreItems.beeswax);
// / ALVEARY
ItemStack alvearyPlainBlock = blocks.getAlvearyBlock(BlockAlvearyType.PLAIN);
@@ -508,14 +537,14 @@ public class PluginApiculture extends BlankForestryPlugin {
"###",
"#X#",
"###",
- 'X', PluginCore.items.impregnatedCasing,
- '#', PluginCore.items.craftingMaterial.getScentedPaneling());
+ 'X', coreItems.impregnatedCasing,
+ '#', coreItems.craftingMaterial.getScentedPaneling());
// SWARMER
RecipeUtil.addRecipe(blocks.getAlvearyBlock(BlockAlvearyType.SWARMER),
"#G#",
" X ",
"#G#",
- '#', PluginCore.items.tubes.get(EnumElectronTube.DIAMOND, 1),
+ '#', coreItems.tubes.get(EnumElectronTube.DIAMOND, 1),
'X', alvearyPlainBlock,
'G', OreDictUtil.INGOT_GOLD);
// FAN
@@ -523,7 +552,7 @@ public class PluginApiculture extends BlankForestryPlugin {
"I I",
" X ",
"I#I",
- '#', PluginCore.items.tubes.get(EnumElectronTube.GOLD, 1),
+ '#', coreItems.tubes.get(EnumElectronTube.GOLD, 1),
'X', alvearyPlainBlock,
'I', OreDictUtil.INGOT_IRON);
// HEATER
@@ -531,7 +560,7 @@ public class PluginApiculture extends BlankForestryPlugin {
"#I#",
" X ",
"YYY",
- '#', PluginCore.items.tubes.get(EnumElectronTube.GOLD, 1),
+ '#', coreItems.tubes.get(EnumElectronTube.GOLD, 1),
'X', alvearyPlainBlock,
'I', OreDictUtil.INGOT_IRON, 'Y', OreDictUtil.STONE);
// HYGROREGULATOR
@@ -556,57 +585,68 @@ public class PluginApiculture extends BlankForestryPlugin {
"WWW",
'X', alvearyPlainBlock,
'I', OreDictUtil.INGOT_IRON,
- 'W', PluginCore.items.craftingMaterial.getWovenSilk());
+ 'W', coreItems.craftingMaterial.getWovenSilk());
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FACTORY)) {
// / SQUEEZER
FluidStack honeyDropFluid = Fluids.FOR_HONEY.getFluid(Constants.FLUID_PER_HONEY_DROP);
- RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{items.honeyDrop.getItemStack()}, honeyDropFluid, items.propolis.getItemStack(), 5);
- RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{items.honeydew.getItemStack()}, honeyDropFluid);
+ RecipeManagers.squeezerManager.addRecipe(10, items.honeyDrop.getItemStack(), honeyDropFluid, items.propolis.getItemStack(), 5);
+ RecipeManagers.squeezerManager.addRecipe(10, items.honeydew.getItemStack(), honeyDropFluid);
- ItemStack phosphor = PluginCore.items.phosphor.getItemStack(2);
- RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND)}, new FluidStack(FluidRegistry.LAVA, 2000));
- RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.SAND, 1, 1)}, new FluidStack(FluidRegistry.LAVA, 2000));
- RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{phosphor, new ItemStack(Blocks.DIRT)}, new FluidStack(FluidRegistry.LAVA, 1600));
+ ItemStack phosphor = coreItems.phosphor.getItemStack(2);
+ NonNullList lavaIngredients = NonNullList.create();
+ lavaIngredients.add(phosphor);
+ lavaIngredients.add(new ItemStack(Blocks.SAND));
+ RecipeManagers.squeezerManager.addRecipe(10, lavaIngredients, new FluidStack(FluidRegistry.LAVA, 2000));
+
+ lavaIngredients = NonNullList.create();
+ lavaIngredients.add(phosphor);
+ lavaIngredients.add(new ItemStack(Blocks.SAND, 1, 1));
+ RecipeManagers.squeezerManager.addRecipe(10, lavaIngredients, new FluidStack(FluidRegistry.LAVA, 2000));
+
+ lavaIngredients = NonNullList.create();
+ lavaIngredients.add(phosphor);
+ lavaIngredients.add(new ItemStack(Blocks.DIRT));
+ RecipeManagers.squeezerManager.addRecipe(10, lavaIngredients, new FluidStack(FluidRegistry.LAVA, 1600));
// / CARPENTER
- RecipeManagers.carpenterManager.addRecipe(50, Fluids.FOR_HONEY.getFluid(500), null, PluginCore.items.craftingMaterial.getScentedPaneling(),
+ RecipeManagers.carpenterManager.addRecipe(50, Fluids.FOR_HONEY.getFluid(500), ItemStack.EMPTY, coreItems.craftingMaterial.getScentedPaneling(),
" J ", "###", "WPW",
'#', OreDictUtil.PLANK_WOOD,
'J', items.royalJelly,
- 'W', PluginCore.items.beeswax,
+ 'W', coreItems.beeswax,
'P', items.pollenCluster.get(EnumPollenCluster.NORMAL, 1));
-
- RecipeManagers.carpenterManager.addRecipe(30, new FluidStack(FluidRegistry.WATER, 600), null, blocks.candle.getUnlitCandle(24),
+
+ RecipeManagers.carpenterManager.addRecipe(30, new FluidStack(FluidRegistry.WATER, 600), ItemStack.EMPTY, blocks.candle.getUnlitCandle(24),
" X ",
"###",
"###",
- '#', PluginCore.items.beeswax,
+ '#', coreItems.beeswax,
'X', Items.STRING);
- RecipeManagers.carpenterManager.addRecipe(10, new FluidStack(FluidRegistry.WATER, 200), null, blocks.candle.getUnlitCandle(6),
+ RecipeManagers.carpenterManager.addRecipe(10, new FluidStack(FluidRegistry.WATER, 200), ItemStack.EMPTY, blocks.candle.getUnlitCandle(6),
"#X#",
- '#', PluginCore.items.beeswax,
- 'X', PluginCore.items.craftingMaterial.getSilkWisp());
+ '#', coreItems.beeswax,
+ 'X', coreItems.craftingMaterial.getSilkWisp());
RecipeUtil.addShapelessRecipe(blocks.candle.getUnlitCandle(1), blocks.candle.getUnlitCandle(1));
RecipeUtil.addShapelessRecipe(blocks.candle.getLitCandle(1), blocks.candle.getLitCandle(1));
// / CENTRIFUGE
// Honey combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.HONEY, 1), ImmutableMap.of(
- PluginCore.items.beeswax.getItemStack(), 1.0f,
+ coreItems.beeswax.getItemStack(), 1.0f,
items.honeyDrop.getItemStack(), 0.9f
));
// Cocoa combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.COCOA, 1), ImmutableMap.of(
- PluginCore.items.beeswax.getItemStack(), 1.0f,
+ coreItems.beeswax.getItemStack(), 1.0f,
new ItemStack(Items.DYE, 1, 3), 0.5f
));
// Simmering combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.SIMMERING, 1), ImmutableMap.of(
- PluginCore.items.refractoryWax.getItemStack(), 1.0f,
- PluginCore.items.phosphor.getItemStack(2), 0.7f
+ coreItems.refractoryWax.getItemStack(), 1.0f,
+ coreItems.phosphor.getItemStack(2), 0.7f
));
// Stringy combs
@@ -623,7 +663,7 @@ public class PluginApiculture extends BlankForestryPlugin {
// Frozen combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.FROZEN, 1), ImmutableMap.of(
- PluginCore.items.beeswax.getItemStack(), 0.8f,
+ coreItems.beeswax.getItemStack(), 0.8f,
items.honeyDrop.getItemStack(), 0.7f,
new ItemStack(Items.SNOWBALL), 0.4f,
items.pollenCluster.get(EnumPollenCluster.CRYSTALLINE, 1), 0.2f
@@ -637,7 +677,7 @@ public class PluginApiculture extends BlankForestryPlugin {
// Parched combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.PARCHED, 1), ImmutableMap.of(
- PluginCore.items.beeswax.getItemStack(), 1.0f,
+ coreItems.beeswax.getItemStack(), 1.0f,
items.honeyDrop.getItemStack(), 0.9f
));
@@ -654,33 +694,33 @@ public class PluginApiculture extends BlankForestryPlugin {
// Powdery combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.POWDERY, 1), ImmutableMap.of(
items.honeyDrop.getItemStack(), 0.2f,
- PluginCore.items.beeswax.getItemStack(), 0.2f,
+ coreItems.beeswax.getItemStack(), 0.2f,
new ItemStack(Items.GUNPOWDER), 0.9f
));
// Wheaten Combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.WHEATEN, 1), ImmutableMap.of(
items.honeyDrop.getItemStack(), 0.2f,
- PluginCore.items.beeswax.getItemStack(), 0.2f,
+ coreItems.beeswax.getItemStack(), 0.2f,
new ItemStack(Items.WHEAT), 0.8f
));
// Mossy Combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.MOSSY, 1), ImmutableMap.of(
- PluginCore.items.beeswax.getItemStack(), 1.0f,
+ coreItems.beeswax.getItemStack(), 1.0f,
items.honeyDrop.getItemStack(), 0.9f
));
// Mellow Combs
RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.MELLOW, 1), ImmutableMap.of(
items.honeydew.getItemStack(), 0.6f,
- PluginCore.items.beeswax.getItemStack(), 0.2f,
+ coreItems.beeswax.getItemStack(), 0.2f,
new ItemStack(Items.QUARTZ), 0.3f
));
// Silky Propolis
RecipeManagers.centrifugeManager.addRecipe(5, items.propolis.get(EnumPropolis.SILKY, 1), ImmutableMap.of(
- PluginCore.items.craftingMaterial.getSilkWisp(), 0.6f,
+ coreItems.craftingMaterial.getSilkWisp(), 0.6f,
items.propolis.getItemStack(), 0.1f
));
@@ -694,7 +734,7 @@ public class PluginApiculture extends BlankForestryPlugin {
"###",
'X', OreDictUtil.SLAB_WOOD,
'#', OreDictUtil.PLANK_WOOD,
- 'C', PluginCore.items.impregnatedCasing);
+ 'C', coreItems.impregnatedCasing);
RecipeUtil.addRecipe(blocks.beeChest,
" # ",
@@ -714,6 +754,12 @@ public class PluginApiculture extends BlankForestryPlugin {
}
private static void registerBeehiveDrops() {
+ if (items == null) {
+ throw new IllegalStateException("items have not been created");
+ }
+ if (hiveRegistry == null) {
+ throw new IllegalStateException("hiveRegistry has not been created");
+ }
ItemStack honeyComb = items.beeComb.get(EnumHoneyComb.HONEY, 1);
hiveRegistry.addDrops(HiveType.FOREST.getHiveUid(),
new HiveDrop(0.80, BeeDefinition.FOREST, honeyComb).setIgnobleShare(0.7),
@@ -768,6 +814,9 @@ public class PluginApiculture extends BlankForestryPlugin {
}
private static void createHives() {
+ if (hiveRegistry == null) {
+ throw new IllegalStateException("hiveRegistry has not been created");
+ }
hiveRegistry.registerHive(HiveType.FOREST.getHiveUid(), HiveDescription.FOREST);
hiveRegistry.registerHive(HiveType.MEADOWS.getHiveUid(), HiveDescription.MEADOWS);
hiveRegistry.registerHive(HiveType.DESERT.getHiveUid(), HiveDescription.DESERT);
@@ -789,7 +838,7 @@ public class PluginApiculture extends BlankForestryPlugin {
apidae.addMemberGroup(beeBranch.getBranch());
}
- AlleleEffect.createAlleles();
+ AlleleEffects.registerAlleles();
}
public static double getSecondPrincessChance() {
@@ -848,7 +897,6 @@ public class PluginApiculture extends BlankForestryPlugin {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void textureHook(TextureStitchEvent.Pre event) {
- ParticleSnow.sprites = new TextureAtlasSprite[3];
for (int i = 0; i < ParticleSnow.sprites.length; i++) {
ParticleSnow.sprites[i] = event.getMap().registerSprite(new ResourceLocation("forestry:entity/particles/snow." + (i + 1)));
}
@@ -859,7 +907,7 @@ public class PluginApiculture extends BlankForestryPlugin {
@Override
public boolean isAcceptableFlower(IBlockState blockState, World world, BlockPos pos, String flowerType) {
Biome biomeGenForCoords = world.getBiome(pos);
- return BiomeDictionary.isBiomeOfType(biomeGenForCoords, BiomeDictionary.Type.END);
+ return BiomeDictionary.hasType(biomeGenForCoords, BiomeDictionary.Type.END);
}
}
}
diff --git a/src/main/java/forestry/apiculture/VillageCreationApiculture.java b/src/main/java/forestry/apiculture/VillageCreationApiculture.java
index 51b0bf875..b8433c25f 100644
--- a/src/main/java/forestry/apiculture/VillageCreationApiculture.java
+++ b/src/main/java/forestry/apiculture/VillageCreationApiculture.java
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture;
+import javax.annotation.Nullable;
import java.util.List;
import java.util.Random;
@@ -31,7 +32,7 @@ public class VillageCreationApiculture implements VillagerRegistry.IVillageCreat
@Override
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int size) {
- return new StructureVillagePieces.PieceWeight(VillageApiaristHouse.class, 15, MathHelper.getRandomIntegerInRange(random, size, 1 + size));
+ return new StructureVillagePieces.PieceWeight(VillageApiaristHouse.class, 15, MathHelper.getInt(random, size, 1 + size));
}
@Override
@@ -40,6 +41,7 @@ public class VillageCreationApiculture implements VillagerRegistry.IVillageCreat
}
@Override
+ @Nullable
public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) {
return VillageApiaristHouse.buildComponent(startPiece, pieces, random, p1, p2, p3, facing, p5);
}
diff --git a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java
index 73bd2c631..4d62de529 100644
--- a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java
+++ b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java
@@ -1,34 +1,36 @@
package forestry.apiculture;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Random;
+import forestry.api.apiculture.EnumBeeType;
+import forestry.apiculture.genetics.BeeDefinition;
+import forestry.apiculture.items.ItemHoneyComb;
+import net.minecraft.entity.IMerchant;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.item.ItemStack;
import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList;
-import forestry.api.apiculture.EnumBeeType;
-import forestry.apiculture.genetics.BeeDefinition;
-
public class VillagerApiaristTrades {
public static class GiveRandomCombsForItems implements EntityVillager.ITradeList {
- public ItemStack itemToBuy;
+ public final ItemHoneyComb honeyComb;
+ public final ItemStack itemToBuy;
@Nullable
- public EntityVillager.PriceInfo buyInfo;
+ public final EntityVillager.PriceInfo buyInfo;
@Nullable
- public EntityVillager.PriceInfo priceInfo;
+ public final EntityVillager.PriceInfo priceInfo;
- public GiveRandomCombsForItems(ItemStack stack, @Nullable EntityVillager.PriceInfo buyInfo, @Nullable EntityVillager.PriceInfo priceInfo) {
+ public GiveRandomCombsForItems(ItemHoneyComb honeyComb, ItemStack stack, @Nullable EntityVillager.PriceInfo buyInfo, @Nullable EntityVillager.PriceInfo priceInfo) {
+ this.honeyComb = honeyComb;
this.itemToBuy = stack;
this.buyInfo = buyInfo;
this.priceInfo = priceInfo;
}
@Override
- public void modifyMerchantRecipeList(@Nonnull MerchantRecipeList recipeList, @Nonnull Random random) {
+ public void addMerchantRecipe(IMerchant p_190888_1_, MerchantRecipeList recipeList, Random random) {
int sellAmount = 1;
if (this.priceInfo != null) {
sellAmount = this.priceInfo.getPrice(random);
@@ -40,25 +42,26 @@ public class VillagerApiaristTrades {
}
ItemStack itemToBuy = this.itemToBuy.copy();
- itemToBuy.stackSize = buyAmount;
- ItemStack randomComb = PluginApiculture.items.beeComb.getRandomComb(sellAmount, random, false);
- recipeList.add(new MerchantRecipe(itemToBuy, randomComb));
+ itemToBuy.setCount(buyAmount);
+ ItemStack randomComb = honeyComb.getRandomComb(sellAmount, random, false);
+ if (!randomComb.isEmpty()) {
+ recipeList.add(new MerchantRecipe(itemToBuy, randomComb));
+ }
}
}
+
public static class GiveRandomHiveDroneForItems implements EntityVillager.ITradeList {
- @Nonnull
- public ItemStack buyingItemStack;
+ public final ItemStack buyingItemStack;
@Nullable
- public EntityVillager.PriceInfo buyingPriceInfo;
- @Nonnull
- public ItemStack buyingItemStackTwo;
+ public final EntityVillager.PriceInfo buyingPriceInfo;
+ public final ItemStack buyingItemStackTwo;
@Nullable
- public EntityVillager.PriceInfo buyingPriceItemTwoInfo;
+ public final EntityVillager.PriceInfo buyingPriceItemTwoInfo;
public GiveRandomHiveDroneForItems(
- @Nonnull ItemStack buyingItemStack,
+ ItemStack buyingItemStack,
@Nullable EntityVillager.PriceInfo buyingPriceInfo,
- @Nonnull ItemStack buyingItemStackTwo,
+ ItemStack buyingItemStackTwo,
@Nullable EntityVillager.PriceInfo buyingPriceItemTwoInfo) {
this.buyingItemStack = buyingItemStack;
this.buyingPriceInfo = buyingPriceInfo;
@@ -67,8 +70,7 @@ public class VillagerApiaristTrades {
}
@Override
- public void modifyMerchantRecipeList(@Nonnull MerchantRecipeList recipeList, @Nonnull Random random) {
-
+ public void addMerchantRecipe(IMerchant p_190888_1_, MerchantRecipeList recipeList, Random random) {
int buyAmount = 1;
if (this.buyingPriceInfo != null) {
buyAmount = this.buyingPriceInfo.getPrice(random);
@@ -78,12 +80,12 @@ public class VillagerApiaristTrades {
if (this.buyingPriceItemTwoInfo != null) {
buyTwoAmount = this.buyingPriceItemTwoInfo.getPrice(random);
}
- BeeDefinition [] forestryMundane = new BeeDefinition[] { BeeDefinition.FOREST, BeeDefinition.MEADOWS, BeeDefinition.MODEST, BeeDefinition.WINTRY, BeeDefinition.TROPICAL, BeeDefinition.MARSHY };
+ BeeDefinition[] forestryMundane = new BeeDefinition[]{BeeDefinition.FOREST, BeeDefinition.MEADOWS, BeeDefinition.MODEST, BeeDefinition.WINTRY, BeeDefinition.TROPICAL, BeeDefinition.MARSHY};
ItemStack randomHiveDrone = forestryMundane[random.nextInt(forestryMundane.length)].getMemberStack(EnumBeeType.DRONE);
ItemStack buyItemStack = this.buyingItemStack.copy();
- buyItemStack.stackSize = buyAmount;
+ buyItemStack.setCount(buyAmount);
ItemStack buyItemStackTwo = this.buyingItemStackTwo.copy();
- buyItemStackTwo.stackSize = buyTwoAmount;
+ buyItemStackTwo.setCount(buyTwoAmount);
recipeList.add(new MerchantRecipe(buyItemStack, buyItemStackTwo, randomHiveDrone));
}
}
diff --git a/src/main/java/forestry/apiculture/blocks/BlockAlveary.java b/src/main/java/forestry/apiculture/blocks/BlockAlveary.java
index 8d62c9476..1be8b906e 100644
--- a/src/main/java/forestry/apiculture/blocks/BlockAlveary.java
+++ b/src/main/java/forestry/apiculture/blocks/BlockAlveary.java
@@ -10,31 +10,12 @@
******************************************************************************/
package forestry.apiculture.blocks;
-import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import net.minecraft.block.Block;
-import net.minecraft.block.SoundType;
-import net.minecraft.block.properties.PropertyEnum;
-import net.minecraft.block.state.BlockStateContainer;
-import net.minecraft.block.state.IBlockState;
-import net.minecraft.client.renderer.block.model.ModelResourceLocation;
-import net.minecraft.client.renderer.block.statemap.StateMapperBase;
-import net.minecraft.item.Item;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.EnumFacing;
-import net.minecraft.util.IStringSerializable;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.IBlockAccess;
-import net.minecraft.world.World;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
import forestry.api.core.IModelManager;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.Tabs;
@@ -48,17 +29,33 @@ import forestry.apiculture.multiblock.TileAlvearyPlain;
import forestry.apiculture.multiblock.TileAlvearySieve;
import forestry.apiculture.multiblock.TileAlvearyStabiliser;
import forestry.apiculture.multiblock.TileAlvearySwarmer;
-import forestry.apiculture.network.packets.PacketAlveryChange;
+import forestry.apiculture.network.packets.PacketAlvearyChange;
import forestry.core.blocks.BlockStructure;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.IActivatable;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.BlockUtil;
+import net.minecraft.block.Block;
+import net.minecraft.block.SoundType;
+import net.minecraft.block.properties.PropertyEnum;
+import net.minecraft.block.state.BlockStateContainer;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.client.renderer.block.model.ModelResourceLocation;
+import net.minecraft.client.renderer.block.statemap.StateMapperBase;
+import net.minecraft.item.Item;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.EnumFacing;
+import net.minecraft.util.IStringSerializable;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class BlockAlveary extends BlockStructure implements IStateMapperRegister {
private static final PropertyEnum STATE = PropertyEnum.create("state", State.class);
private static final PropertyEnum PLAIN_TYPE = PropertyEnum.create("type", AlvearyPlainType.class);
-
+
private enum State implements IStringSerializable {
ON, OFF;
@@ -67,7 +64,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
return name().toLowerCase(Locale.ENGLISH);
}
}
-
+
private enum AlvearyPlainType implements IStringSerializable {
NORMAL, ENTRANCE, ENTRANCE_LEFT, ENTRANCE_RIGHT;
@@ -81,7 +78,6 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
Map blockMap = new EnumMap<>(BlockAlvearyType.class);
for (final BlockAlvearyType type : BlockAlvearyType.VALUES) {
BlockAlveary block = new BlockAlveary() {
- @Nonnull
@Override
public BlockAlvearyType getAlvearyType() {
return type;
@@ -110,7 +106,6 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
setSoundType(SoundType.WOOD);
}
- @Nonnull
public abstract BlockAlvearyType getAlvearyType();
@Override
@@ -151,7 +146,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, 0, "apiculture/alveary." + getAlvearyType());
}
-
+
@Override
protected BlockStateContainer createBlockState() {
BlockAlvearyType alvearyType = getAlvearyType();
@@ -164,7 +159,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
return new BlockStateContainer(this);
}
}
-
+
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileAlveary tile = TileUtil.getTile(world, pos, TileAlveary.class);
@@ -211,7 +206,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
return super.getActualState(state, world, pos);
}
- @Nonnull
+
private static List getBlocksTouching(IBlockAccess world, BlockPos blockPos) {
List touching = new ArrayList<>();
for (EnumFacing direction : EnumFacing.HORIZONTALS) {
@@ -222,19 +217,18 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
}
return touching;
}
-
+
@Override
@SideOnly(Side.CLIENT)
public void registerStateMapper() {
Proxies.render.registerStateMapper(this, new AlvearyStateMapper(getAlvearyType()));
}
-
+
@SideOnly(Side.CLIENT)
private static class AlvearyStateMapper extends StateMapperBase {
- @Nonnull
private final BlockAlvearyType type;
- public AlvearyStateMapper(@Nonnull BlockAlvearyType type) {
+ public AlvearyStateMapper(BlockAlvearyType type) {
this.type = type;
}
@@ -249,7 +243,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
}
@Override
- public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) {
+ public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof TileAlveary) {
TileAlveary tileAlveary = (TileAlveary) tileEntity;
@@ -257,9 +251,8 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe
// We must check that the slabs on top were not removed
IAlvearyControllerInternal alveary = tileAlveary.getMultiblockLogic().getController();
alveary.reassemble();
- if(alveary.getReferenceCoord() != null){
- Proxies.net.sendNetworkPacket(new PacketAlveryChange(alveary), worldIn);
- }
+ BlockPos referenceCoord = alveary.getReferenceCoord();
+ Proxies.net.sendNetworkPacket(new PacketAlvearyChange(referenceCoord), referenceCoord, worldIn);
}
}
}
diff --git a/src/main/java/forestry/apiculture/blocks/BlockBeeHives.java b/src/main/java/forestry/apiculture/blocks/BlockBeeHives.java
index e2fe5262b..77aa984cc 100644
--- a/src/main/java/forestry/apiculture/blocks/BlockBeeHives.java
+++ b/src/main/java/forestry/apiculture/blocks/BlockBeeHives.java
@@ -10,7 +10,7 @@
******************************************************************************/
package forestry.apiculture.blocks;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -26,6 +26,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
+import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -74,7 +75,7 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
return getDefaultState().withProperty(HIVE_TYPES, HiveType.VALUES[meta]);
}
- public IBlockState getStateForType(@Nonnull HiveType type) {
+ public IBlockState getStateForType(HiveType type) {
return getDefaultState().withProperty(HIVE_TYPES, type);
}
@@ -168,7 +169,11 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
return PluginApiculture.hiveRegistry.getDrops(hiveName);
}
+ @Nullable
private static String getHiveNameForMeta(int meta) {
+ if (meta < 0 || meta >= HiveType.VALUES.length) {
+ return null;
+ }
return HiveType.VALUES[meta].getHiveUid();
}
@@ -177,11 +182,11 @@ public class BlockBeeHives extends BlockContainer implements IItemModelRegister,
}
@Override
- public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
+ public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList list) {
for (IBlockState blockState : getBlockState().getValidStates()) {
if (getHiveType(blockState) != HiveType.SWARM) {
int meta = getMetaFromState(blockState);
- itemList.add(new ItemStack(this, 1, meta));
+ list.add(new ItemStack(this, 1, meta));
}
}
}
diff --git a/src/main/java/forestry/apiculture/blocks/BlockCandle.java b/src/main/java/forestry/apiculture/blocks/BlockCandle.java
index 0635f9170..efe1a5689 100644
--- a/src/main/java/forestry/apiculture/blocks/BlockCandle.java
+++ b/src/main/java/forestry/apiculture/blocks/BlockCandle.java
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture.blocks;
+import javax.annotation.Nullable;
+
import com.google.common.collect.ImmutableMap;
import java.awt.Color;
@@ -39,6 +41,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.IStringSerializable;
+import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
@@ -149,12 +152,12 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
}
@Override
- public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
- itemList.add(new ItemStack(this, 1, 0));
+ public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList list) {
+ list.add(new ItemStack(this, 1, 0));
}
@Override
- public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
+ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (!(tileEntity instanceof TileCandle)) {
return false;
@@ -166,19 +169,21 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
boolean flag = false;
boolean toggleLitState = true;
+ ItemStack heldItem = playerIn.getHeldItem(hand);
+
if (!isLit) {
- if (heldItem == null || !lightingItems.contains(heldItem.getItem())) {
+ if (heldItem.isEmpty() || !lightingItems.contains(heldItem.getItem())) {
toggleLitState = false;
} else if (ItemStackUtil.equals(this, heldItem) && isLit(heldItem)) {
toggleLitState = true;
}
}
- if (heldItem != null) {
+ if (!heldItem.isEmpty()) {
if (ItemStackUtil.equals(this, heldItem)) {
if (!isLit(heldItem)) {
// Copy the colour of an unlit, coloured candle.
- if (heldItem.hasTagCompound() && heldItem.getTagCompound().hasKey(colourTagName)) {
+ if (heldItem.getTagCompound() != null && heldItem.getTagCompound().hasKey(colourTagName)) {
tileCandle.setColour(heldItem.getTagCompound().getInteger(colourTagName));
} else {
// Reset to white if item has no
@@ -262,11 +267,10 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
}
private ItemStack getCandleDrop(IBlockAccess world, BlockPos pos) {
- TileEntity tileEntity = world.getTileEntity(pos);
- if (!(tileEntity instanceof TileCandle)) {
- return null;
+ TileCandle tileCandle = TileUtil.getTile(world, pos, TileCandle.class);
+ if (tileCandle == null) {
+ return new ItemStack(this);
}
- TileCandle tileCandle = (TileCandle) tileEntity;
int colour = tileCandle.getColour();
int newMeta = tileCandle.isLit() ? 1 : 0;
@@ -282,15 +286,17 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
- TileCandle tileCandle = (TileCandle) world.getTileEntity(pos);
- int colour = getColourValueFromItemStack(stack);
- boolean isLit = isLit(stack);
- tileCandle.setColour(colour);
- tileCandle.setLit(isLit);
- if (tileCandle.isLit()) {
- world.theProfiler.startSection("checkLight");
- world.checkLight(pos);
- world.theProfiler.endSection();
+ TileCandle tileCandle = TileUtil.getTile(world, pos, TileCandle.class);
+ if (tileCandle != null) {
+ int colour = getColourValueFromItemStack(stack);
+ boolean isLit = isLit(stack);
+ tileCandle.setColour(colour);
+ tileCandle.setLit(isLit);
+ if (tileCandle.isLit()) {
+ world.theProfiler.startSection("checkLight");
+ world.checkLight(pos);
+ world.theProfiler.endSection();
+ }
}
}
@@ -304,7 +310,7 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
private static int getColourValueFromItemStack(ItemStack itemStack) {
int value = 0xffffff; // default to white.
- if (itemStack.hasTagCompound()) {
+ if (itemStack.getTagCompound() != null) {
NBTTagCompound tag = itemStack.getTagCompound();
if (tag.hasKey(colourTagName)) {
value = tag.getInteger(colourTagName);
@@ -318,10 +324,6 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
}
public static void addItemToLightingList(Item item) {
- if (item == null) {
- throw new NullPointerException();
- }
-
if (!lightingItems.contains(item)) {
lightingItems.add(item);
}
@@ -336,10 +338,12 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile
}
@Override
- public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
- TileCandle tileCandle = TileUtil.getTile(worldIn, pos, TileCandle.class);
- if (tileCandle != null) {
- return tileCandle.getColour();
+ public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
+ if (worldIn != null && pos != null) {
+ TileCandle tileCandle = TileUtil.getTile(worldIn, pos, TileCandle.class);
+ if (tileCandle != null) {
+ return tileCandle.getColour();
+ }
}
return 0xffffff;
}
diff --git a/src/main/java/forestry/apiculture/blocks/BlockStump.java b/src/main/java/forestry/apiculture/blocks/BlockStump.java
index 84c5949a9..e0a93b47b 100644
--- a/src/main/java/forestry/apiculture/blocks/BlockStump.java
+++ b/src/main/java/forestry/apiculture/blocks/BlockStump.java
@@ -10,9 +10,14 @@
******************************************************************************/
package forestry.apiculture.blocks;
-import java.util.List;
import java.util.Random;
+import forestry.api.core.IItemModelRegister;
+import forestry.api.core.IModelManager;
+import forestry.api.core.Tabs;
+import forestry.apiculture.PluginApiculture;
+import forestry.apiculture.tiles.TileCandle;
+import forestry.core.config.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.SoundType;
@@ -23,19 +28,12 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
+import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
-
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-import forestry.api.core.IItemModelRegister;
-import forestry.api.core.IModelManager;
-import forestry.api.core.Tabs;
-import forestry.apiculture.PluginApiculture;
-import forestry.apiculture.tiles.TileCandle;
-import forestry.core.config.Constants;
-
public class BlockStump extends BlockTorch implements IItemModelRegister {
public BlockStump() {
@@ -51,13 +49,14 @@ public class BlockStump extends BlockTorch implements IItemModelRegister {
}
@Override
- public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
- itemList.add(new ItemStack(this, 1, 0));
+ public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList list) {
+ list.add(new ItemStack(this, 1, 0));
}
@Override
- public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
- if (heldItem != null && BlockCandle.lightingItems.contains(heldItem.getItem())) {
+ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
+ ItemStack heldItem = playerIn.getHeldItem(hand);
+ if (BlockCandle.lightingItems.contains(heldItem.getItem())) {
IBlockState blockState = worldIn.getBlockState(pos);
Block block = blockState.getBlock();
IBlockState activatedState = PluginApiculture.blocks.candle.getStateFromMeta(block.getMetaFromState(blockState));
diff --git a/src/main/java/forestry/apiculture/blocks/BlockTypeApiculture.java b/src/main/java/forestry/apiculture/blocks/BlockTypeApiculture.java
index c816df00a..6d5100151 100644
--- a/src/main/java/forestry/apiculture/blocks/BlockTypeApiculture.java
+++ b/src/main/java/forestry/apiculture/blocks/BlockTypeApiculture.java
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.apiculture.blocks;
-import javax.annotation.Nonnull;
-
import forestry.apiculture.tiles.TileApiary;
import forestry.apiculture.tiles.TileBeeHouse;
import forestry.core.blocks.IBlockType;
@@ -25,14 +23,12 @@ public enum BlockTypeApiculture implements IBlockType {
public static final BlockTypeApiculture[] VALUES = values();
- @Nonnull
private final IMachineProperties machineProperties;
- BlockTypeApiculture(@Nonnull Class teClass, @Nonnull String name) {
+ BlockTypeApiculture(Class teClass, String name) {
this.machineProperties = new MachineProperties<>(teClass, name);
}
- @Nonnull
@Override
public IMachineProperties> getMachineProperties() {
return machineProperties;
diff --git a/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java b/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java
index 0b0f05eaa..2008317b1 100644
--- a/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java
+++ b/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java
@@ -10,12 +10,8 @@
******************************************************************************/
package forestry.apiculture.blocks;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
-import net.minecraft.util.math.AxisAlignedBB;
-
import forestry.apiculture.tiles.TileApiaristChest;
import forestry.core.blocks.IBlockTypeTesr;
import forestry.core.blocks.IMachinePropertiesTesr;
@@ -24,20 +20,20 @@ import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileForestry;
import forestry.core.tiles.TileNaturalistChest;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.util.math.AxisAlignedBB;
public enum BlockTypeApicultureTesr implements IBlockTypeTesr {
APIARIST_CHEST(TileApiaristChest.class, "api_chest", Proxies.render.getRenderChest("apiaristchest"), TileNaturalistChest.chestBoundingBox);
public static final BlockTypeApicultureTesr[] VALUES = values();
- @Nonnull
private final IMachinePropertiesTesr> machineProperties;
- BlockTypeApicultureTesr(@Nonnull Class teClass, @Nonnull String name, @Nullable TileEntitySpecialRenderer super T> renderer, AxisAlignedBB boundingBox) {
+ BlockTypeApicultureTesr(Class teClass, String name, @Nullable TileEntitySpecialRenderer super T> renderer, AxisAlignedBB boundingBox) {
this.machineProperties = new MachinePropertiesTesr<>(teClass, name, renderer, boundingBox, Constants.MOD_ID + ":blocks/" + name + ".0", false);
}
- @Nonnull
@Override
public IMachinePropertiesTesr> getMachineProperties() {
return machineProperties;
diff --git a/src/main/java/forestry/apiculture/blocks/package-info.java b/src/main/java/forestry/apiculture/blocks/package-info.java
new file mode 100644
index 000000000..94724a24b
--- /dev/null
+++ b/src/main/java/forestry/apiculture/blocks/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.blocks;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/capabilities/package-info.java b/src/main/java/forestry/apiculture/capabilities/package-info.java
new file mode 100644
index 000000000..57bfea1b1
--- /dev/null
+++ b/src/main/java/forestry/apiculture/capabilities/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.capabilities;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java
index e54fe20e9..336023fa4 100644
--- a/src/main/java/forestry/apiculture/commands/BeeModeHelper.java
+++ b/src/main/java/forestry/apiculture/commands/BeeModeHelper.java
@@ -10,7 +10,9 @@
******************************************************************************/
package forestry.apiculture.commands;
+import javax.annotation.Nullable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import net.minecraft.world.World;
@@ -23,7 +25,7 @@ public class BeeModeHelper implements ICommandModeHelper {
@Override
public String[] getModeNames() {
- ArrayList beekeepingModes = BeeManager.beeRoot.getBeekeepingModes();
+ List beekeepingModes = BeeManager.beeRoot.getBeekeepingModes();
int modeStringCount = beekeepingModes.size();
List modeStrings = new ArrayList<>(modeStringCount);
for (IBeekeepingMode mode : beekeepingModes) {
@@ -34,6 +36,7 @@ public class BeeModeHelper implements ICommandModeHelper {
}
@Override
+ @Nullable
public String getModeNameMatching(String desired) {
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(desired);
if (mode == null) {
@@ -55,6 +58,9 @@ public class BeeModeHelper implements ICommandModeHelper {
@Override
public Iterable getDescription(String modeName) {
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(modeName);
+ if (mode == null) {
+ return Collections.emptyList();
+ }
return mode.getDescription();
}
diff --git a/src/main/java/forestry/apiculture/commands/CommandBeeGive.java b/src/main/java/forestry/apiculture/commands/CommandBeeGive.java
index 8be47754a..7b95a3533 100644
--- a/src/main/java/forestry/apiculture/commands/CommandBeeGive.java
+++ b/src/main/java/forestry/apiculture/commands/CommandBeeGive.java
@@ -12,17 +12,10 @@ package forestry.apiculture.commands;
import javax.annotation.Nullable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import net.minecraft.command.CommandBase;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.command.PlayerNotFoundException;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.math.BlockPos;
-
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -34,6 +27,13 @@ import forestry.core.commands.CommandHelpers;
import forestry.core.commands.SpeciesNotFoundException;
import forestry.core.commands.SubCommand;
import forestry.core.commands.TemplateNotFoundException;
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.math.BlockPos;
public class CommandBeeGive extends SubCommand {
@@ -65,7 +65,7 @@ public class CommandBeeGive extends SubCommand {
}
@Override
- public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws SpeciesNotFoundException, TemplateNotFoundException, PlayerNotFoundException {
+ public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length < 2) {
printHelp(sender);
return;
@@ -84,10 +84,6 @@ public class CommandBeeGive extends SubCommand {
} else {
player = CommandBase.getPlayer(server, sender, sender.getName());
}
- if (player == null) {
- printHelp(sender);
- return;
- }
IBee bee = BeeManager.beeRoot.getBee(beeGenome);
@@ -139,7 +135,7 @@ public class CommandBeeGive extends SubCommand {
}
@Override
- public List getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) {
+ public List getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) {
if (args.length == 1) {
List tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(args, getSpecies());
tabCompletion.add("help");
@@ -147,9 +143,9 @@ public class CommandBeeGive extends SubCommand {
} else if (args.length == 2) {
return CommandHelpers.getListOfStringsMatchingLastWord(args, beeTypeArr);
} else if (args.length == 3) {
- return CommandHelpers.getListOfStringsMatchingLastWord(args, server.getPlayerList().getAllUsernames());
+ return CommandHelpers.getListOfStringsMatchingLastWord(args, server.getOnlinePlayerNames());
}
- return null;
+ return Collections.emptyList();
}
private static String[] getSpecies() {
diff --git a/src/main/java/forestry/apiculture/commands/package-info.java b/src/main/java/forestry/apiculture/commands/package-info.java
new file mode 100644
index 000000000..fdf17b4c9
--- /dev/null
+++ b/src/main/java/forestry/apiculture/commands/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.commands;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/compat/ApicultureJeiPlugin.java b/src/main/java/forestry/apiculture/compat/ApicultureJeiPlugin.java
index e0afe9f84..0d966c98e 100644
--- a/src/main/java/forestry/apiculture/compat/ApicultureJeiPlugin.java
+++ b/src/main/java/forestry/apiculture/compat/ApicultureJeiPlugin.java
@@ -24,9 +24,9 @@ public class ApicultureJeiPlugin extends BlankModPlugin {
return species == null ? null : species.getUID();
};
- subtypeRegistry.registerNbtInterpreter(items.beeDroneGE, beeSubtypeInterpreter);
- subtypeRegistry.registerNbtInterpreter(items.beePrincessGE, beeSubtypeInterpreter);
- subtypeRegistry.registerNbtInterpreter(items.beeQueenGE, beeSubtypeInterpreter);
+ subtypeRegistry.registerSubtypeInterpreter(items.beeDroneGE, beeSubtypeInterpreter);
+ subtypeRegistry.registerSubtypeInterpreter(items.beePrincessGE, beeSubtypeInterpreter);
+ subtypeRegistry.registerSubtypeInterpreter(items.beeQueenGE, beeSubtypeInterpreter);
}
@Override
diff --git a/src/main/java/forestry/apiculture/compat/package-info.java b/src/main/java/forestry/apiculture/compat/package-info.java
new file mode 100644
index 000000000..15bb400cf
--- /dev/null
+++ b/src/main/java/forestry/apiculture/compat/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.compat;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/entities/AIAvoidPlayers.java b/src/main/java/forestry/apiculture/entities/AIAvoidPlayers.java
index 2848d03cb..17aff290f 100644
--- a/src/main/java/forestry/apiculture/entities/AIAvoidPlayers.java
+++ b/src/main/java/forestry/apiculture/entities/AIAvoidPlayers.java
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture.entities;
+import javax.annotation.Nullable;
+
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.RandomPositionGenerator;
@@ -21,15 +23,16 @@ import net.minecraft.util.math.Vec3d;
public class AIAvoidPlayers extends EntityAIBase {
private final EntityCreature mob;
+ private final PathNavigate pathNavigator;
private final float farSpeed;
private final float nearSpeed;
private final float minDistance;
+ @Nullable
private Path path;
- private final PathNavigate pathNavigator;
-
+ @Nullable
private EntityPlayer player;
public AIAvoidPlayers(EntityCreature mob, float minDistance, float farSpeed, float nearSpeed) {
@@ -44,7 +47,7 @@ public class AIAvoidPlayers extends EntityAIBase {
@Override
public boolean shouldExecute() {
- player = mob.worldObj.getClosestPlayerToEntity(mob, minDistance);
+ player = mob.world.getClosestPlayerToEntity(mob, minDistance);
if (player == null) {
return false;
@@ -86,7 +89,7 @@ public class AIAvoidPlayers extends EntityAIBase {
@Override
public void updateTask() {
- if (mob.getDistanceSqToEntity(player) < 49.0D) {
+ if (player != null && mob.getDistanceSqToEntity(player) < 49.0D) {
mob.getNavigator().setSpeed(nearSpeed);
} else {
mob.getNavigator().setSpeed(farSpeed);
diff --git a/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java b/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java
index ab30aa4d8..20ed47c72 100644
--- a/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java
+++ b/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java
@@ -10,17 +10,11 @@
******************************************************************************/
package forestry.apiculture.entities;
-import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import net.minecraft.block.state.IBlockState;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.world.World;
-
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
@@ -35,13 +29,16 @@ import forestry.apiculture.inventory.IApiaryInventory;
import forestry.apiculture.inventory.InventoryApiary;
import forestry.core.config.Config;
import forestry.core.inventory.IInventoryAdapter;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implements IApiary {
- @Nonnull
+
private static final IBeeModifier beeModifier = new ApiaryBeeModifier();
- @Nonnull
+
private final IBeeListener beeListener = new ApiaryBeeListener(this);
- @Nonnull
private final InventoryApiary inventory = new InventoryApiary();
@SuppressWarnings("unused")
@@ -68,12 +65,11 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement
return inventory;
}
- @Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
}
-
+
@Override
public IBlockState getDisplayTile() {
return PluginApiculture.blocks.apiary.getDefaultState();
diff --git a/src/main/java/forestry/apiculture/entities/EntityMinecartBeeHousingBase.java b/src/main/java/forestry/apiculture/entities/EntityMinecartBeeHousingBase.java
index 6951fc4af..dc0d061b0 100644
--- a/src/main/java/forestry/apiculture/entities/EntityMinecartBeeHousingBase.java
+++ b/src/main/java/forestry/apiculture/entities/EntityMinecartBeeHousingBase.java
@@ -10,11 +10,10 @@
******************************************************************************/
package forestry.apiculture.entities;
-import javax.annotation.Nonnull;
import java.io.IOException;
+import java.util.Optional;
import java.util.Random;
-import com.google.common.base.Optional;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeHousing;
@@ -27,10 +26,9 @@ import forestry.apiculture.gui.IGuiBeeHousingInventory;
import forestry.apiculture.network.packets.PacketBeeLogicEntityRequest;
import forestry.apiculture.tiles.TileBeeHousingBase;
import forestry.core.entities.EntityMinecartContainerForestry;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IForestryPacketServer;
import forestry.core.network.IStreamableGui;
+import forestry.core.network.PacketBufferForestry;
import forestry.core.owner.GameProfileDataSerializer;
import forestry.core.owner.IOwnedTile;
import forestry.core.owner.IOwnerHandler;
@@ -60,7 +58,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
private final IErrorLogic errorLogic = ForestryAPI.errorStateRegistry.createErrorLogic();
private final OwnerHandler ownerHandler = new OwnerHandler() {
@Override
- public void setOwner(@Nonnull GameProfile owner) {
+ public void setOwner(GameProfile owner) {
super.setOwner(owner);
dataManager.set(OWNER, Optional.of(owner));
}
@@ -68,11 +66,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public GameProfile getOwner() {
Optional gameProfileOptional = dataManager.get(OWNER);
- if (gameProfileOptional.isPresent()) {
- return gameProfileOptional.get();
- } else {
- return null;
- }
+ return gameProfileOptional.orElse(null);
}
};
@@ -92,7 +86,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
protected void entityInit() {
super.entityInit();
- this.dataManager.register(OWNER, Optional.absent());
+ this.dataManager.register(OWNER, Optional.empty());
}
/* IOwnedTile */
@@ -109,7 +103,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public EnumTemperature getTemperature() {
- return EnumTemperature.getFromBiome(getBiome(), worldObj, getPosition());
+ return EnumTemperature.getFromBiome(getBiome(), world, getPosition());
}
@Override
@@ -119,37 +113,37 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public float getExactTemperature() {
- return ForestryAPI.climateManager.getTemperature(worldObj, getPosition());
+ return ForestryAPI.climateManager.getTemperature(world, getPosition());
}
@Override
public float getExactHumidity() {
- return ForestryAPI.climateManager.getHumidity(worldObj, getPosition());
+ return ForestryAPI.climateManager.getHumidity(world, getPosition());
}
@Override
public int getBlockLightValue() {
- return worldObj.getLightFromNeighbors(getPosition().up());
+ return world.getLightFromNeighbors(getPosition().up());
}
@Override
public boolean canBlockSeeTheSky() {
- return worldObj.canBlockSeeSky(getPosition().up());
+ return world.canBlockSeeSky(getPosition().up());
}
-
+
@Override
public boolean isRaining() {
- return worldObj.canBlockSeeSky(getPosition().up());
+ return world.isRaining();
}
@Override
public World getWorldObj() {
- return worldObj;
+ return world;
}
@Override
public Biome getBiome() {
- return worldObj.getBiome(getPosition());
+ return world.getBiome(getPosition());
}
@Override
@@ -173,12 +167,12 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
}
@Override
- public void writeGuiData(DataOutputStreamForestry data) throws IOException {
+ public void writeGuiData(PacketBufferForestry data) {
data.writeVarInt(beeLogic.getBeeProgressPercent());
}
@Override
- public void readGuiData(DataInputStreamForestry data) throws IOException {
+ public void readGuiData(PacketBufferForestry data) throws IOException {
breedingProgressPercent = data.readVarInt();
}
@@ -190,7 +184,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public void onUpdate() {
super.onUpdate();
- if (!worldObj.isRemote) {
+ if (!world.isRemote) {
if (beeLogic.canWork()) {
beeLogic.doWork();
}
@@ -202,12 +196,12 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
}
if (beeLogic.canDoBeeFX()) {
- if (worldObj.getTotalWorldTime() % beeFXInterval == beeFXTime) {
+ if (world.getTotalWorldTime() % beeFXInterval == beeFXTime) {
beeLogic.doBeeFX();
}
- if (worldObj.getTotalWorldTime() % pollenFXInterval == pollenFXTime) {
- TileBeeHousingBase.doPollenFX(worldObj, posX - 0.5, posY - 0.1, posZ - 0.5);
+ if (world.getTotalWorldTime() % pollenFXInterval == pollenFXTime) {
+ TileBeeHousingBase.doPollenFX(world, posX - 0.5, posY - 0.1, posZ - 0.5);
}
}
}
diff --git a/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java b/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java
index 4395df345..d1d1ece1d 100644
--- a/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java
+++ b/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java
@@ -10,15 +10,9 @@
******************************************************************************/
package forestry.apiculture.entities;
-import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
-import net.minecraft.block.state.IBlockState;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.world.World;
-
import forestry.api.apiculture.DefaultBeeListener;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
@@ -30,6 +24,10 @@ import forestry.apiculture.gui.ContainerMinecartBeehouse;
import forestry.apiculture.gui.GuiBeeHousing;
import forestry.core.config.Config;
import forestry.core.inventory.IInventoryAdapter;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
private static final IBeeModifier beeModifier = new BeehouseBeeModifier();
@@ -51,7 +49,7 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
public List getHints() {
return Config.hints.get("bee.house");
}
-
+
@Override
public IBlockState getDisplayTile() {
return PluginApiculture.blocks.beeHouse.getDefaultState();
@@ -73,7 +71,6 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
return Collections.singleton(beeListener);
}
- @Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return beeInventory;
diff --git a/src/main/java/forestry/apiculture/entities/ParticleBeeExplore.java b/src/main/java/forestry/apiculture/entities/ParticleBeeExplore.java
index 5187a47e9..f8438609b 100644
--- a/src/main/java/forestry/apiculture/entities/ParticleBeeExplore.java
+++ b/src/main/java/forestry/apiculture/entities/ParticleBeeExplore.java
@@ -52,7 +52,7 @@ public class ParticleBeeExplore extends Particle {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
- this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ this.move(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (origin.xCoord - this.posX) * 0.03;
@@ -125,11 +125,11 @@ public class ParticleBeeExplore extends Particle {
// avoid calculating collisions
@Override
- public void moveEntity(double x, double y, double z) {
- this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
+ public void move(double x, double y, double z) {
+ this.setBoundingBox(this.getBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
-
+
@Override
public int getFXLayer() {
return 1;
diff --git a/src/main/java/forestry/apiculture/entities/ParticleBeeRoundTrip.java b/src/main/java/forestry/apiculture/entities/ParticleBeeRoundTrip.java
index f681665a7..c00700129 100644
--- a/src/main/java/forestry/apiculture/entities/ParticleBeeRoundTrip.java
+++ b/src/main/java/forestry/apiculture/entities/ParticleBeeRoundTrip.java
@@ -54,7 +54,7 @@ public class ParticleBeeRoundTrip extends Particle {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
- this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ this.move(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (origin.xCoord - this.posX) * 0.03 + 0.1 * rand.nextFloat();
@@ -128,8 +128,8 @@ public class ParticleBeeRoundTrip extends Particle {
// avoid calculating collisions
@Override
- public void moveEntity(double x, double y, double z) {
- this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
+ public void move(double x, double y, double z) {
+ this.setBoundingBox(this.getBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
diff --git a/src/main/java/forestry/apiculture/entities/ParticleBeeTargetEntity.java b/src/main/java/forestry/apiculture/entities/ParticleBeeTargetEntity.java
index 5f585afcd..7289f9d8e 100644
--- a/src/main/java/forestry/apiculture/entities/ParticleBeeTargetEntity.java
+++ b/src/main/java/forestry/apiculture/entities/ParticleBeeTargetEntity.java
@@ -54,7 +54,7 @@ public class ParticleBeeTargetEntity extends Particle {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
- this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ this.move(this.motionX, this.motionY, this.motionZ);
if (this.particleAge == this.particleMaxAge / 2) {
this.motionX = (origin.xCoord - this.posX) * 0.03;
@@ -125,8 +125,8 @@ public class ParticleBeeTargetEntity extends Particle {
// avoid calculating collisions
@Override
- public void moveEntity(double x, double y, double z) {
- this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z));
+ public void move(double x, double y, double z) {
+ this.setBoundingBox(this.getBoundingBox().offset(x, y, z));
this.resetPositionToBB();
}
diff --git a/src/main/java/forestry/apiculture/entities/package-info.java b/src/main/java/forestry/apiculture/entities/package-info.java
new file mode 100644
index 000000000..a32e04c55
--- /dev/null
+++ b/src/main/java/forestry/apiculture/entities/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.entities;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java
index a9a4cb72a..32c667778 100644
--- a/src/main/java/forestry/apiculture/flowers/FlowerProvider.java
+++ b/src/main/java/forestry/apiculture/flowers/FlowerProvider.java
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture.flowers;
+import java.util.List;
+
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.ICheckPollinatable;
import forestry.api.genetics.IFlowerProvider;
@@ -56,7 +58,7 @@ public class FlowerProvider implements IFlowerProvider {
}
@Override
- public ItemStack[] affectProducts(World world, IIndividual individual, BlockPos pos, ItemStack[] products) {
+ public List affectProducts(World world, IIndividual individual, BlockPos pos, List products) {
return products;
}
diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java
index f98c6414c..7a1ecbd69 100644
--- a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java
+++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java
@@ -10,11 +10,6 @@
******************************************************************************/
package forestry.apiculture.flowers;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableSet;
-
-import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -23,13 +18,8 @@ import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
-import net.minecraft.block.Block;
-import net.minecraft.block.state.IBlockState;
-import net.minecraft.init.Blocks;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Vec3i;
-import net.minecraft.world.World;
-
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.HashMultimap;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IBee;
@@ -43,21 +33,14 @@ import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.utils.Log;
import forestry.core.utils.VectUtil;
+import net.minecraft.block.Block;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Vec3i;
+import net.minecraft.world.World;
public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelper {
-
- private final Set defaultFlowerTypes = ImmutableSet.of(
- FlowerManager.FlowerTypeVanilla,
- FlowerManager.FlowerTypeNether,
- FlowerManager.FlowerTypeCacti,
- FlowerManager.FlowerTypeMushrooms,
- FlowerManager.FlowerTypeEnd,
- FlowerManager.FlowerTypeJungle,
- FlowerManager.FlowerTypeSnow,
- FlowerManager.FlowerTypeWheat,
- FlowerManager.FlowerTypeGourd
- );
-
private final HashMultimap registeredRules;
private final HashMultimap acceptableBlocks;
private final HashMultimap acceptableBlockStates;
@@ -152,7 +135,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
}
@Override
- @Nonnull
+
public List getAcceptedFlowerCoordinates(IBeeHousing beeHousing, IBee bee, String flowerType, int maxFlowers) {
Set acceptableRules = this.registeredRules.get(flowerType);
Set acceptedBlockStates = this.acceptableBlockStates.get(flowerType);
diff --git a/src/main/java/forestry/apiculture/flowers/GrowthRuleDirtGrass.java b/src/main/java/forestry/apiculture/flowers/GrowthRuleDirtGrass.java
index d627c5efa..b174ce922 100644
--- a/src/main/java/forestry/apiculture/flowers/GrowthRuleDirtGrass.java
+++ b/src/main/java/forestry/apiculture/flowers/GrowthRuleDirtGrass.java
@@ -27,11 +27,8 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
}
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
- if (ground != Blocks.DIRT && ground != Blocks.GRASS) {
- return false;
- }
-
- return helper.plantRandomFlower(flowerType, world, pos);
+ return (ground == Blocks.DIRT || ground == Blocks.GRASS) &&
+ helper.plantRandomFlower(flowerType, world, pos);
}
}
diff --git a/src/main/java/forestry/apiculture/flowers/GrowthRuleMycelium.java b/src/main/java/forestry/apiculture/flowers/GrowthRuleMycelium.java
index 7e8ea3339..480b20a4d 100644
--- a/src/main/java/forestry/apiculture/flowers/GrowthRuleMycelium.java
+++ b/src/main/java/forestry/apiculture/flowers/GrowthRuleMycelium.java
@@ -27,11 +27,8 @@ public class GrowthRuleMycelium implements IFlowerGrowthRule {
}
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
- if (ground != Blocks.MYCELIUM) {
- return false;
- }
-
- return helper.plantRandomFlower(flowerType, world, pos);
+ return ground == Blocks.MYCELIUM &&
+ helper.plantRandomFlower(flowerType, world, pos);
}
}
diff --git a/src/main/java/forestry/apiculture/flowers/GrowthRuleSnow.java b/src/main/java/forestry/apiculture/flowers/GrowthRuleSnow.java
index 3b65d330a..a572366c9 100644
--- a/src/main/java/forestry/apiculture/flowers/GrowthRuleSnow.java
+++ b/src/main/java/forestry/apiculture/flowers/GrowthRuleSnow.java
@@ -27,11 +27,8 @@ public class GrowthRuleSnow implements IFlowerGrowthRule {
}
Block ground = world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
- if (ground != Blocks.DIRT && ground != Blocks.GRASS) {
- return false;
- }
-
- return helper.plantRandomFlower(flowerType, world, pos);
+ return (ground == Blocks.DIRT || ground == Blocks.GRASS) &&
+ helper.plantRandomFlower(flowerType, world, pos);
}
}
diff --git a/src/main/java/forestry/apiculture/flowers/package-info.java b/src/main/java/forestry/apiculture/flowers/package-info.java
new file mode 100644
index 000000000..00c276d4f
--- /dev/null
+++ b/src/main/java/forestry/apiculture/flowers/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.flowers;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java b/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java
index 192369da1..83b7ca817 100755
--- a/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java
+++ b/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java
@@ -10,11 +10,6 @@
******************************************************************************/
package forestry.apiculture.genetics;
-import javax.annotation.Nonnull;
-
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.nbt.NBTTagCompound;
-
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IApiaristTracker;
@@ -22,10 +17,14 @@ import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.genetics.BreedingTracker;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
public class ApiaristTracker extends BreedingTracker implements IApiaristTracker {
- /** Required for creation from map storage */
+ /**
+ * Required for creation from map storage
+ */
public ApiaristTracker(String s) {
super(s);
}
@@ -35,7 +34,7 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
private int princessesTotal = 0;
@Override
- public void readFromNBT(@Nonnull NBTTagCompound nbttagcompound) {
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
queensTotal = nbttagcompound.getInteger("QueensTotal");
princessesTotal = nbttagcompound.getInteger("PrincessesTotal");
@@ -45,9 +44,8 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
}
- @Nonnull
@Override
- public NBTTagCompound writeToNBT(@Nonnull NBTTagCompound nbttagcompound) {
+ public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("QueensTotal", queensTotal);
nbttagcompound.setInteger("PrincessesTotal", princessesTotal);
@@ -87,7 +85,6 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
@Override
public void registerPrincess(IIndividual bee) {
-
princessesTotal++;
registerBirth(bee);
}
@@ -110,7 +107,7 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
@Override
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
- return BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile());
+ return BeeManager.beeRoot.getBreedingTracker(player.world, player.getGameProfile());
}
@Override
diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java
index ddf70d82f..dc97a69ef 100644
--- a/src/main/java/forestry/apiculture/genetics/Bee.java
+++ b/src/main/java/forestry/apiculture/genetics/Bee.java
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture.genetics;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
@@ -19,18 +18,7 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
-import net.minecraft.item.EnumRarity;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Vec3i;
-import net.minecraft.util.text.TextFormatting;
-import net.minecraft.world.World;
-import net.minecraft.world.biome.Biome;
-
import com.mojang.authlib.GameProfile;
-
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.FlowerManager;
@@ -64,22 +52,29 @@ import forestry.core.genetics.Chromosome;
import forestry.core.genetics.GenericRatings;
import forestry.core.genetics.IndividualLiving;
import forestry.core.utils.GeneticsUtil;
-import forestry.core.utils.Log;
import forestry.core.utils.Translator;
import forestry.core.utils.VectUtil;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Vec3i;
+import net.minecraft.util.text.TextFormatting;
+import net.minecraft.world.World;
+import net.minecraft.world.biome.Biome;
public class Bee extends IndividualLiving implements IBee {
private int generation;
private boolean isNatural = true;
- @Nonnull
private final IBeeGenome genome;
@Nullable
private IBeeGenome mate;
/* CONSTRUCTOR */
- public Bee(@Nonnull NBTTagCompound nbt) {
+ public Bee(NBTTagCompound nbt) {
super(nbt);
if (nbt.hasKey("NA")) {
@@ -101,16 +96,16 @@ public class Bee extends IndividualLiving implements IBee {
}
}
- public Bee(@Nonnull IBeeGenome genome, IBee mate) {
+ public Bee(IBeeGenome genome, IBee mate) {
this(genome);
this.mate = mate.getGenome();
}
- public Bee(@Nonnull IBeeGenome genome) {
+ public Bee(IBeeGenome genome) {
this(genome, true, 0);
}
- private Bee(@Nonnull IBeeGenome genome, boolean isNatural, int generation) {
+ private Bee(IBeeGenome genome, boolean isNatural, int generation) {
super(genome.getLifespan());
this.genome = genome;
this.isNatural = isNatural;
@@ -162,10 +157,6 @@ public class Bee extends IndividualLiving implements IBee {
public IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing) {
IAlleleBeeEffect effect = genome.getEffect();
- if (effect == null) {
- return null;
- }
-
storedData[0] = doEffect(effect, storedData[0], housing);
// Return here if the primary can already not be combined
@@ -192,10 +183,6 @@ public class Bee extends IndividualLiving implements IBee {
public IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing) {
IAlleleBeeEffect effect = genome.getEffect();
- if (effect == null) {
- return null;
- }
-
storedData[0] = doFX(effect, storedData[0], housing);
// Return here if the primary can already not be combined
@@ -218,7 +205,6 @@ public class Bee extends IndividualLiving implements IBee {
}
// / INFORMATION
- @Nonnull
@Override
public IBeeGenome getGenome() {
return genome;
@@ -235,7 +221,6 @@ public class Bee extends IndividualLiving implements IBee {
NBTTagCompound nbttagcompound = new NBTTagCompound();
this.writeToNBT(nbttagcompound);
return new Bee(nbttagcompound);
-
}
@Override
@@ -246,7 +231,6 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public Set getCanWork(IBeeHousing housing) {
World world = housing.getWorldObj();
- BlockPos housingCoords = housing.getCoordinates();
Set errorStates = new HashSet<>();
@@ -279,7 +263,7 @@ public class Bee extends IndividualLiving implements IBee {
}
// / Check for the sky, except if in hell
- if (!world.provider.getHasNoSky()) {
+ if (!world.provider.hasNoSky()) {
if (!housing.canBlockSeeTheSky() && !canWorkUnderground(beeModifier)) {
errorStates.add(EnumErrorCode.NO_SKY);
}
@@ -335,10 +319,6 @@ public class Bee extends IndividualLiving implements IBee {
}
private boolean isSuitableBiome(Biome biome) {
- if (biome == null) {
- return false;
- }
-
EnumTemperature temperature = EnumTemperature.getFromBiome(biome);
EnumHumidity humidity = EnumHumidity.getFromValue(biome.getRainfall());
return isSuitableClimate(temperature, humidity);
@@ -351,8 +331,8 @@ public class Bee extends IndividualLiving implements IBee {
}
@Override
- public ArrayList getSuitableBiomes() {
- ArrayList suitableBiomes = new ArrayList<>();
+ public List getSuitableBiomes() {
+ List suitableBiomes = new ArrayList<>();
for (Biome biome : Biome.REGISTRY) {
if (isSuitableBiome(biome)) {
suitableBiomes.add(biome);
@@ -473,17 +453,9 @@ public class Bee extends IndividualLiving implements IBee {
}
@Override
- public ItemStack[] produceStacks(IBeeHousing housing) {
- if (housing == null) {
- Log.warning("Failed to produce in an apiary because the beehousing was null.");
- return null;
- }
+ public List produceStacks(IBeeHousing housing) {
World world = housing.getWorldObj();
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
- if (mode == null) {
- Log.warning("Failed to produce in an apiary because the beekeeping mode was null.");
- return null;
- }
List products = new ArrayList<>();
@@ -523,13 +495,13 @@ public class Bee extends IndividualLiving implements IBee {
}
}
- ItemStack[] productsArray = products.toArray(new ItemStack[products.size()]);
BlockPos housingCoordinates = housing.getCoordinates();
- return genome.getFlowerProvider().affectProducts(world, this, housingCoordinates, productsArray);
+ return genome.getFlowerProvider().affectProducts(world, this, housingCoordinates, products);
}
/* REPRODUCTION */
@Override
+ @Nullable
public IBee spawnPrincess(IBeeHousing housing) {
// We need a mated queen to produce offspring.
@@ -542,17 +514,18 @@ public class Bee extends IndividualLiving implements IBee {
return null;
}
- return createOffspring(housing, getGeneration() + 1);
+ return createOffspring(housing, mate, getGeneration() + 1);
}
@Override
+ @Nullable
public IBee[] spawnDrones(IBeeHousing housing) {
World world = housing.getWorldObj();
// We need a mated queen to produce offspring.
if (mate == null) {
- return null;
+ return new IBee[]{};
}
List bees = new ArrayList<>();
@@ -565,11 +538,9 @@ public class Bee extends IndividualLiving implements IBee {
}
for (int i = 0; i < toCreate; i++) {
- IBee offspring = createOffspring(housing, 0);
- if (offspring != null) {
- offspring.setIsNatural(true);
- bees.add(offspring);
- }
+ IBee offspring = createOffspring(housing, mate, 0);
+ offspring.setIsNatural(true);
+ bees.add(offspring);
}
if (!bees.isEmpty()) {
@@ -579,7 +550,7 @@ public class Bee extends IndividualLiving implements IBee {
}
}
- private IBee createOffspring(IBeeHousing housing, int generation) {
+ private IBee createOffspring(IBeeHousing housing, IBeeGenome mate, int generation) {
World world = housing.getWorldObj();
@@ -588,7 +559,7 @@ public class Bee extends IndividualLiving implements IBee {
IChromosome[] parent2 = mate.getChromosomes();
// Check for mutation. Replace one of the parents with the mutation
- // template if mutation occured.
+ // template if mutation occurred.
IChromosome[] mutated1 = mutateSpecies(housing, genome, mate);
if (mutated1 != null) {
parent1 = mutated1;
@@ -608,6 +579,7 @@ public class Bee extends IndividualLiving implements IBee {
return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
}
+ @Nullable
private static IChromosome[] mutateSpecies(IBeeHousing housing, IBeeGenome genomeOne, IBeeGenome genomeTwo) {
World world = housing.getWorldObj();
@@ -665,6 +637,7 @@ public class Bee extends IndividualLiving implements IBee {
/* FLOWERS */
@Override
+ @Nullable
public IIndividual retrievePollen(IBeeHousing housing) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
diff --git a/src/main/java/forestry/apiculture/genetics/BeeAlyzerPlugin.java b/src/main/java/forestry/apiculture/genetics/BeeAlyzerPlugin.java
index 7d64837f3..e5feba7ea 100644
--- a/src/main/java/forestry/apiculture/genetics/BeeAlyzerPlugin.java
+++ b/src/main/java/forestry/apiculture/genetics/BeeAlyzerPlugin.java
@@ -1,16 +1,9 @@
package forestry.apiculture.genetics;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.item.ItemStack;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
@@ -29,6 +22,11 @@ import forestry.core.gui.widgets.ItemStackWidget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Translator;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
public class BeeAlyzerPlugin implements IAlyzerPlugin {
public static final BeeAlyzerPlugin INSTANCE = new BeeAlyzerPlugin();
@@ -36,7 +34,7 @@ public class BeeAlyzerPlugin implements IAlyzerPlugin {
protected final Map iconStacks = new HashMap<>();
private BeeAlyzerPlugin() {
- ArrayList beeList = new ArrayList<>();
+ NonNullList beeList = NonNullList.create();
PluginApiculture.items.beeDroneGE.addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList) {
IAlleleBeeSpecies species = BeeGenome.getSpecies(beeStack);
@@ -56,6 +54,9 @@ public class BeeAlyzerPlugin implements IAlyzerPlugin {
return;
}
EnumBeeType type = BeeManager.beeRoot.getType(itemStack);
+ if (type == null) {
+ return;
+ }
TextLayoutHelper textLayout = guiAlyzer.getTextLayout();
diff --git a/src/main/java/forestry/apiculture/genetics/BeeBranchDefinition.java b/src/main/java/forestry/apiculture/genetics/BeeBranchDefinition.java
index 1d2401f26..c0c1d1f13 100644
--- a/src/main/java/forestry/apiculture/genetics/BeeBranchDefinition.java
+++ b/src/main/java/forestry/apiculture/genetics/BeeBranchDefinition.java
@@ -1,5 +1,6 @@
package forestry.apiculture.genetics;
+import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Locale;
@@ -7,7 +8,7 @@ import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
-import forestry.apiculture.genetics.alleles.AlleleEffect;
+import forestry.apiculture.genetics.alleles.AlleleEffects;
import forestry.core.genetics.IBranchDefinition;
import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.genetics.alleles.EnumAllele;
@@ -20,96 +21,96 @@ public enum BeeBranchDefinition implements IBranchDefinition {
INFERNAL("Diapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.DOWN_2);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.NETHER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.AVERAGE);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.DOWN_2);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.NETHER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.AVERAGE);
}
},
AUSTERE("Modapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.DOWN_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.CACTI);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.DOWN_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.CACTI);
}
},
TROPICAL("Caldapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.UP_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.JUNGLE);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.EFFECT, AlleleEffect.effectMiasmic);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.UP_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.JUNGLE);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.EFFECT, AlleleEffects.effectMiasmic);
}
},
END("Finapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.LOW);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGE);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.END);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.EFFECT, AlleleEffect.effectMisanthrope);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.LOW);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGE);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.END);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.EFFECT, AlleleEffects.effectMisanthrope);
}
},
FROZEN("Coagapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.SNOW);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.EFFECT, AlleleEffect.effectGlacial);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.UP_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.SNOW);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.EFFECT, AlleleEffects.effectGlacial);
}
},
VENGEFUL("Punapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGEST);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.EFFECT, AlleleEffect.effectRadioactive);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGEST);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.EFFECT, AlleleEffects.effectRadioactive);
}
},
FESTIVE("Festapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_2);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_2);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
}
},
AGRARIAN("Rustapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.WHEAT);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.WHEAT);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTER);
}
},
BOGGY("Paludapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.MUSHROOMS);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.MUSHROOMS);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
}
},
MONASTIC("Monapis") {
@Override
protected void setBranchProperties(IAllele[] alleles) {
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.LOW);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTER);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.CAVE_DWELLING, true);
- AlleleHelper.instance.set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.WHEAT);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.LOW);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTER);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.CAVE_DWELLING, true);
+ AlleleHelper.getInstance().set(alleles, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.WHEAT);
}
};
@@ -135,24 +136,25 @@ public enum BeeBranchDefinition implements IBranchDefinition {
return branch;
}
+ @Nullable
private static IAllele[] defaultTemplate;
private static IAllele[] getDefaultTemplate() {
if (defaultTemplate == null) {
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.NORMAL);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.NONE);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.NEVER_SLEEPS, false);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.NONE);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.TOLERATES_RAIN, false);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.CAVE_DWELLING, false);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.VANILLA);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWEST);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.AVERAGE);
- AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.EFFECT, AlleleEffect.effectNone);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.NORMAL);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.NONE);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.NEVER_SLEEPS, false);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.NONE);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.TOLERATES_RAIN, false);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.CAVE_DWELLING, false);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.VANILLA);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWEST);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.AVERAGE);
+ AlleleHelper.getInstance().set(defaultTemplate, EnumBeeChromosome.EFFECT, AlleleEffects.effectNone);
}
return Arrays.copyOf(defaultTemplate, defaultTemplate.length);
}
diff --git a/src/main/java/forestry/apiculture/genetics/BeeDefinition.java b/src/main/java/forestry/apiculture/genetics/BeeDefinition.java
index 7df6c49c6..259afceb3 100644
--- a/src/main/java/forestry/apiculture/genetics/BeeDefinition.java
+++ b/src/main/java/forestry/apiculture/genetics/BeeDefinition.java
@@ -10,18 +10,12 @@
******************************************************************************/
package forestry.apiculture.genetics;
+import javax.annotation.Nullable;
import java.awt.Color;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Locale;
-import org.apache.commons.lang3.text.WordUtils;
-
-import net.minecraft.init.Items;
-import net.minecraft.item.ItemStack;
-
-import net.minecraftforge.common.BiomeDictionary;
-import net.minecraftforge.common.MinecraftForge;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
@@ -35,13 +29,18 @@ import forestry.api.core.EnumTemperature;
import forestry.api.genetics.AlleleSpeciesRegisterEvent;
import forestry.api.genetics.IAllele;
import forestry.apiculture.PluginApiculture;
-import forestry.apiculture.genetics.alleles.AlleleEffect;
+import forestry.apiculture.genetics.alleles.AlleleEffects;
import forestry.apiculture.items.EnumHoneyComb;
import forestry.apiculture.items.EnumPollenCluster;
import forestry.core.PluginCore;
import forestry.core.config.Constants;
import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.genetics.alleles.EnumAllele;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.BiomeDictionary;
+import net.minecraftforge.common.MinecraftForge;
+import org.apache.commons.lang3.text.WordUtils;
public enum BeeDefinition implements IBeeDefinition {
/* HONEY BRANCH */
@@ -53,8 +52,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.HIGH);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.HIGH);
}
@Override
@@ -70,7 +69,7 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOWER);
}
@Override
@@ -86,7 +85,7 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
}
@Override
@@ -108,8 +107,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.FAST);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.FAST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTEST);
}
@Override
@@ -129,9 +128,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
- AlleleHelper.instance.set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOW);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOW);
}
@Override
@@ -147,9 +146,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTENED);
- AlleleHelper.instance.set(template, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.MAXIMUM);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTENED);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.MAXIMUM);
}
@Override
@@ -167,9 +166,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectBeatific);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectBeatific);
}
@Override
@@ -187,9 +186,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
- AlleleHelper.instance.set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOW);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.SLOW);
}
@Override
@@ -205,8 +204,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTENED);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTENED);
}
@Override
@@ -224,9 +223,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FAST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FAST);
}
@Override
@@ -245,10 +244,10 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.CAVE_DWELLING, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.CAVE_DWELLING, true);
}
@Override
@@ -265,10 +264,10 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
- AlleleHelper.instance.set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.CAVE_DWELLING, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.CAVE_DWELLING, true);
}
@Override
@@ -285,11 +284,11 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
- AlleleHelper.instance.set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.CAVE_DWELLING, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectHeroic);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.CAVE_DWELLING, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectHeroic);
}
@Override
@@ -310,9 +309,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectAggressive);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectAggressive);
}
@Override
@@ -334,9 +333,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectAggressive);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectAggressive);
}
@Override
@@ -359,9 +358,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectIgnition);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectIgnition);
}
@Override
@@ -382,8 +381,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
}
@Override
@@ -401,8 +400,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
}
@Override
@@ -427,10 +426,10 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.DOWN_2);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectCreeper);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.DOWN_2);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectCreeper);
}
@Override
@@ -452,8 +451,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
}
@Override
@@ -471,8 +470,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONG);
}
@Override
@@ -491,10 +490,10 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_2);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectExploration);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_2);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectExploration);
}
@Override
@@ -530,7 +529,7 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectReanimation);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectReanimation);
}
@Override
@@ -548,9 +547,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGEST);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectResurrection);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectResurrection);
}
@Override
@@ -569,9 +568,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
- AlleleHelper.instance.set(template, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.MAXIMUM);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.MAXIMUM);
}
@Override
@@ -589,8 +588,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
}
@Override
@@ -610,8 +609,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORT);
}
@Override
@@ -631,8 +630,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.NORMAL);
}
@Override
@@ -649,8 +648,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.NORMAL);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGER);
}
@Override
@@ -669,8 +668,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
- AlleleHelper.instance.set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.LONGEST);
}
@Override
@@ -692,7 +691,7 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectFestiveEaster);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectFestiveEaster);
}
@Override
@@ -720,8 +719,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectSnowing);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectSnowing);
}
@Override
@@ -749,8 +748,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectDrunkard);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectDrunkard);
}
@Override
@@ -782,9 +781,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.TOLERATES_RAIN, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.GOURD);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TOLERATES_RAIN, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FLOWER_PROVIDER, EnumAllele.Flowers.GOURD);
}
@Override
@@ -827,8 +826,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
- AlleleHelper.instance.set(template, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGE);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGE);
}
@Override
@@ -846,10 +845,10 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
- AlleleHelper.instance.set(template, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_2);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectFertile);
- AlleleHelper.instance.set(template, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGE);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOW);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.HUMIDITY_TOLERANCE, EnumAllele.Tolerance.BOTH_2);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectFertile);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGE);
}
@Override
@@ -886,9 +885,9 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.MAXIMUM);
- AlleleHelper.instance.set(template, EnumBeeChromosome.TOLERATES_RAIN, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FERTILITY, EnumAllele.Fertility.MAXIMUM);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TOLERATES_RAIN, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
}
@Override
@@ -908,10 +907,10 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.TOLERATES_RAIN, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectMycophilic);
- AlleleHelper.instance.set(template, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGER);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TOLERATES_RAIN, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.NEVER_SLEEPS, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectMycophilic);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TERRITORY, EnumAllele.Territory.LARGER);
}
@Override
@@ -950,7 +949,7 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTEST);
}
@Override
@@ -968,8 +967,8 @@ public enum BeeDefinition implements IBeeDefinition {
@Override
protected void setAlleles(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTEST);
- AlleleHelper.instance.set(template, EnumBeeChromosome.EFFECT, AlleleEffect.effectRepulsion);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.FLOWERING, EnumAllele.Flowering.FASTEST);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.EFFECT, AlleleEffects.effectRepulsion);
}
@Override
@@ -983,7 +982,9 @@ public enum BeeDefinition implements IBeeDefinition {
private final BeeBranchDefinition branch;
private final IAlleleBeeSpecies species;
+ @Nullable
private IAllele[] template;
+ @Nullable
private IBeeGenome genome;
BeeDefinition(BeeBranchDefinition branch, String binomial, boolean dominant, Color primary, Color secondary) {
@@ -1029,7 +1030,7 @@ public enum BeeDefinition implements IBeeDefinition {
private void init() {
template = branch.getTemplate();
- AlleleHelper.instance.set(template, EnumBeeChromosome.SPECIES, species);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.SPECIES, species);
setAlleles(template);
genome = BeeManager.beeRoot.templateAsGenome(template);
diff --git a/src/main/java/forestry/apiculture/genetics/BeeGenome.java b/src/main/java/forestry/apiculture/genetics/BeeGenome.java
index 5311d3c30..c4d98a704 100755
--- a/src/main/java/forestry/apiculture/genetics/BeeGenome.java
+++ b/src/main/java/forestry/apiculture/genetics/BeeGenome.java
@@ -10,9 +10,9 @@
******************************************************************************/
package forestry.apiculture.genetics;
-import javax.annotation.Nonnull;
import java.util.concurrent.TimeUnit;
+import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -60,16 +60,12 @@ public class BeeGenome extends Genome implements IBeeGenome {
.expireAfterAccess(1, TimeUnit.MINUTES)
.build(new CacheLoader() {
@Override
- public BeeGenome load(@Nonnull NBTTagCompound tagCompound) {
+ public BeeGenome load(NBTTagCompound tagCompound) {
return new BeeGenome(tagCompound);
}
});
public static BeeGenome fromNBT(NBTTagCompound nbtTagCompound) {
- if (nbtTagCompound == null) {
- return null;
- }
-
return beeGenomeCache.getUnchecked(nbtTagCompound);
}
@@ -84,9 +80,7 @@ public class BeeGenome extends Genome implements IBeeGenome {
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
- if (!BeeManager.beeRoot.isMember(itemStack)) {
- return null;
- }
+ Preconditions.checkArgument(BeeManager.beeRoot.isMember(itemStack), "itemStack must be a bee");
IAlleleSpecies species = getSpeciesDirectly(BeeManager.beeRoot, itemStack);
if (species instanceof IAlleleBeeSpecies) {
@@ -98,13 +92,11 @@ public class BeeGenome extends Genome implements IBeeGenome {
// / INFORMATION RETRIEVAL
@Override
- @Nonnull
public IAlleleBeeSpecies getPrimary() {
return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES);
}
@Override
- @Nonnull
public IAlleleBeeSpecies getSecondary() {
return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES);
}
@@ -170,7 +162,6 @@ public class BeeGenome extends Genome implements IBeeGenome {
}
@Override
- @Nonnull
public ISpeciesRoot getSpeciesRoot() {
return BeeManager.beeRoot;
}
diff --git a/src/main/java/forestry/apiculture/genetics/BeeRoot.java b/src/main/java/forestry/apiculture/genetics/BeeRoot.java
index b5f80c505..4006c111c 100644
--- a/src/main/java/forestry/apiculture/genetics/BeeRoot.java
+++ b/src/main/java/forestry/apiculture/genetics/BeeRoot.java
@@ -17,6 +17,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
+import com.google.common.base.Preconditions;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
@@ -44,6 +45,7 @@ import forestry.apiculture.BeeHousingListener;
import forestry.apiculture.BeeHousingModifier;
import forestry.apiculture.BeekeepingLogic;
import forestry.apiculture.PluginApiculture;
+import forestry.apiculture.items.ItemRegistryApiculture;
import forestry.core.genetics.SpeciesRoot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -54,8 +56,16 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
public class BeeRoot extends SpeciesRoot implements IBeeRoot {
private static int beeSpeciesCount = -1;
+ private static final List beeTemplates = new ArrayList<>();
+ /** List of possible mutations on species alleles. */
+ private static final List beeMutations = new ArrayList<>();
public static final String UID = "rootBees";
+ private final List beekeepingModes = new ArrayList<>();
+
+ @Nullable
+ private static IBeekeepingMode activeBeekeepingMode;
+
@Override
public String getUID() {
return UID;
@@ -99,31 +109,29 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
@Override
public ItemStack getMemberStack(IIndividual individual, ISpeciesType type) {
- if (!isMember(individual)) {
- return null;
- }
- IBee bee = (IBee) individual;
- if (!(type instanceof EnumBeeType)) {
- return null;
- }
+ Preconditions.checkArgument(individual instanceof IBee, "individual is not a bee");
+ Preconditions.checkArgument(type instanceof EnumBeeType, "type is not an EnumBeeType");
+ ItemRegistryApiculture apicultureItems = PluginApiculture.items;
+ Preconditions.checkState(apicultureItems != null, "Apiculture items are null");
+ IBee bee = (IBee) individual;
Item beeItem;
switch ((EnumBeeType) type) {
case QUEEN:
- beeItem = PluginApiculture.items.beeQueenGE;
+ beeItem = apicultureItems.beeQueenGE;
// ensure a queen is always mated
if (bee.getMate() == null) {
bee.mate(bee);
}
break;
case PRINCESS:
- beeItem = PluginApiculture.items.beePrincessGE;
+ beeItem = apicultureItems.beePrincessGE;
break;
case DRONE:
- beeItem = PluginApiculture.items.beeDroneGE;
+ beeItem = apicultureItems.beeDroneGE;
break;
case LARVAE:
- beeItem = PluginApiculture.items.beeLarvaeGE;
+ beeItem = apicultureItems.beeLarvaeGE;
break;
default:
throw new RuntimeException("Cannot instantiate a bee of type " + type);
@@ -139,19 +147,17 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
@Nullable
@Override
public EnumBeeType getType(ItemStack stack) {
- if (stack == null) {
- return null;
- }
-
Item item = stack.getItem();
+ ItemRegistryApiculture apicultureItems = PluginApiculture.items;
+ Preconditions.checkState(apicultureItems != null, "Apiculture items are null");
- if (PluginApiculture.items.beeDroneGE == item) {
+ if (apicultureItems.beeDroneGE == item) {
return EnumBeeType.DRONE;
- } else if (PluginApiculture.items.beePrincessGE == item) {
+ } else if (apicultureItems.beePrincessGE == item) {
return EnumBeeType.PRINCESS;
- } else if (PluginApiculture.items.beeQueenGE == item) {
+ } else if (apicultureItems.beeQueenGE == item) {
return EnumBeeType.QUEEN;
- } else if (PluginApiculture.items.beeLarvaeGE == item) {
+ } else if (apicultureItems.beeLarvaeGE == item) {
return EnumBeeType.LARVAE;
}
@@ -180,9 +186,8 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
@Override
public IBee getMember(ItemStack stack) {
- if (!isMember(stack) || !stack.hasTagCompound()) {
- return null;
- }
+ Preconditions.checkArgument(isMember(stack), "ItemStack must be a bee.");
+ Preconditions.checkArgument(stack.getTagCompound() != null, "ItemStack must have a tag compound.");
return new Bee(stack.getTagCompound());
}
@@ -225,10 +230,8 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
}
/* TEMPLATES */
- private static final ArrayList beeTemplates = new ArrayList<>();
-
@Override
- public ArrayList getIndividualTemplates() {
+ public List getIndividualTemplates() {
return beeTemplates;
}
@@ -246,11 +249,6 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
}
/* MUTATIONS */
- /**
- * List of possible mutations on species alleles.
- */
- private static final List beeMutations = new ArrayList<>();
-
@Override
public List getMutations(boolean shuffle) {
if (shuffle) {
@@ -275,16 +273,13 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
}
/* BREEDING MODES */
- private final ArrayList beekeepingModes = new ArrayList<>();
- private static IBeekeepingMode activeBeekeepingMode;
-
@Override
public void resetBeekeepingMode() {
activeBeekeepingMode = null;
}
@Override
- public ArrayList getBeekeepingModes() {
+ public List getBeekeepingModes() {
return this.beekeepingModes;
}
@@ -331,14 +326,14 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
}
@Override
- public IApiaristTracker getBreedingTracker(World world, GameProfile player) {
+ public IApiaristTracker getBreedingTracker(World world, @Nullable GameProfile player) {
String filename = "ApiaristTracker." + (player == null ? "common" : player.getId());
- ApiaristTracker tracker = (ApiaristTracker) world.loadItemData(ApiaristTracker.class, filename);
+ ApiaristTracker tracker = (ApiaristTracker) world.loadData(ApiaristTracker.class, filename);
// Create a tracker if there is none yet.
if (tracker == null) {
tracker = new ApiaristTracker(filename);
- world.setItemData(filename, tracker);
+ world.setData(filename, tracker);
}
tracker.setUsername(player);
diff --git a/src/main/java/forestry/apiculture/genetics/BeeVariation.java b/src/main/java/forestry/apiculture/genetics/BeeVariation.java
index 686e38a47..ed37c214e 100644
--- a/src/main/java/forestry/apiculture/genetics/BeeVariation.java
+++ b/src/main/java/forestry/apiculture/genetics/BeeVariation.java
@@ -51,7 +51,7 @@ public abstract class BeeVariation implements IBeeDefinition {
@Override
protected void initializeTemplate(IAllele[] template) {
- AlleleHelper.instance.set(template, EnumBeeChromosome.TOLERATES_RAIN, true);
+ AlleleHelper.getInstance().set(template, EnumBeeChromosome.TOLERATES_RAIN, true);
}
}
}
diff --git a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java
index c20c8621e..f849d087f 100755
--- a/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java
+++ b/src/main/java/forestry/apiculture/genetics/BeekeepingMode.java
@@ -11,6 +11,7 @@
package forestry.apiculture.genetics;
import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import java.util.Random;
@@ -53,8 +54,8 @@ public class BeekeepingMode implements IBeekeepingMode {
}
@Override
- public ArrayList getDescription() {
- ArrayList ret = new ArrayList<>();
+ public List getDescription() {
+ List ret = new ArrayList<>();
ret.add("beemode." + name.toLowerCase(Locale.ENGLISH) + ".desc");
return ret;
}
diff --git a/src/main/java/forestry/apiculture/genetics/DefaultBeeModelProvider.java b/src/main/java/forestry/apiculture/genetics/DefaultBeeModelProvider.java
index 8a5025083..9934b337c 100644
--- a/src/main/java/forestry/apiculture/genetics/DefaultBeeModelProvider.java
+++ b/src/main/java/forestry/apiculture/genetics/DefaultBeeModelProvider.java
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.genetics;
+import javax.annotation.Nullable;
import java.util.Locale;
import net.minecraft.client.renderer.block.model.ModelBakery;
@@ -34,6 +35,7 @@ public class DefaultBeeModelProvider implements IBeeModelProvider {
}
@SideOnly(Side.CLIENT)
+ @Nullable
private static ModelResourceLocation[] models;
@Override
diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java
index 6208b09b1..1e9b97f5d 100644
--- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java
+++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleBeeSpecies.java
@@ -76,8 +76,8 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public IAlleleBeeSpeciesBuilder addProduct(ItemStack product, Float chance) {
- if (product == null || product.getItem() == null) {
- throw new IllegalArgumentException("Tried to add null product");
+ if (product.isEmpty()) {
+ throw new IllegalArgumentException("Tried to add empty product");
}
if (chance <= 0.0f || chance > 1.0f) {
throw new IllegalArgumentException("chance must be in the range (0, 1]");
@@ -88,8 +88,8 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public IAlleleBeeSpeciesBuilder addSpecialty(ItemStack specialty, Float chance) {
- if (specialty == null || specialty.getItem() == null) {
- throw new IllegalArgumentException("Tried to add null specialty");
+ if (specialty.isEmpty()) {
+ throw new IllegalArgumentException("Tried to add empty specialty");
}
if (chance <= 0.0f || chance > 1.0f) {
throw new IllegalArgumentException("chance must be in the range (0, 1]");
diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java
index 5476b6f2f..7d6d3e860 100644
--- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java
+++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java
@@ -10,86 +10,32 @@
******************************************************************************/
package forestry.apiculture.genetics.alleles;
-import java.util.Arrays;
import java.util.List;
-import net.minecraft.entity.Entity;
-import net.minecraft.init.MobEffects;
-import net.minecraft.util.math.AxisAlignedBB;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Vec3i;
-
import forestry.api.apiculture.BeeManager;
-import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingLogic;
-import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IEffectData;
import forestry.core.config.Constants;
import forestry.core.genetics.alleles.AlleleCategorized;
import forestry.core.proxy.Proxies;
import forestry.core.utils.VectUtil;
+import net.minecraft.entity.Entity;
+import net.minecraft.util.math.AxisAlignedBB;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Vec3i;
public abstract class AlleleEffect extends AlleleCategorized implements IAlleleBeeEffect {
-
- public static IAlleleBeeEffect effectNone;
- public static IAlleleBeeEffect effectAggressive;
- public static IAlleleBeeEffect effectHeroic;
- public static IAlleleBeeEffect effectBeatific;
- public static IAlleleBeeEffect effectMiasmic;
- public static IAlleleBeeEffect effectMisanthrope;
- public static IAlleleBeeEffect effectGlacial;
- public static IAlleleBeeEffect effectRadioactive;
- public static IAlleleBeeEffect effectCreeper;
- public static IAlleleBeeEffect effectIgnition;
- public static IAlleleBeeEffect effectExploration;
- public static IAlleleBeeEffect effectFestiveEaster;
- public static IAlleleBeeEffect effectSnowing;
- public static IAlleleBeeEffect effectDrunkard;
- public static IAlleleBeeEffect effectReanimation;
- public static IAlleleBeeEffect effectResurrection;
- public static IAlleleBeeEffect effectRepulsion;
- public static IAlleleBeeEffect effectFertile;
- public static IAlleleBeeEffect effectMycophilic;
-
- public static void createAlleles() {
- List beeEffects = Arrays.asList(
- effectNone = new AlleleEffectNone("none", true),
- effectAggressive = new AlleleEffectAggressive(),
- effectHeroic = new AlleleEffectHeroic(),
- effectBeatific = new AlleleEffectPotion("beatific", false, MobEffects.REGENERATION, 100),
- effectMiasmic = new AlleleEffectPotion("miasmic", false, MobEffects.POISON, 600, 100, 0.1f),
- effectMisanthrope = new AlleleEffectMisanthrope(),
- effectGlacial = new AlleleEffectGlacial(),
- effectRadioactive = new AlleleEffectRadioactive(),
- effectCreeper = new AlleleEffectCreeper(),
- effectIgnition = new AlleleEffectIgnition(),
- effectExploration = new AlleleEffectExploration(),
- effectFestiveEaster = new AlleleEffectNone("festiveEaster", true),
- effectSnowing = new AlleleEffectSnowing(),
- effectDrunkard = new AlleleEffectPotion("drunkard", false, MobEffects.NAUSEA, 100),
- effectReanimation = new AlleleEffectResurrection("reanimation", AlleleEffectResurrection.getReanimationList()),
- effectResurrection = new AlleleEffectResurrection("resurrection", AlleleEffectResurrection.getResurrectionList()),
- effectRepulsion = new AlleleEffectRepulsion(),
- effectFertile = new AlleleEffectFertile(),
- effectMycophilic = new AlleleEffectFungification()
- );
-
- for (IAlleleBeeEffect beeEffect : beeEffects) {
- AlleleManager.alleleRegistry.registerAllele(beeEffect, EnumBeeChromosome.EFFECT);
- }
- }
-
protected AlleleEffect(String valueName, boolean isDominant) {
super(Constants.MOD_ID, "effect", valueName, isDominant);
}
@Override
public IEffectData validateStorage(IEffectData storedData) {
- return null;
+ return storedData;
}
@Override
diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java
index ca0c79a19..2547ecc18 100644
--- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java
+++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.genetics.alleles;
+import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFungification.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFungification.java
index f8cdc9272..45260dfab 100644
--- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFungification.java
+++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFungification.java
@@ -1,5 +1,6 @@
package forestry.apiculture.genetics.alleles;
+import javax.annotation.Nullable;
import java.util.List;
import forestry.api.apiculture.IBeeGenome;
@@ -105,14 +106,14 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
if (cow instanceof EntityMooshroom) {
return false;
}
- World worldObj = cow.worldObj;
+ World world = cow.world;
cow.setDead();
- EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
+ EntityMooshroom mooshroom = new EntityMooshroom(world);
mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch);
mooshroom.setHealth(cow.getHealth());
mooshroom.renderYawOffset = cow.renderYawOffset;
- worldObj.spawnEntityInWorld(mooshroom);
- worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, cow.posX, cow.posY + cow.height / 2.0F, cow.posZ, 0.0D, 0.0D, 0.0D);
+ world.spawnEntity(mooshroom);
+ world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, cow.posX, cow.posY + cow.height / 2.0F, cow.posZ, 0.0D, 0.0D, 0.0D);
return true;
}
}
diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectResurrection.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectResurrection.java
index b3feac440..1956ee006 100644
--- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectResurrection.java
+++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectResurrection.java
@@ -101,9 +101,9 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
ItemStack contained = entity.getEntityItem();
for (Resurrectable entry : resurrectables) {
if (ItemStackUtil.isIdenticalItem(entry.res, contained)) {
- EntityUtil.spawnEntity(entity.worldObj, entry.risen, entity.posX, entity.posY, entity.posZ);
- contained.stackSize--;
- if (contained.stackSize <= 0) {
+ EntityUtil.spawnEntity(entity.world, entry.risen, entity.posX, entity.posY, entity.posZ);
+ contained.shrink(1);
+ if (contained.getCount() <= 0) {
entity.setDead();
}
return true;
diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectThrottled.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectThrottled.java
index 6d047ebbc..a2e9ec313 100644
--- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectThrottled.java
+++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectThrottled.java
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture.genetics.alleles;
+import javax.annotation.Nullable;
+
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffects.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffects.java
new file mode 100644
index 000000000..a78125aec
--- /dev/null
+++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffects.java
@@ -0,0 +1,62 @@
+package forestry.apiculture.genetics.alleles;
+
+import java.util.Arrays;
+import java.util.List;
+
+import forestry.api.apiculture.EnumBeeChromosome;
+import forestry.api.apiculture.IAlleleBeeEffect;
+import forestry.api.genetics.AlleleManager;
+import net.minecraft.init.MobEffects;
+
+public class AlleleEffects {
+ public static final IAlleleBeeEffect effectNone;
+ public static final IAlleleBeeEffect effectAggressive;
+ public static final IAlleleBeeEffect effectHeroic;
+ public static final IAlleleBeeEffect effectBeatific;
+ public static final IAlleleBeeEffect effectMiasmic;
+ public static final IAlleleBeeEffect effectMisanthrope;
+ public static final IAlleleBeeEffect effectGlacial;
+ public static final IAlleleBeeEffect effectRadioactive;
+ public static final IAlleleBeeEffect effectCreeper;
+ public static final IAlleleBeeEffect effectIgnition;
+ public static final IAlleleBeeEffect effectExploration;
+ public static final IAlleleBeeEffect effectFestiveEaster;
+ public static final IAlleleBeeEffect effectSnowing;
+ public static final IAlleleBeeEffect effectDrunkard;
+ public static final IAlleleBeeEffect effectReanimation;
+ public static final IAlleleBeeEffect effectResurrection;
+ public static final IAlleleBeeEffect effectRepulsion;
+ public static final IAlleleBeeEffect effectFertile;
+ public static final IAlleleBeeEffect effectMycophilic;
+ private static final List beeEffects;
+
+ static {
+ beeEffects = Arrays.asList(
+ effectNone = new AlleleEffectNone("none", true),
+ effectAggressive = new AlleleEffectAggressive(),
+ effectHeroic = new AlleleEffectHeroic(),
+ effectBeatific = new AlleleEffectPotion("beatific", false, MobEffects.REGENERATION, 100),
+ effectMiasmic = new AlleleEffectPotion("miasmic", false, MobEffects.POISON, 600, 100, 0.1f),
+ effectMisanthrope = new AlleleEffectMisanthrope(),
+ effectGlacial = new AlleleEffectGlacial(),
+ effectRadioactive = new AlleleEffectRadioactive(),
+ effectCreeper = new AlleleEffectCreeper(),
+ effectIgnition = new AlleleEffectIgnition(),
+ effectExploration = new AlleleEffectExploration(),
+ effectFestiveEaster = new AlleleEffectNone("festiveEaster", true),
+ effectSnowing = new AlleleEffectSnowing(),
+ effectDrunkard = new AlleleEffectPotion("drunkard", false, MobEffects.NAUSEA, 100),
+ effectReanimation = new AlleleEffectResurrection("reanimation", AlleleEffectResurrection.getReanimationList()),
+ effectResurrection = new AlleleEffectResurrection("resurrection", AlleleEffectResurrection.getResurrectionList()),
+ effectRepulsion = new AlleleEffectRepulsion(),
+ effectFertile = new AlleleEffectFertile(),
+ effectMycophilic = new AlleleEffectFungification()
+ );
+ }
+
+ public static void registerAlleles() {
+ for (IAlleleBeeEffect beeEffect : beeEffects) {
+ AlleleManager.alleleRegistry.registerAllele(beeEffect, EnumBeeChromosome.EFFECT);
+ }
+ }
+}
diff --git a/src/main/java/forestry/apiculture/genetics/alleles/package-info.java b/src/main/java/forestry/apiculture/genetics/alleles/package-info.java
new file mode 100644
index 000000000..23cca36ee
--- /dev/null
+++ b/src/main/java/forestry/apiculture/genetics/alleles/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.genetics.alleles;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/genetics/package-info.java b/src/main/java/forestry/apiculture/genetics/package-info.java
new file mode 100644
index 000000000..82ba47c72
--- /dev/null
+++ b/src/main/java/forestry/apiculture/genetics/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.genetics;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java
index 4830e446d..9a72da8a4 100755
--- a/src/main/java/forestry/apiculture/gui/ContainerImprinter.java
+++ b/src/main/java/forestry/apiculture/gui/ContainerImprinter.java
@@ -10,17 +10,15 @@
******************************************************************************/
package forestry.apiculture.gui;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.entity.player.InventoryPlayer;
-
import forestry.apiculture.inventory.ItemInventoryImprinter;
import forestry.apiculture.network.packets.PacketImprintSelectionResponse;
import forestry.core.gui.ContainerItemInventory;
import forestry.core.gui.IGuiSelectable;
import forestry.core.gui.slots.SlotFiltered;
import forestry.core.gui.slots.SlotOutput;
-import forestry.core.network.packets.PacketGuiSelectRequest;
import forestry.core.proxy.Proxies;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.InventoryPlayer;
public class ContainerImprinter extends ContainerItemInventory implements IGuiSelectable {
@@ -34,15 +32,15 @@ public class ContainerImprinter extends ContainerItemInventory {
private static final LinkedListMultimap habitats = LinkedListMultimap.create();
@@ -89,9 +84,10 @@ public class GuiHabitatLocator extends GuiForestry activeBiomeTypes = EnumSet.noneOf(BiomeDictionary.Type.class);
+ Set activeBiomeTypes = new HashSet<>();
for (Biome biome : inventory.getBiomesToSearch()) {
- Collections.addAll(activeBiomeTypes, BiomeDictionary.getTypesForBiome(biome));
+ Set biomeTypes = BiomeDictionary.getTypes(biome);
+ activeBiomeTypes.addAll(biomeTypes);
}
for (HabitatSlot habitatSlot : habitatSlots) {
diff --git a/src/main/java/forestry/apiculture/gui/GuiImprinter.java b/src/main/java/forestry/apiculture/gui/GuiImprinter.java
index 07074a10f..fc12d1630 100755
--- a/src/main/java/forestry/apiculture/gui/GuiImprinter.java
+++ b/src/main/java/forestry/apiculture/gui/GuiImprinter.java
@@ -11,14 +11,9 @@
package forestry.apiculture.gui;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.item.ItemStack;
-
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.genetics.BeeGenome;
@@ -30,6 +25,9 @@ import forestry.core.network.packets.PacketGuiSelectRequest;
import forestry.core.proxy.Proxies;
import forestry.core.render.ColourProperties;
import forestry.core.utils.Translator;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
public class GuiImprinter extends GuiForestry {
@@ -44,7 +42,7 @@ public class GuiImprinter extends GuiForestry beeList = new ArrayList<>();
+ NonNullList beeList = NonNullList.create();
PluginApiculture.items.beeDroneGE.addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList) {
IAlleleBeeSpecies species = BeeGenome.getSpecies(beeStack);
diff --git a/src/main/java/forestry/apiculture/gui/widgets/HabitatSlot.java b/src/main/java/forestry/apiculture/gui/HabitatSlot.java
similarity index 74%
rename from src/main/java/forestry/apiculture/gui/widgets/HabitatSlot.java
rename to src/main/java/forestry/apiculture/gui/HabitatSlot.java
index b99854873..45c67430f 100644
--- a/src/main/java/forestry/apiculture/gui/widgets/HabitatSlot.java
+++ b/src/main/java/forestry/apiculture/gui/HabitatSlot.java
@@ -1,75 +1,68 @@
-/*******************************************************************************
- * Copyright (c) 2011-2014 SirSengir.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser Public License v3
- * which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl-3.0.txt
- *
- * Various Contributors including, but not limited to:
- * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
- ******************************************************************************/
-package forestry.apiculture.gui.widgets;
-
-import javax.annotation.Nonnull;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Locale;
-
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.texture.TextureAtlasSprite;
-import net.minecraftforge.common.BiomeDictionary;
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
-import forestry.core.gui.tooltips.ToolTip;
-import forestry.core.gui.widgets.Widget;
-import forestry.core.gui.widgets.WidgetManager;
-import forestry.core.proxy.Proxies;
-import forestry.core.render.TextureManager;
-
-public class HabitatSlot extends Widget {
- @Nonnull
- private final Collection biomes;
- @Nonnull
- private final String name;
- @Nonnull
- private final String iconIndex;
- public boolean isActive = false;
-
- public HabitatSlot(@Nonnull WidgetManager widgetManager, int xPos, int yPos, @Nonnull String name, @Nonnull Collection biomes) {
- super(widgetManager, xPos, yPos);
- this.biomes = biomes;
- this.name = name;
- this.iconIndex = "habitats/" + name.toLowerCase(Locale.ENGLISH);
- }
-
- @Override
- public ToolTip getToolTip(int mouseX, int mouseY) {
- ToolTip tooltip = new ToolTip();
- tooltip.add(name);
- return tooltip;
- }
-
- @SideOnly(Side.CLIENT)
- public TextureAtlasSprite getIcon() {
- return TextureManager.getInstance().getDefault(iconIndex);
- }
-
- public void setActive(Collection biomes) {
- isActive = !Collections.disjoint(this.biomes, biomes);
- }
-
- @Override
- public void draw(int startX, int startY) {
- if (getIcon() != null) {
- if (!isActive) {
- GlStateManager.color(0.2f, 0.2f, 0.2f, 0.2f);
- } else {
- GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
- }
-
- Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap());
- manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, getIcon(), 16, 16);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011-2014 SirSengir.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser Public License v3
+ * which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl-3.0.txt
+ *
+ * Various Contributors including, but not limited to:
+ * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
+ ******************************************************************************/
+package forestry.apiculture.gui;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+
+import forestry.core.gui.tooltips.ToolTip;
+import forestry.core.gui.widgets.Widget;
+import forestry.core.gui.widgets.WidgetManager;
+import forestry.core.proxy.Proxies;
+import forestry.core.render.TextureManager;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.texture.TextureAtlasSprite;
+import net.minecraftforge.common.BiomeDictionary;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+
+public class HabitatSlot extends Widget {
+ private final Collection biomes;
+ private final String name;
+ private final String iconIndex;
+ public boolean isActive = false;
+
+ public HabitatSlot(WidgetManager widgetManager, int xPos, int yPos, String name, Collection biomes) {
+ super(widgetManager, xPos, yPos);
+ this.biomes = biomes;
+ this.name = name;
+ this.iconIndex = "habitats/" + name.toLowerCase(Locale.ENGLISH);
+ }
+
+ @Override
+ public ToolTip getToolTip(int mouseX, int mouseY) {
+ ToolTip tooltip = new ToolTip();
+ tooltip.add(name);
+ return tooltip;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public TextureAtlasSprite getIcon() {
+ return TextureManager.getInstance().getDefault(iconIndex);
+ }
+
+ public void setActive(Collection biomes) {
+ isActive = !Collections.disjoint(this.biomes, biomes);
+ }
+
+ @Override
+ public void draw(int startX, int startY) {
+ if (!isActive) {
+ GlStateManager.color(0.2f, 0.2f, 0.2f, 0.2f);
+ } else {
+ GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
+ }
+
+ Proxies.render.bindTexture(TextureManager.getInstance().getGuiTextureMap());
+ manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, getIcon(), 16, 16);
+ }
+}
diff --git a/src/main/java/forestry/apiculture/gui/package-info.java b/src/main/java/forestry/apiculture/gui/package-info.java
new file mode 100644
index 000000000..38cb8cb61
--- /dev/null
+++ b/src/main/java/forestry/apiculture/gui/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.gui;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/inventory/InventoryAlvearySieve.java b/src/main/java/forestry/apiculture/inventory/InventoryAlvearySieve.java
index 7eb40d1de..74e048c73 100644
--- a/src/main/java/forestry/apiculture/inventory/InventoryAlvearySieve.java
+++ b/src/main/java/forestry/apiculture/inventory/InventoryAlvearySieve.java
@@ -34,12 +34,12 @@ public class InventoryAlvearySieve extends InventoryAdapterTile getBiomesToSearch() {
@@ -98,7 +93,7 @@ public class ItemInventoryHabitatLocator extends ItemInventory implements IError
/* IErrorSource */
@Override
public ImmutableSet getErrorStates() {
- if (getStackInSlot(SLOT_ANALYZED) != null) {
+ if (!getStackInSlot(SLOT_ANALYZED).isEmpty()) {
return ImmutableSet.of();
}
diff --git a/src/main/java/forestry/apiculture/inventory/ItemInventoryImprinter.java b/src/main/java/forestry/apiculture/inventory/ItemInventoryImprinter.java
index 4bfa289c9..1af4e5903 100644
--- a/src/main/java/forestry/apiculture/inventory/ItemInventoryImprinter.java
+++ b/src/main/java/forestry/apiculture/inventory/ItemInventoryImprinter.java
@@ -10,15 +10,20 @@
******************************************************************************/
package forestry.apiculture.inventory;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
+import java.util.List;
+import java.util.Map;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
+import forestry.api.apiculture.IBeeGenome;
+import forestry.api.apiculture.IBeeRoot;
+import forestry.api.genetics.IAllele;
import forestry.apiculture.genetics.Bee;
import forestry.core.inventory.ItemInventory;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
public class ItemInventoryImprinter extends ItemInventory {
private static final short specimenSlot = 0;
@@ -72,9 +77,13 @@ public class ItemInventoryImprinter extends ItemInventory {
}
public IBee getSelectedBee() {
- return new Bee(BeeManager.beeRoot.templateAsGenome(
- BeeManager.beeRoot.getGenomeTemplates().get(BeeManager.beeRoot.getIndividualTemplates().get(primaryIndex).getIdent()),
- BeeManager.beeRoot.getGenomeTemplates().get(BeeManager.beeRoot.getIndividualTemplates().get(secondaryIndex).getIdent())));
+ IBeeRoot beeRoot = BeeManager.beeRoot;
+ List individualTemplates = beeRoot.getIndividualTemplates();
+ Map genomeTemplates = beeRoot.getGenomeTemplates();
+ IAllele[] templateActive = genomeTemplates.get(individualTemplates.get(primaryIndex).getIdent());
+ IAllele[] templateInactive = genomeTemplates.get(individualTemplates.get(secondaryIndex).getIdent());
+ IBeeGenome genome = beeRoot.templateAsGenome(templateActive, templateInactive);
+ return new Bee(genome);
}
public int getPrimaryIndex() {
@@ -96,7 +105,7 @@ public class ItemInventoryImprinter extends ItemInventory {
@Override
public void onSlotClick(int slotIndex, EntityPlayer player) {
ItemStack specimen = getStackInSlot(specimenSlot);
- if (specimen == null) {
+ if (specimen.isEmpty()) {
return;
}
@@ -106,21 +115,18 @@ public class ItemInventoryImprinter extends ItemInventory {
}
// Needs space
- if (getStackInSlot(imprintedSlot) != null) {
+ if (!getStackInSlot(imprintedSlot).isEmpty()) {
return;
}
IBee imprint = getSelectedBee();
- if (imprint == null) {
- return;
- }
NBTTagCompound nbttagcompound = new NBTTagCompound();
imprint.writeToNBT(nbttagcompound);
specimen.setTagCompound(nbttagcompound);
setInventorySlotContents(imprintedSlot, specimen);
- setInventorySlotContents(specimenSlot, null);
+ setInventorySlotContents(specimenSlot, ItemStack.EMPTY);
}
@Override
diff --git a/src/main/java/forestry/apiculture/inventory/package-info.java b/src/main/java/forestry/apiculture/inventory/package-info.java
new file mode 100644
index 000000000..472adccc4
--- /dev/null
+++ b/src/main/java/forestry/apiculture/inventory/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.inventory;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java b/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java
index 61e754ce4..2a2359d5e 100644
--- a/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java
+++ b/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java
@@ -10,24 +10,22 @@
******************************************************************************/
package forestry.apiculture.items;
+import javax.annotation.Nullable;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import forestry.api.apiculture.IBee;
+import forestry.apiculture.network.packets.PacketHabitatBiomePointer;
+import forestry.core.proxy.Proxies;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
-
import net.minecraftforge.common.BiomeDictionary;
-import forestry.api.apiculture.IBee;
-import forestry.apiculture.network.packets.PacketHabitatBiomePointer;
-import forestry.core.proxy.Proxies;
-
public class HabitatLocatorLogic {
private static final int maxChecksPerTick = 100;
private static final int maxSearchRadiusIterations = 500;
@@ -39,19 +37,20 @@ public class HabitatLocatorLogic {
private static final Set endBiomes = new HashSet<>();
static {
- Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.BEACH));
- Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.OCEAN));
- Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.RIVER));
+ waterBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.BEACH));
+ waterBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.OCEAN));
+ waterBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.RIVER));
- Collections.addAll(netherBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.NETHER));
+ netherBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.NETHER));
- Collections.addAll(endBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.END));
+ endBiomes.addAll(BiomeDictionary.getBiomes(BiomeDictionary.Type.END));
}
private Set targetBiomes = new HashSet<>();
private boolean biomeFound = false;
private int searchRadiusIteration = 0;
private int searchAngleIteration = 0;
+ @Nullable
private BlockPos searchCenter;
public boolean isBiomeFound() {
@@ -69,7 +68,7 @@ public class HabitatLocatorLogic {
this.biomeFound = false;
this.searchCenter = player.getPosition();
- Biome currentBiome = player.worldObj.getBiome(searchCenter);
+ Biome currentBiome = player.world.getBiome(searchCenter);
removeInvalidBiomes(currentBiome, targetBiomes);
// reset the locator coordinates
@@ -99,11 +98,16 @@ public class HabitatLocatorLogic {
}
}
+ @Nullable
private BlockPos findNearestBiome(Entity player, Collection biomesToSearch) {
+ if (searchCenter == null) {
+ return null;
+ }
+
BlockPos playerPos = player.getPosition();
// If we are in a valid spot, we point to ourselves.
- BlockPos coordinates = getChunkCoordinates(playerPos, player.worldObj, biomesToSearch);
+ BlockPos coordinates = getChunkCoordinates(playerPos, player.world, biomesToSearch);
if (coordinates != null) {
searchAngleIteration = 0;
searchRadiusIteration = 0;
@@ -139,7 +143,7 @@ public class HabitatLocatorLogic {
int zOffset = Math.round((float) (radius * Math.sin(angle)));
BlockPos pos = searchCenter.add(xOffset, 0, zOffset);
- coordinates = getChunkCoordinates(pos, player.worldObj, biomesToSearch);
+ coordinates = getChunkCoordinates(pos, player.world, biomesToSearch);
if (coordinates != null) {
searchAngleIteration = 0;
searchRadiusIteration = 0;
@@ -150,6 +154,7 @@ public class HabitatLocatorLogic {
return null;
}
+ @Nullable
private static BlockPos getChunkCoordinates(BlockPos pos, World world, Collection biomesToSearch) {
Biome biome;
@@ -185,13 +190,13 @@ public class HabitatLocatorLogic {
biomesToSearch.removeAll(waterBiomes);
- if (BiomeDictionary.isBiomeOfType(currentBiome, BiomeDictionary.Type.NETHER)) {
+ if (BiomeDictionary.hasType(currentBiome, BiomeDictionary.Type.NETHER)) {
biomesToSearch.retainAll(netherBiomes);
} else {
biomesToSearch.removeAll(netherBiomes);
}
- if (BiomeDictionary.isBiomeOfType(currentBiome, BiomeDictionary.Type.END)) {
+ if (BiomeDictionary.hasType(currentBiome, BiomeDictionary.Type.END)) {
biomesToSearch.retainAll(endBiomes);
} else {
biomesToSearch.removeAll(endBiomes);
diff --git a/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java b/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java
index 6817f72eb..0b6cbaba1 100755
--- a/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java
+++ b/src/main/java/forestry/apiculture/items/ItemArmorApiarist.java
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture.items;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import forestry.api.apiculture.ApicultureCapabilities;
@@ -60,9 +59,9 @@ public class ItemArmorApiarist extends ItemArmor implements IItemModelRegister {
return false;
}
- @Nonnull
@Override
- public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
+ @Nullable
+ public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
return new ICapabilityProvider() {
@Override
public boolean hasCapability(Capability> capability, @Nullable EnumFacing facing) {
diff --git a/src/main/java/forestry/apiculture/items/ItemBeeGE.java b/src/main/java/forestry/apiculture/items/ItemBeeGE.java
index 8d5f04026..f546ef75c 100755
--- a/src/main/java/forestry/apiculture/items/ItemBeeGE.java
+++ b/src/main/java/forestry/apiculture/items/ItemBeeGE.java
@@ -12,19 +12,7 @@ package forestry.apiculture.items;
import java.util.List;
-import net.minecraft.client.renderer.ItemMeshDefinition;
-import net.minecraft.client.renderer.block.model.ModelResourceLocation;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.text.TextFormatting;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
import forestry.api.apiculture.BeeManager;
-import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
@@ -38,6 +26,16 @@ import forestry.core.config.Config;
import forestry.core.genetics.ItemGE;
import forestry.core.items.IColoredItem;
import forestry.core.utils.Translator;
+import net.minecraft.client.renderer.ItemMeshDefinition;
+import net.minecraft.client.renderer.block.model.ModelResourceLocation;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
+import net.minecraft.util.text.TextFormatting;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemBeeGE extends ItemGE implements IColoredItem {
@@ -63,7 +61,6 @@ public class ItemBeeGE extends ItemGE implements IColoredItem {
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
-
if (itemstack.getTagCompound() == null) {
return super.getItemStackDisplayName(itemstack);
}
@@ -81,7 +78,7 @@ public class ItemBeeGE extends ItemGE implements IColoredItem {
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
- if (!itemstack.hasTagCompound()) {
+ if (itemstack.getTagCompound() == null) {
return;
}
@@ -98,11 +95,11 @@ public class ItemBeeGE extends ItemGE implements IColoredItem {
}
@Override
- public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
- addCreativeItems(itemList, true);
+ public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems) {
+ addCreativeItems(subItems, true);
}
- public void addCreativeItems(List itemList, boolean hideSecrets) {
+ public void addCreativeItems(NonNullList subItems, boolean hideSecrets) {
for (IBee bee : BeeManager.beeRoot.getIndividualTemplates()) {
// Don't show secret bees unless ordered to.
if (hideSecrets && bee.isSecret() && !Config.isDebug) {
@@ -110,15 +107,15 @@ public class ItemBeeGE extends ItemGE implements IColoredItem {
}
ItemStack beeStack = BeeManager.beeRoot.getMemberStack(bee, type);
- if (beeStack != null) {
- itemList.add(beeStack);
+ if (!beeStack.isEmpty()) {
+ subItems.add(beeStack);
}
}
}
@Override
public int getColorFromItemstack(ItemStack itemstack, int tintIndex) {
- if (!itemstack.hasTagCompound()) {
+ if (itemstack.getTagCompound() == null) {
if (tintIndex == 1) {
return 0xffdc16;
} else {
@@ -127,26 +124,10 @@ public class ItemBeeGE extends ItemGE implements IColoredItem {
}
IAlleleBeeSpecies species = BeeGenome.getSpecies(itemstack);
- if (species instanceof IAlleleBeeSpecies) {
- return species.getSpriteColour(tintIndex);
- } else {
- return 0xffffff;
- }
+ return species.getSpriteColour(tintIndex);
}
/* MODELS */
- @SideOnly(Side.CLIENT)
- @Override
- public int getColourFromSpecies(IAlleleSpecies species, int renderPass) {
-
- if (species instanceof IAlleleBeeSpecies) {
- return species.getSpriteColour(renderPass);
- } else {
- return 0xffffff;
- }
-
- }
-
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
@@ -159,16 +140,11 @@ public class ItemBeeGE extends ItemGE implements IColoredItem {
}
private class BeeMeshDefinition implements ItemMeshDefinition {
-
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
IAlleleBeeSpecies species = (IAlleleBeeSpecies) getSpecies(stack);
- if (species == null) {
- species = (IAlleleBeeSpecies) BeeManager.beeRoot.getDefaultTemplate()[EnumBeeChromosome.SPECIES.ordinal()];
- }
return species.getModel(type);
}
-
}
public final EnumBeeType getType() {
diff --git a/src/main/java/forestry/apiculture/items/ItemBlockCandle.java b/src/main/java/forestry/apiculture/items/ItemBlockCandle.java
index f178c8fa6..e50a16d16 100644
--- a/src/main/java/forestry/apiculture/items/ItemBlockCandle.java
+++ b/src/main/java/forestry/apiculture/items/ItemBlockCandle.java
@@ -31,7 +31,7 @@ public class ItemBlockCandle extends ItemBlockForestry implements I
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack stack, int pass) {
int value = 0xffffff;
- if (pass == 1 && stack.hasTagCompound()) {
+ if (pass == 1 && stack.getTagCompound() != null) {
NBTTagCompound tag = stack.getTagCompound();
if (tag.hasKey(BlockCandle.colourTagName)) {
value = tag.getInteger(BlockCandle.colourTagName);
@@ -43,7 +43,7 @@ public class ItemBlockCandle extends ItemBlockForestry implements I
@Override
public String getUnlocalizedName(ItemStack itemStack) {
String value = getBlock().getUnlocalizedName();
- if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(BlockCandle.colourTagName)) {
+ if (itemStack.getTagCompound() != null && itemStack.getTagCompound().hasKey(BlockCandle.colourTagName)) {
value = value + ".dyed";
}
diff --git a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java
index aeddbe33f..6f084c671 100644
--- a/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java
+++ b/src/main/java/forestry/apiculture/items/ItemHabitatLocator.java
@@ -62,18 +62,18 @@ public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister {
@SideOnly(Side.CLIENT)
public void registerSprites(ITextureManager manager) {
TextureAtlasSprite texture = new TextureHabitatLocator(iconName);
- Minecraft.getMinecraft().getTextureMapBlocks().setTextureEntry(iconName, texture);
+ Minecraft.getMinecraft().getTextureMapBlocks().setTextureEntry(texture);
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
super.addInformation(itemstack, player, list, flag);
- Biome currentBiome = player.worldObj.getBiome(player.getPosition());
+ Biome currentBiome = player.world.getBiome(player.getPosition());
- float temperatureValue = ForestryAPI.climateManager.getTemperature(player.worldObj, player.getPosition());
+ float temperatureValue = ForestryAPI.climateManager.getTemperature(player.world, player.getPosition());
EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
- EnumHumidity humidity = EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(player.worldObj, player.getPosition()));
+ EnumHumidity humidity = EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(player.world, player.getPosition()));
list.add(Translator.translateToLocal("for.gui.currentBiome") + ": " + currentBiome.getBiomeName());
list.add(Translator.translateToLocal("for.gui.temperature") + ": " + AlleleManager.climateHelper.toDisplay(temperature));
diff --git a/src/main/java/forestry/apiculture/items/ItemHiveFrame.java b/src/main/java/forestry/apiculture/items/ItemHiveFrame.java
index f4ff25ca0..984d33fcf 100755
--- a/src/main/java/forestry/apiculture/items/ItemHiveFrame.java
+++ b/src/main/java/forestry/apiculture/items/ItemHiveFrame.java
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.items;
+import javax.annotation.Nullable;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
@@ -38,6 +39,7 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
}
@Override
+ @Nullable
public ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear) {
frame.setItemDamage(frame.getItemDamage() + wear);
if (frame.getItemDamage() >= frame.getMaxDamage()) {
diff --git a/src/main/java/forestry/apiculture/items/ItemHoneyComb.java b/src/main/java/forestry/apiculture/items/ItemHoneyComb.java
index 5d9e161a9..bfa2105d9 100755
--- a/src/main/java/forestry/apiculture/items/ItemHoneyComb.java
+++ b/src/main/java/forestry/apiculture/items/ItemHoneyComb.java
@@ -10,22 +10,22 @@
******************************************************************************/
package forestry.apiculture.items;
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
-import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-
-import net.minecraftforge.fml.relauncher.Side;
-import net.minecraftforge.fml.relauncher.SideOnly;
-
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.core.config.Config;
import forestry.core.items.IColoredItem;
import forestry.core.items.ItemForestry;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemHoneyComb extends ItemForestry implements IColoredItem {
public ItemHoneyComb() {
@@ -51,7 +51,7 @@ public class ItemHoneyComb extends ItemForestry implements IColoredItem {
manager.registerItemModel(item, i, "beecombs/" + EnumHoneyComb.VALUES[i].name);
}
}
-
+
@Override
public String getUnlocalizedName(ItemStack stack) {
EnumHoneyComb honeyComb = EnumHoneyComb.VALUES[stack.getItemDamage()];
@@ -59,15 +59,16 @@ public class ItemHoneyComb extends ItemForestry implements IColoredItem {
}
@Override
- public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
+ public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems) {
for (int i = 0; i < EnumHoneyComb.VALUES.length; i++) {
EnumHoneyComb honeyComb = EnumHoneyComb.VALUES[i];
if (!honeyComb.isSecret() || Config.isDebug) {
- itemList.add(new ItemStack(this, 1, i));
+ subItems.add(new ItemStack(this, 1, i));
}
}
}
+ @Nullable
private static EnumHoneyComb getRandomCombType(Random random, boolean includeSecret) {
List validCombs = new ArrayList<>(EnumHoneyComb.VALUES.length);
for (int i = 0; i < EnumHoneyComb.VALUES.length; i++) {
@@ -86,6 +87,9 @@ public class ItemHoneyComb extends ItemForestry implements IColoredItem {
public ItemStack getRandomComb(int amount, Random random, boolean includeSecret) {
EnumHoneyComb honeyComb = getRandomCombType(random, includeSecret);
+ if (honeyComb == null) {
+ return ItemStack.EMPTY;
+ }
return get(honeyComb, amount);
}
diff --git a/src/main/java/forestry/apiculture/items/ItemMinecartBeehouse.java b/src/main/java/forestry/apiculture/items/ItemMinecartBeehouse.java
index a46564a38..393eda088 100644
--- a/src/main/java/forestry/apiculture/items/ItemMinecartBeehouse.java
+++ b/src/main/java/forestry/apiculture/items/ItemMinecartBeehouse.java
@@ -10,13 +10,16 @@
******************************************************************************/
package forestry.apiculture.items;
-import java.util.List;
-
+import forestry.api.core.IItemModelRegister;
+import forestry.api.core.IModelManager;
+import forestry.apiculture.entities.EntityMinecartApiary;
+import forestry.apiculture.entities.EntityMinecartBeeHousingBase;
+import forestry.apiculture.entities.EntityMinecartBeehouse;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockRailBase;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.IBehaviorDispenseItem;
-import net.minecraft.dispenser.IBlockSource;
+import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMinecart;
@@ -24,59 +27,51 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
+import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
-
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-import forestry.api.core.IItemModelRegister;
-import forestry.api.core.IModelManager;
-import forestry.apiculture.entities.EntityMinecartApiary;
-import forestry.apiculture.entities.EntityMinecartBeeHousingBase;
-import forestry.apiculture.entities.EntityMinecartBeehouse;
-
public class ItemMinecartBeehouse extends ItemMinecart implements IItemModelRegister {
private final String[] definition = new String[]{"cart.beehouse", "cart.apiary"};
-
- private static final IBehaviorDispenseItem dispenserMinecartBehavior = new IBehaviorDispenseItem() {
- @Override
- public ItemStack dispense(IBlockSource source, ItemStack stack) {
- return stack;
- }
- };
+
+ private static final IBehaviorDispenseItem dispenserMinecartBehavior = (source, stack) -> stack;
public ItemMinecartBeehouse() {
- super(null);
+ super(EntityMinecart.Type.CHEST);
setMaxDamage(0);
setHasSubtypes(true);
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, dispenserMinecartBehavior);
}
@Override
- public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
+ public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!BlockRailBase.isRailBlock(worldIn.getBlockState(pos))) {
return EnumActionResult.PASS;
}
+ ItemStack stack = player.getHeldItem(hand);
+
if (!worldIn.isRemote) {
EntityMinecartBeeHousingBase entityMinecart;
+
if (stack.getItemDamage() == 0) {
entityMinecart = new EntityMinecartBeehouse(worldIn, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F);
} else {
entityMinecart = new EntityMinecartApiary(worldIn, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F);
}
- entityMinecart.getOwnerHandler().setOwner(playerIn.getGameProfile());
+ entityMinecart.getOwnerHandler().setOwner(player.getGameProfile());
if (stack.hasDisplayName()) {
entityMinecart.setCustomNameTag(stack.getDisplayName());
}
- worldIn.spawnEntityInWorld(entityMinecart);
+ worldIn.spawnEntity(entityMinecart);
}
- --stack.stackSize;
+ stack.shrink(1);
return EnumActionResult.SUCCESS;
}
@@ -99,9 +94,9 @@ public class ItemMinecartBeehouse extends ItemMinecart implements IItemModelRegi
}
@Override
- public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
+ public void getSubItems(Item item, CreativeTabs tab, NonNullList subItems) {
for (int i = 0; i < definition.length; i++) {
- itemList.add(new ItemStack(this, 1, i));
+ subItems.add(new ItemStack(this, 1, i));
}
}
diff --git a/src/main/java/forestry/apiculture/items/ItemSmoker.java b/src/main/java/forestry/apiculture/items/ItemSmoker.java
index e1b233bca..8217e0621 100644
--- a/src/main/java/forestry/apiculture/items/ItemSmoker.java
+++ b/src/main/java/forestry/apiculture/items/ItemSmoker.java
@@ -1,6 +1,5 @@
package forestry.apiculture.items;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import forestry.api.apiculture.ApicultureCapabilities;
@@ -42,8 +41,8 @@ public class ItemSmoker extends ItemForestry {
@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {
super.onUsingTick(stack, player, count);
- World worldObj = player.worldObj;
- addSmoke(stack, worldObj, player, (count % 5) + 1);
+ World world = player.world;
+ addSmoke(stack, world, player, (count % 5) + 1);
}
private static EnumHandSide getHandSide(ItemStack stack, Entity entity) {
@@ -60,7 +59,7 @@ public class ItemSmoker extends ItemForestry {
return EnumHandSide.RIGHT;
}
- private static void addSmoke(ItemStack stack, World worldObj, Entity entity, int distance) {
+ private static void addSmoke(ItemStack stack, World world, Entity entity, int distance) {
if (distance <= 0) {
return;
}
@@ -78,9 +77,9 @@ public class ItemSmoker extends ItemForestry {
Vec3d scaledOffset = handOffset.scale(1.0 / distance);
Vec3d smokePos = lookDistance.add(entity.getPositionVector()).add(scaledOffset);
- Proxies.render.addEntitySmokeFX(worldObj, smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord);
+ Proxies.render.addEntitySmokeFX(world, smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord);
BlockPos blockPos = new BlockPos(smokePos.xCoord, smokePos.yCoord + 1, smokePos.zCoord);
- TileEntity tileEntity = worldObj.getTileEntity(blockPos);
+ TileEntity tileEntity = world.getTileEntity(blockPos);
if (tileEntity instanceof IHiveTile) {
IHiveTile hive = (IHiveTile) tileEntity;
hive.calmBees();
@@ -88,19 +87,20 @@ public class ItemSmoker extends ItemForestry {
}
@Override
- public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
- playerIn.setActiveHand(hand);
- return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
+ public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
+ playerIn.setActiveHand(handIn);
+ ItemStack itemStack = playerIn.getHeldItem(handIn);
+ return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
@Override
- public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
+ public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof IHiveTile) {
IHiveTile hive = (IHiveTile) tileEntity;
hive.calmBees();
}
- return super.onItemUseFirst(stack, player, world, pos, side, hitX, hitY, hitZ, hand);
+ return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand);
}
@Override
@@ -108,9 +108,8 @@ public class ItemSmoker extends ItemForestry {
return 32;
}
- @Nonnull
@Override
- public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
+ public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
return new ICapabilityProvider() {
@Override
public boolean hasCapability(Capability> capability, @Nullable EnumFacing facing) {
diff --git a/src/main/java/forestry/apiculture/items/ItemWaxCast.java b/src/main/java/forestry/apiculture/items/ItemWaxCast.java
index 8a5f4ea9e..44906bafc 100755
--- a/src/main/java/forestry/apiculture/items/ItemWaxCast.java
+++ b/src/main/java/forestry/apiculture/items/ItemWaxCast.java
@@ -10,11 +10,10 @@
******************************************************************************/
package forestry.apiculture.items;
-import net.minecraft.item.ItemStack;
-
import forestry.api.core.Tabs;
import forestry.core.items.ICraftingPlan;
import forestry.core.items.ItemForestry;
+import net.minecraft.item.ItemStack;
public class ItemWaxCast extends ItemForestry implements ICraftingPlan {
@@ -27,12 +26,8 @@ public class ItemWaxCast extends ItemForestry implements ICraftingPlan {
@Override
public ItemStack planUsed(ItemStack plan, ItemStack result) {
- plan.setItemDamage(plan.getItemDamage() + result.stackSize);
- if (plan.getItemDamage() >= plan.getMaxDamage()) {
- return null;
- } else {
- return plan;
- }
+ plan.setItemDamage(plan.getItemDamage() + result.getCount());
+ return plan;
}
}
diff --git a/src/main/java/forestry/apiculture/items/package-info.java b/src/main/java/forestry/apiculture/items/package-info.java
new file mode 100644
index 000000000..21da7cdb5
--- /dev/null
+++ b/src/main/java/forestry/apiculture/items/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.items;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java
index d71863db5..539cec0c0 100644
--- a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java
+++ b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture.multiblock;
-import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
@@ -36,8 +35,7 @@ import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.IMultiblockControllerInternal;
import forestry.core.multiblock.MultiblockValidationException;
import forestry.core.multiblock.RectangularMultiblockControllerBase;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
+import forestry.core.network.PacketBufferForestry;
import forestry.core.proxy.Proxies;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ClimateUtil;
@@ -51,8 +49,6 @@ import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public class AlvearyController extends RectangularMultiblockControllerBase implements IAlvearyControllerInternal, IClimateControlled {
-
- @Nonnull
private final InventoryBeeHousing inventory;
private final IBeekeepingLogic beekeepingLogic;
@@ -76,7 +72,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
this.beeModifiers.add(new AlvearyBeeModifier());
}
- @Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
@@ -87,7 +82,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
return beekeepingLogic;
}
- @Nonnull
@Override
public IInventoryAdapter getInternalInventory() {
if (isAssembled()) {
@@ -175,9 +169,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
for (int slabX = minimumCoord.getX(); slabX <= maximumCoord.getX(); slabX++) {
for (int slabZ = minimumCoord.getZ(); slabZ <= maximumCoord.getZ(); slabZ++) {
BlockPos pos = new BlockPos(slabX, slabY, slabZ);
- IBlockState state = worldObj.getBlockState(pos);
+ IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
- if (!BlockUtil.isWoodSlabBlock(state, block, worldObj, pos)) {
+ if (!BlockUtil.isWoodSlabBlock(state, block, world, pos)) {
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSlabs"));
}
@@ -196,9 +190,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
if (isCoordInMultiblock(airX, airY, airZ)) {
continue;
}
- IBlockState blockState = worldObj.getBlockState(new BlockPos(airX, airY, airZ));
- Block block = blockState.getBlock();
- if (block.isOpaqueCube(blockState)) {
+ IBlockState blockState = world.getBlockState(new BlockPos(airX, airY, airZ));
+ if (blockState.isOpaqueCube()) {
throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSpace"));
}
}
@@ -278,15 +271,15 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
float fxZ = center.getZ() + 0.5F;
float distanceFromCenter = 1.6F;
- float leftRightSpreadFromCenter = distanceFromCenter * (worldObj.rand.nextFloat() - 0.5F);
- float upSpread = worldObj.rand.nextFloat() * 0.8F;
+ float leftRightSpreadFromCenter = distanceFromCenter * (world.rand.nextFloat() - 0.5F);
+ float upSpread = world.rand.nextFloat() * 0.8F;
fxY += upSpread;
// display fx on all 4 sides
- Proxies.render.addEntityHoneyDustFX(worldObj, fxX - distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter);
- Proxies.render.addEntityHoneyDustFX(worldObj, fxX + distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter);
- Proxies.render.addEntityHoneyDustFX(worldObj, fxX + leftRightSpreadFromCenter, fxY, fxZ - distanceFromCenter);
- Proxies.render.addEntityHoneyDustFX(worldObj, fxX + leftRightSpreadFromCenter, fxY, fxZ + distanceFromCenter);
+ Proxies.render.addEntityHoneyDustFX(world, fxX - distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter);
+ Proxies.render.addEntityHoneyDustFX(world, fxX + distanceFromCenter, fxY, fxZ + leftRightSpreadFromCenter);
+ Proxies.render.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ - distanceFromCenter);
+ Proxies.render.addEntityHoneyDustFX(world, fxX + leftRightSpreadFromCenter, fxY, fxZ + distanceFromCenter);
}
}
}
@@ -383,30 +376,30 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public Biome getBiome() {
BlockPos coords = getReferenceCoord();
- return worldObj.getBiome(coords);
+ return world.getBiome(coords);
}
@Override
public int getBlockLightValue() {
BlockPos topCenter = getTopCenterCoord();
- return worldObj.getLightFromNeighbors(topCenter.up());
+ return world.getLightFromNeighbors(topCenter.up());
}
@Override
public boolean canBlockSeeTheSky() {
BlockPos topCenter = getTopCenterCoord();
- return worldObj.canBlockSeeSky(topCenter.add(0, 2, 0));
+ return world.canBlockSeeSky(topCenter.add(0, 2, 0));
}
-
+
@Override
public boolean isRaining() {
BlockPos topCenter = getTopCenterCoord();
- return worldObj.isRainingAt(topCenter.add(0, 2, 0));
+ return world.isRainingAt(topCenter.add(0, 2, 0));
}
@Override
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
- float temperature = ForestryAPI.climateManager.getTemperature(worldObj, getReferenceCoord());
+ float temperature = ForestryAPI.climateManager.getTemperature(world, getReferenceCoord());
tempChange += change;
tempChange = Math.max(boundaryDown - temperature, tempChange);
@@ -415,7 +408,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
- float humidity = ForestryAPI.climateManager.getHumidity(worldObj, getReferenceCoord());
+ float humidity = ForestryAPI.climateManager.getHumidity(world, getReferenceCoord());
humidChange += change;
humidChange = Math.max(boundaryDown - humidity, humidChange);
@@ -429,25 +422,24 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
}
@Override
- public void writeGuiData(DataOutputStreamForestry data) throws IOException {
+ public void writeGuiData(PacketBufferForestry data) {
data.writeVarInt(beekeepingLogic.getBeeProgressPercent());
data.writeVarInt(Math.round(tempChange * 100));
data.writeVarInt(Math.round(humidChange * 100));
- IClimatePosition position = ForestryAPI.climateManager.getPosition(worldObj, getReferenceCoord());
- if(position != null){
+ IClimatePosition position = ForestryAPI.climateManager.getPosition(world, getReferenceCoord());
+ if (position != null) {
ClimateUtil.writePositionData(position, data);
}
}
@Override
- public void readGuiData(DataInputStreamForestry data) throws IOException {
+ public void readGuiData(PacketBufferForestry data) throws IOException {
breedingProgressPercent = data.readVarInt();
tempChange = data.readVarInt() / 100.0F;
humidChange = data.readVarInt() / 100.0F;
- IClimatePosition position = ForestryAPI.climateManager.getPosition(worldObj, getReferenceCoord());
- if(position != null){
+ IClimatePosition position = ForestryAPI.climateManager.getPosition(world, getReferenceCoord());
+ if (position != null) {
ClimateUtil.readPositionData(position, data);
}
}
-
}
diff --git a/src/main/java/forestry/apiculture/multiblock/FakeAlvearyController.java b/src/main/java/forestry/apiculture/multiblock/FakeAlvearyController.java
index ed2010ca5..d42cb2027 100644
--- a/src/main/java/forestry/apiculture/multiblock/FakeAlvearyController.java
+++ b/src/main/java/forestry/apiculture/multiblock/FakeAlvearyController.java
@@ -10,15 +10,10 @@
******************************************************************************/
package forestry.apiculture.multiblock;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.Collections;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Vec3d;
-import net.minecraft.world.biome.Biome;
-
import com.mojang.authlib.GameProfile;
-
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
@@ -28,6 +23,10 @@ import forestry.apiculture.tiles.FakeBeeHousingInventory;
import forestry.core.inventory.FakeInventoryAdapter;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.FakeMultiblockController;
+import net.minecraft.init.Biomes;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Vec3d;
+import net.minecraft.world.biome.Biome;
public class FakeAlvearyController extends FakeMultiblockController implements IAlvearyControllerInternal {
public static final FakeAlvearyController instance = new FakeAlvearyController();
@@ -46,7 +45,6 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
return Collections.emptyList();
}
- @Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return FakeBeeHousingInventory.instance;
@@ -66,30 +64,31 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
public boolean canBlockSeeTheSky() {
return false;
}
-
+
@Override
public boolean isRaining() {
return false;
}
@Override
+ @Nullable
public GameProfile getOwner() {
return null;
}
@Override
public BlockPos getCoordinates() {
- return null;
+ return BlockPos.ORIGIN;
}
@Override
public Vec3d getBeeFXCoordinates() {
- return null;
+ return new Vec3d(0, 0, 0);
}
@Override
public Biome getBiome() {
- return null;
+ return Biomes.PLAINS;
}
@Override
diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlveary.java b/src/main/java/forestry/apiculture/multiblock/TileAlveary.java
index ecfac5556..dc98a4253 100644
--- a/src/main/java/forestry/apiculture/multiblock/TileAlveary.java
+++ b/src/main/java/forestry/apiculture/multiblock/TileAlveary.java
@@ -10,19 +10,9 @@
******************************************************************************/
package forestry.apiculture.multiblock;
-import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.List;
-import forestry.core.owner.IOwnedTile;
-import forestry.core.owner.IOwnerHandler;
-import net.minecraft.block.state.IBlockState;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.Vec3d;
-import net.minecraft.world.World;
-import net.minecraft.world.biome.Biome;
-
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
@@ -40,11 +30,18 @@ import forestry.core.config.Config;
import forestry.core.gui.IHintSource;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.MultiblockTileEntityForestry;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamableGui;
+import forestry.core.network.PacketBufferForestry;
+import forestry.core.owner.IOwnedTile;
+import forestry.core.owner.IOwnerHandler;
import forestry.core.tiles.IClimatised;
import forestry.core.tiles.ITitled;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Vec3d;
+import net.minecraft.world.World;
+import net.minecraft.world.biome.Biome;
public abstract class TileAlveary extends MultiblockTileEntityForestry implements IBeeHousing, IAlvearyComponent, IOwnedTile, IStreamableGui, ITitled, IClimatised, IHintSource {
private final String unlocalizedTitle;
@@ -61,10 +58,10 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry 0);
}
- @Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -115,28 +112,22 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
this.active = active;
- if (worldObj != null) {
- if (worldObj.isRemote) {
- worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
+ if (world != null) {
+ if (world.isRemote) {
+ world.markBlockRangeForRenderUpdate(getPos(), getPos());
} else {
- Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
+ Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), pos, world);
}
}
}
@Override
- public EnergyManager getEnergyManager() {
- return energyManager;
- }
-
- @Override
- public boolean hasCapability(@Nonnull Capability> capability, @Nullable EnumFacing facing) {
+ public boolean hasCapability( Capability> capability, @Nullable EnumFacing facing) {
return energyManager.hasCapability(capability) || super.hasCapability(capability, facing);
}
- @Nonnull
@Override
- public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) {
+ public T getCapability( Capability capability, @Nullable EnumFacing facing) {
T energyCapability = energyManager.getCapability(capability);
if (energyCapability != null) {
return energyCapability;
diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java
index 8bd597a86..7a27344ca 100644
--- a/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java
+++ b/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java
@@ -10,18 +10,8 @@
******************************************************************************/
package forestry.apiculture.multiblock;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.EnumFacing;
-
-import net.minecraftforge.common.capabilities.Capability;
-import net.minecraftforge.fluids.Fluid;
-import net.minecraftforge.fluids.FluidRegistry;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import forestry.api.climate.IClimateControlled;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.apiculture.blocks.BlockAlvearyType;
@@ -32,9 +22,18 @@ import forestry.core.config.Constants;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.Fluids;
import forestry.core.fluids.TankManager;
-import forestry.core.fluids.tanks.FilteredTank;
+import forestry.core.fluids.FilteredTank;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.tiles.ILiquidTankTile;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumFacing;
+import net.minecraftforge.common.capabilities.Capability;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankTile, IAlvearyComponent.Climatiser {
private final HygroregulatorRecipe[] recipes;
@@ -43,6 +42,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
private final FilteredTank liquidTank;
private final IInventoryAdapter inventory;
+ @Nullable
private HygroregulatorRecipe currentRecipe;
private int transferTime;
@@ -75,6 +75,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
/* UPDATING */
+ @Nullable
private HygroregulatorRecipe getRecipe(FluidStack liquid) {
HygroregulatorRecipe recipe = null;
for (HygroregulatorRecipe rec : recipes) {
@@ -88,12 +89,15 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
@Override
public void changeClimate(int tickCount, IClimateControlled climateControlled) {
- if (transferTime <= 0 && liquidTank.getFluidAmount() > 0) {
- currentRecipe = getRecipe(liquidTank.getFluid());
+ if (transferTime <= 0) {
+ FluidStack fluid = liquidTank.getFluid();
+ if (fluid != null && fluid.amount > 0) {
+ currentRecipe = getRecipe(fluid);
- if (currentRecipe != null) {
- liquidTank.drainInternal(currentRecipe.liquid.amount, true);
- transferTime = currentRecipe.transferTime;
+ if (currentRecipe != null) {
+ liquidTank.drainInternal(currentRecipe.liquid.amount, true);
+ transferTime = currentRecipe.transferTime;
+ }
}
}
@@ -128,7 +132,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
}
- @Nonnull
+
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -144,22 +148,21 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
}
/* ILIQUIDTANKCONTAINER */
- @Nonnull
+
@Override
public TankManager getTankManager() {
return tankManager;
}
@Override
- public boolean hasCapability(Capability> capability, EnumFacing facing) {
- if (super.hasCapability(capability, facing)) {
- return true;
- }
- return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
+ public boolean hasCapability(Capability> capability, @Nullable EnumFacing facing) {
+ return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY ||
+ super.hasCapability(capability, facing);
}
@Override
- public T getCapability(Capability capability, EnumFacing facing) {
+ @Nullable
+ public T getCapability(Capability capability, @Nullable EnumFacing facing) {
if (super.hasCapability(capability, facing)) {
return super.getCapability(capability, facing);
}
diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlvearySwarmer.java b/src/main/java/forestry/apiculture/multiblock/TileAlvearySwarmer.java
index 27cc3ae3b..6d295207f 100644
--- a/src/main/java/forestry/apiculture/multiblock/TileAlvearySwarmer.java
+++ b/src/main/java/forestry/apiculture/multiblock/TileAlvearySwarmer.java
@@ -10,16 +10,10 @@
******************************************************************************/
package forestry.apiculture.multiblock;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.Map.Entry;
import java.util.Stack;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.ISidedInventory;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
@@ -36,6 +30,11 @@ import forestry.core.inventory.IInventoryAdapter;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.IActivatable;
import forestry.core.utils.ItemStackUtil;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ISidedInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory, IActivatable, IAlvearyComponent.Active {
@@ -85,7 +84,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
}
// Try to spawn princess
- if (worldObj.rand.nextInt(1000) >= chance) {
+ if (world.rand.nextInt(1000) >= chance) {
return;
}
@@ -100,6 +99,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
}
+ @Nullable
private ItemStack getPrincessStack() {
ItemStack princessStack = getMultiblockLogic().getController().getBeeInventory().getQueen();
@@ -111,10 +111,6 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
}
private int consumeInducerAndGetChance() {
- if (getInternalInventory() == null) {
- return 0;
- }
-
for (int slotIndex = 0; slotIndex < getSizeInventory(); slotIndex++) {
ItemStack stack = getStackInSlot(slotIndex);
for (Entry entry : BeeManager.inducers.entrySet()) {
@@ -134,10 +130,10 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
HiveDescriptionSwarmer hiveDescription = new HiveDescriptionSwarmer(toSpawn);
Hive hive = new Hive(hiveDescription);
- int x = getPos().getX() + worldObj.rand.nextInt(40 * 2) - 40;
- int z = getPos().getZ() + worldObj.rand.nextInt(40 * 2) - 40;
+ int x = getPos().getX() + world.rand.nextInt(40 * 2) - 40;
+ int z = getPos().getZ() + world.rand.nextInt(40 * 2) - 40;
- if (HiveDecorator.tryGenHive(worldObj, worldObj.rand, x, z, hive)) {
+ if (HiveDecorator.tryGenHive(world, world.rand, x, z, hive)) {
pendingSpawns.pop();
}
}
@@ -165,11 +161,11 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
NBTTagList nbttaglist = nbttagcompound.getTagList("PendingSpawns", 10);
for (int i = 0; i < nbttaglist.tagCount(); i++) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
- pendingSpawns.add(ItemStack.loadItemStackFromNBT(nbttagcompound1));
+ pendingSpawns.add(new ItemStack(nbttagcompound1));
}
}
- @Nonnull
+
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -202,8 +198,8 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
this.active = active;
- if (worldObj != null && !worldObj.isRemote) {
- Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
+ if (world != null && !world.isRemote) {
+ Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), pos, world);
}
}
diff --git a/src/main/java/forestry/apiculture/multiblock/package-info.java b/src/main/java/forestry/apiculture/multiblock/package-info.java
new file mode 100644
index 000000000..eeba2f252
--- /dev/null
+++ b/src/main/java/forestry/apiculture/multiblock/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.multiblock;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/network/PacketRegistryApiculture.java b/src/main/java/forestry/apiculture/network/PacketRegistryApiculture.java
index 1a77b7c03..b00809da2 100644
--- a/src/main/java/forestry/apiculture/network/PacketRegistryApiculture.java
+++ b/src/main/java/forestry/apiculture/network/PacketRegistryApiculture.java
@@ -11,27 +11,28 @@
package forestry.apiculture.network;
import forestry.apiculture.network.packets.PacketActiveUpdate;
-import forestry.apiculture.network.packets.PacketAlveryChange;
+import forestry.apiculture.network.packets.PacketAlvearyChange;
import forestry.apiculture.network.packets.PacketBeeLogicActive;
import forestry.apiculture.network.packets.PacketBeeLogicActiveEntity;
import forestry.apiculture.network.packets.PacketBeeLogicEntityRequest;
import forestry.apiculture.network.packets.PacketCandleUpdate;
import forestry.apiculture.network.packets.PacketHabitatBiomePointer;
import forestry.apiculture.network.packets.PacketImprintSelectionResponse;
-import forestry.core.network.PacketRegistry;
+import forestry.core.network.IPacketRegistry;
+import forestry.core.network.PacketIdClient;
+import forestry.core.network.PacketIdServer;
-public class PacketRegistryApiculture extends PacketRegistry {
+public class PacketRegistryApiculture implements IPacketRegistry {
@Override
public void registerPackets() {
- registerClientPacket(new PacketImprintSelectionResponse());
- registerClientPacket(new PacketActiveUpdate());
- registerClientPacket(new PacketBeeLogicActive());
- registerClientPacket(new PacketBeeLogicActiveEntity());
- registerClientPacket(new PacketHabitatBiomePointer());
- registerClientPacket(new PacketCandleUpdate());
-
- registerServerPacket(new PacketBeeLogicEntityRequest());
-
- registerClientPacket(new PacketAlveryChange());
+ PacketIdClient.IMPRINT_SELECTION_RESPONSE.setPacketHandler(new PacketImprintSelectionResponse.Handler());
+ PacketIdClient.TILE_FORESTRY_ACTIVE.setPacketHandler(new PacketActiveUpdate.Handler());
+ PacketIdClient.BEE_LOGIC_ACTIVE.setPacketHandler(new PacketBeeLogicActive.Handler());
+ PacketIdClient.BEE_LOGIC_ACTIVE_ENTITY.setPacketHandler(new PacketBeeLogicActiveEntity.Handler());
+ PacketIdClient.HABITAT_BIOME_POINTER.setPacketHandler(new PacketHabitatBiomePointer.Handler());
+ PacketIdClient.CANDLE_UPDATE.setPacketHandler(new PacketCandleUpdate.Handler());
+ PacketIdClient.ALVERAY_CONTROLLER_CHANGE.setPacketHandler(new PacketAlvearyChange.Handler());
+
+ PacketIdServer.BEE_LOGIC_ACTIVE_ENTITY_REQUEST.setPacketHandler(new PacketBeeLogicEntityRequest.Handler());
}
}
diff --git a/src/main/java/forestry/apiculture/network/package-info.java b/src/main/java/forestry/apiculture/network/package-info.java
new file mode 100644
index 000000000..076c4afb2
--- /dev/null
+++ b/src/main/java/forestry/apiculture/network/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.network;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/network/packets/PacketActiveUpdate.java b/src/main/java/forestry/apiculture/network/packets/PacketActiveUpdate.java
index 0e4d3c182..5433a2df0 100644
--- a/src/main/java/forestry/apiculture/network/packets/PacketActiveUpdate.java
+++ b/src/main/java/forestry/apiculture/network/packets/PacketActiveUpdate.java
@@ -12,26 +12,24 @@ package forestry.apiculture.network.packets;
import java.io.IOException;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.tileentity.TileEntity;
import forestry.api.multiblock.IMultiblockComponent;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
+import forestry.core.network.ForestryPacket;
import forestry.core.network.IForestryPacketClient;
+import forestry.core.network.IForestryPacketHandlerClient;
+import forestry.core.network.PacketBufferForestry;
import forestry.core.network.PacketIdClient;
-import forestry.core.network.packets.PacketCoordinates;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.IActivatable;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.math.BlockPos;
-public class PacketActiveUpdate extends PacketCoordinates implements IForestryPacketClient {
-
- private boolean active;
-
- public PacketActiveUpdate() {
- }
+public class PacketActiveUpdate extends ForestryPacket implements IForestryPacketClient {
+ private final BlockPos pos;
+ private final boolean active;
public PacketActiveUpdate(IActivatable tile) {
- super(tile.getCoordinates());
+ this.pos = tile.getCoordinates();
this.active = tile.isActive();
}
@@ -41,27 +39,26 @@ public class PacketActiveUpdate extends PacketCoordinates implements IForestryPa
}
@Override
- protected void writeData(DataOutputStreamForestry data) throws IOException {
- super.writeData(data);
+ protected void writeData(PacketBufferForestry data) throws IOException {
+ data.writeBlockPos(pos);
data.writeBoolean(active);
}
- @Override
- public void readData(DataInputStreamForestry data) throws IOException {
- super.readData(data);
- active = data.readBoolean();
- }
+ public static class Handler implements IForestryPacketHandlerClient {
+ @Override
+ public void onPacketData(PacketBufferForestry data, EntityPlayer player) {
+ BlockPos pos = data.readBlockPos();
+ boolean active = data.readBoolean();
- @Override
- public void onPacketData(DataInputStreamForestry data, EntityPlayer player) {
- TileEntity tile = getTarget(Proxies.common.getRenderWorld());
- if (tile instanceof IActivatable) {
- ((IActivatable) tile).setActive(active);
- }else{
- if(tile instanceof IMultiblockComponent){
- IMultiblockComponent component = (IMultiblockComponent) tile;
- if(component.getMultiblockLogic().isConnected() && component.getMultiblockLogic().getController() instanceof IActivatable){
- ((IActivatable)component.getMultiblockLogic().getController()).setActive(active);
+ TileEntity tile = Proxies.common.getRenderWorld().getTileEntity(pos);
+ if (tile instanceof IActivatable) {
+ ((IActivatable) tile).setActive(active);
+ } else {
+ if (tile instanceof IMultiblockComponent) {
+ IMultiblockComponent component = (IMultiblockComponent) tile;
+ if (component.getMultiblockLogic().isConnected() && component.getMultiblockLogic().getController() instanceof IActivatable) {
+ ((IActivatable) component.getMultiblockLogic().getController()).setActive(active);
+ }
}
}
}
diff --git a/src/main/java/forestry/apiculture/network/packets/PacketAlveryChange.java b/src/main/java/forestry/apiculture/network/packets/PacketAlvearyChange.java
similarity index 51%
rename from src/main/java/forestry/apiculture/network/packets/PacketAlveryChange.java
rename to src/main/java/forestry/apiculture/network/packets/PacketAlvearyChange.java
index 8bd1a2068..ae0337da7 100644
--- a/src/main/java/forestry/apiculture/network/packets/PacketAlveryChange.java
+++ b/src/main/java/forestry/apiculture/network/packets/PacketAlvearyChange.java
@@ -10,24 +10,25 @@
******************************************************************************/
package forestry.apiculture.network.packets;
+import java.io.IOException;
+
+import forestry.core.network.ForestryPacket;
+import forestry.core.network.IForestryPacketHandlerClient;
+import forestry.core.network.PacketBufferForestry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import forestry.api.multiblock.IMultiblockComponent;
-import forestry.apiculture.multiblock.IAlvearyControllerInternal;
-import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.IForestryPacketClient;
import forestry.core.network.PacketIdClient;
-import forestry.core.network.packets.PacketCoordinates;
import forestry.core.proxy.Proxies;
+import net.minecraft.util.math.BlockPos;
-public class PacketAlveryChange extends PacketCoordinates implements IForestryPacketClient {
+public class PacketAlvearyChange extends ForestryPacket implements IForestryPacketClient {
+ private final BlockPos controllerPos;
- public PacketAlveryChange() {
- }
-
- public PacketAlveryChange(IAlvearyControllerInternal controller) {
- super(controller.getReferenceCoord());
+ public PacketAlvearyChange(BlockPos controllerPos) {
+ this.controllerPos = controllerPos;
}
@Override
@@ -36,10 +37,18 @@ public class PacketAlveryChange extends PacketCoordinates implements IForestryPa
}
@Override
- public void onPacketData(DataInputStreamForestry data, EntityPlayer player) {
- TileEntity tile = getTarget(Proxies.common.getRenderWorld());
- if (tile instanceof IMultiblockComponent) {
- ((IMultiblockComponent) tile).getMultiblockLogic().getController().reassemble();
+ protected void writeData(PacketBufferForestry data) throws IOException {
+ data.writeBlockPos(controllerPos);
+ }
+
+ public static class Handler implements IForestryPacketHandlerClient {
+ @Override
+ public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
+ BlockPos pos = data.readBlockPos();
+ TileEntity tile = Proxies.common.getRenderWorld().getTileEntity(pos);
+ if (tile instanceof IMultiblockComponent) {
+ ((IMultiblockComponent) tile).getMultiblockLogic().getController().reassemble();
+ }
}
}
}
diff --git a/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicActive.java b/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicActive.java
index 167bed090..e60a175b5 100644
--- a/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicActive.java
+++ b/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicActive.java
@@ -12,27 +12,26 @@ package forestry.apiculture.network.packets;
import java.io.IOException;
+import forestry.core.network.ForestryPacket;
+import forestry.core.network.IForestryPacketHandlerClient;
+import forestry.core.network.PacketBufferForestry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.apiculture.BeekeepingLogic;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IForestryPacketClient;
import forestry.core.network.PacketIdClient;
-import forestry.core.network.packets.PacketCoordinates;
import forestry.core.proxy.Proxies;
+import net.minecraft.util.math.BlockPos;
-public class PacketBeeLogicActive extends PacketCoordinates implements IForestryPacketClient {
- private BeekeepingLogic beekeepingLogic;
-
- public PacketBeeLogicActive() {
- }
+public class PacketBeeLogicActive extends ForestryPacket implements IForestryPacketClient {
+ private final BlockPos tilePos;
+ private final BeekeepingLogic beekeepingLogic;
public PacketBeeLogicActive(IBeeHousing tile) {
- super(tile.getCoordinates());
+ this.tilePos = tile.getCoordinates();
this.beekeepingLogic = (BeekeepingLogic) tile.getBeekeepingLogic();
}
@@ -42,19 +41,23 @@ public class PacketBeeLogicActive extends PacketCoordinates implements IForestry
}
@Override
- protected void writeData(DataOutputStreamForestry data) throws IOException {
- super.writeData(data);
+ protected void writeData(PacketBufferForestry data) throws IOException {
+ data.writeBlockPos(tilePos);
beekeepingLogic.writeData(data);
}
- @Override
- public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
- TileEntity tile = getTarget(Proxies.common.getRenderWorld());
- if (tile instanceof IBeeHousing) {
- IBeeHousing beeHousing = (IBeeHousing) tile;
- IBeekeepingLogic beekeepingLogic = beeHousing.getBeekeepingLogic();
- if (beekeepingLogic instanceof BeekeepingLogic) {
- ((BeekeepingLogic) beekeepingLogic).readData(data);
+ public static class Handler implements IForestryPacketHandlerClient {
+ @Override
+ public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
+ BlockPos tilePos = data.readBlockPos();
+
+ TileEntity tile = Proxies.common.getRenderWorld().getTileEntity(tilePos);
+ if (tile instanceof IBeeHousing) {
+ IBeeHousing beeHousing = (IBeeHousing) tile;
+ IBeekeepingLogic beekeepingLogic = beeHousing.getBeekeepingLogic();
+ if (beekeepingLogic instanceof BeekeepingLogic) {
+ ((BeekeepingLogic) beekeepingLogic).readData(data);
+ }
}
}
}
diff --git a/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicActiveEntity.java b/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicActiveEntity.java
index 0b94cd232..af6aa2e8a 100644
--- a/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicActiveEntity.java
+++ b/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicActiveEntity.java
@@ -12,27 +12,23 @@ package forestry.apiculture.network.packets;
import java.io.IOException;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.apiculture.BeekeepingLogic;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
+import forestry.core.network.ForestryPacket;
import forestry.core.network.IForestryPacketClient;
+import forestry.core.network.IForestryPacketHandlerClient;
+import forestry.core.network.PacketBufferForestry;
import forestry.core.network.PacketIdClient;
-import forestry.core.network.packets.PacketEntityUpdate;
-import forestry.core.proxy.Proxies;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
-public class PacketBeeLogicActiveEntity extends PacketEntityUpdate implements IForestryPacketClient {
- private BeekeepingLogic beekeepingLogic;
-
- public PacketBeeLogicActiveEntity() {
- }
+public class PacketBeeLogicActiveEntity extends ForestryPacket implements IForestryPacketClient {
+ private final Entity entity;
+ private final BeekeepingLogic beekeepingLogic;
public PacketBeeLogicActiveEntity(IBeeHousing housing, Entity entity) {
- super(entity);
+ this.entity = entity;
this.beekeepingLogic = (BeekeepingLogic) housing.getBeekeepingLogic();
}
@@ -42,19 +38,21 @@ public class PacketBeeLogicActiveEntity extends PacketEntityUpdate implements IF
}
@Override
- protected void writeData(DataOutputStreamForestry data) throws IOException {
- super.writeData(data);
+ protected void writeData(PacketBufferForestry data) throws IOException {
+ data.writeEntityById(entity);
beekeepingLogic.writeData(data);
}
- @Override
- public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
- Entity entity = getTarget(Proxies.common.getRenderWorld());
- if (entity instanceof IBeeHousing) {
- IBeeHousing beeHousing = (IBeeHousing) entity;
- IBeekeepingLogic beekeepingLogic = beeHousing.getBeekeepingLogic();
- if (beekeepingLogic instanceof BeekeepingLogic) {
- ((BeekeepingLogic) beekeepingLogic).readData(data);
+ public static class Handler implements IForestryPacketHandlerClient {
+ @Override
+ public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
+ Entity entity = data.readEntityById(player.world);
+ if (entity instanceof IBeeHousing) {
+ IBeeHousing beeHousing = (IBeeHousing) entity;
+ IBeekeepingLogic beekeepingLogic = beeHousing.getBeekeepingLogic();
+ if (beekeepingLogic instanceof BeekeepingLogic) {
+ ((BeekeepingLogic) beekeepingLogic).readData(data);
+ }
}
}
}
diff --git a/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicEntityRequest.java b/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicEntityRequest.java
index ec94f48b4..8fec0e58e 100644
--- a/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicEntityRequest.java
+++ b/src/main/java/forestry/apiculture/network/packets/PacketBeeLogicEntityRequest.java
@@ -12,23 +12,21 @@ package forestry.apiculture.network.packets;
import java.io.IOException;
+import forestry.api.apiculture.IBeeHousing;
+import forestry.api.apiculture.IBeekeepingLogic;
+import forestry.core.network.ForestryPacket;
+import forestry.core.network.IForestryPacketHandlerServer;
+import forestry.core.network.IForestryPacketServer;
+import forestry.core.network.PacketBufferForestry;
+import forestry.core.network.PacketIdServer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
-import forestry.api.apiculture.IBeeHousing;
-import forestry.api.apiculture.IBeekeepingLogic;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.IForestryPacketServer;
-import forestry.core.network.PacketIdServer;
-import forestry.core.network.packets.PacketEntityUpdate;
-
-public class PacketBeeLogicEntityRequest extends PacketEntityUpdate implements IForestryPacketServer {
-
- public PacketBeeLogicEntityRequest() {
- }
+public class PacketBeeLogicEntityRequest extends ForestryPacket implements IForestryPacketServer {
+ private final Entity entity;
public PacketBeeLogicEntityRequest(Entity entity) {
- super(entity);
+ this.entity = entity;
}
@Override
@@ -37,15 +35,19 @@ public class PacketBeeLogicEntityRequest extends PacketEntityUpdate implements I
}
@Override
- public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
- Entity entity = getTarget(player.worldObj);
- if (entity instanceof IBeeHousing) {
- IBeeHousing beeHousing = (IBeeHousing) entity;
- IBeekeepingLogic beekeepingLogic = beeHousing.getBeekeepingLogic();
- if (beekeepingLogic != null) {
+ protected void writeData(PacketBufferForestry data) throws IOException {
+ data.writeEntityById(entity);
+ }
+
+ public static class Handler implements IForestryPacketHandlerServer {
+ @Override
+ public void onPacketData(PacketBufferForestry data, EntityPlayerMP player) throws IOException {
+ Entity entity = data.readEntityById(player.world);
+ if (entity instanceof IBeeHousing) {
+ IBeeHousing beeHousing = (IBeeHousing) entity;
+ IBeekeepingLogic beekeepingLogic = beeHousing.getBeekeepingLogic();
beekeepingLogic.syncToClient(player);
}
}
}
-
}
diff --git a/src/main/java/forestry/apiculture/network/packets/PacketCandleUpdate.java b/src/main/java/forestry/apiculture/network/packets/PacketCandleUpdate.java
index 4200ac7d1..7f3fbc865 100644
--- a/src/main/java/forestry/apiculture/network/packets/PacketCandleUpdate.java
+++ b/src/main/java/forestry/apiculture/network/packets/PacketCandleUpdate.java
@@ -12,28 +12,23 @@ package forestry.apiculture.network.packets;
import java.io.IOException;
+import forestry.apiculture.tiles.TileCandle;
+import forestry.core.network.ForestryPacket;
+import forestry.core.network.IForestryPacketClient;
+import forestry.core.network.IForestryPacketHandlerClient;
+import forestry.core.network.PacketBufferForestry;
+import forestry.core.network.PacketIdClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.math.BlockPos;
-import forestry.apiculture.tiles.TileCandle;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
-import forestry.core.network.IForestryPacketClient;
-import forestry.core.network.PacketIdClient;
-import forestry.core.network.packets.PacketCoordinates;
-import forestry.core.proxy.Proxies;
-
-public class PacketCandleUpdate extends PacketCoordinates implements IForestryPacketClient {
-
- private int colour;
- private boolean lit;
-
- public PacketCandleUpdate() {
- }
+public class PacketCandleUpdate extends ForestryPacket implements IForestryPacketClient {
+ private final BlockPos pos;
+ private final int colour;
+ private final boolean lit;
public PacketCandleUpdate(TileCandle tileCandle) {
- super(tileCandle);
-
+ pos = tileCandle.getPos();
colour = tileCandle.getColour();
lit = tileCandle.isLit();
}
@@ -44,24 +39,23 @@ public class PacketCandleUpdate extends PacketCoordinates implements IForestryPa
}
@Override
- public void writeData(DataOutputStreamForestry data) throws IOException {
- super.writeData(data);
+ protected void writeData(PacketBufferForestry data) throws IOException {
+ data.writeBlockPos(pos);
data.writeInt(colour);
data.writeBoolean(lit);
}
- @Override
- public void readData(DataInputStreamForestry data) throws IOException {
- super.readData(data);
- colour = data.readInt();
- lit = data.readBoolean();
- }
+ public static class Handler implements IForestryPacketHandlerClient {
+ @Override
+ public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
+ BlockPos pos = data.readBlockPos();
+ int colour = data.readInt();
+ boolean lit = data.readBoolean();
- @Override
- public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
- TileEntity tileEntity = getTarget(Proxies.common.getRenderWorld());
- if (tileEntity instanceof TileCandle) {
- ((TileCandle) tileEntity).onPacketUpdate(colour, lit);
+ TileEntity tileEntity = player.world.getTileEntity(pos);
+ if (tileEntity instanceof TileCandle) {
+ ((TileCandle) tileEntity).onPacketUpdate(colour, lit);
+ }
}
}
}
diff --git a/src/main/java/forestry/apiculture/network/packets/PacketHabitatBiomePointer.java b/src/main/java/forestry/apiculture/network/packets/PacketHabitatBiomePointer.java
index ac1914271..0513e82de 100644
--- a/src/main/java/forestry/apiculture/network/packets/PacketHabitatBiomePointer.java
+++ b/src/main/java/forestry/apiculture/network/packets/PacketHabitatBiomePointer.java
@@ -12,22 +12,25 @@ package forestry.apiculture.network.packets;
import java.io.IOException;
+import forestry.core.network.ForestryPacket;
+import forestry.core.network.IForestryPacketClient;
+import forestry.core.network.IForestryPacketHandlerClient;
+import forestry.core.network.PacketBufferForestry;
+import forestry.core.network.PacketIdClient;
+import forestry.core.proxy.Proxies;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.IForestryPacketClient;
-import forestry.core.network.PacketIdClient;
-import forestry.core.network.packets.PacketCoordinates;
-import forestry.core.proxy.Proxies;
-
-public class PacketHabitatBiomePointer extends PacketCoordinates implements IForestryPacketClient {
-
- public PacketHabitatBiomePointer() {
- }
+public class PacketHabitatBiomePointer extends ForestryPacket implements IForestryPacketClient {
+ private final BlockPos pos;
public PacketHabitatBiomePointer(BlockPos coordinates) {
- super(coordinates);
+ this.pos = coordinates;
+ }
+
+ @Override
+ protected void writeData(PacketBufferForestry data) throws IOException {
+ data.writeBlockPos(pos);
}
@Override
@@ -35,8 +38,11 @@ public class PacketHabitatBiomePointer extends PacketCoordinates implements IFor
return PacketIdClient.HABITAT_BIOME_POINTER;
}
- @Override
- public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
- Proxies.render.setHabitatLocatorTexture(player, getPos());
+ public static class Handler implements IForestryPacketHandlerClient {
+ @Override
+ public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
+ BlockPos pos = data.readBlockPos();
+ Proxies.render.setHabitatLocatorTexture(player, pos);
+ }
}
}
diff --git a/src/main/java/forestry/apiculture/network/packets/PacketImprintSelectionResponse.java b/src/main/java/forestry/apiculture/network/packets/PacketImprintSelectionResponse.java
index bd1905fc4..d05f59a59 100644
--- a/src/main/java/forestry/apiculture/network/packets/PacketImprintSelectionResponse.java
+++ b/src/main/java/forestry/apiculture/network/packets/PacketImprintSelectionResponse.java
@@ -12,22 +12,22 @@ package forestry.apiculture.network.packets;
import java.io.IOException;
+import forestry.apiculture.gui.ContainerImprinter;
+import forestry.core.network.ForestryPacket;
+import forestry.core.network.IForestryPacketClient;
+import forestry.core.network.IForestryPacketHandlerClient;
+import forestry.core.network.PacketBufferForestry;
+import forestry.core.network.PacketIdClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
-import forestry.apiculture.gui.ContainerImprinter;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.IForestryPacketClient;
-import forestry.core.network.PacketIdClient;
-import forestry.core.network.packets.PacketGuiSelect;
-
-public class PacketImprintSelectionResponse extends PacketGuiSelect implements IForestryPacketClient {
-
- public PacketImprintSelectionResponse() {
- }
+public class PacketImprintSelectionResponse extends ForestryPacket implements IForestryPacketClient {
+ private final int primary;
+ private final int secondary;
public PacketImprintSelectionResponse(int primaryIndex, int secondaryIndex) {
- super(primaryIndex, secondaryIndex);
+ this.primary = primaryIndex;
+ this.secondary = secondaryIndex;
}
@Override
@@ -36,12 +36,21 @@ public class PacketImprintSelectionResponse extends PacketGuiSelect implements I
}
@Override
- public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
- Container container = player.openContainer;
- if (!(container instanceof ContainerImprinter)) {
- return;
- }
+ protected void writeData(PacketBufferForestry data) throws IOException {
+ data.writeVarInt(primary);
+ data.writeVarInt(secondary);
+ }
- ((ContainerImprinter) container).setSelection(this);
+ public static class Handler implements IForestryPacketHandlerClient {
+ @Override
+ public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException {
+ Container container = player.openContainer;
+ if (container instanceof ContainerImprinter) {
+ int primaryIndex = data.readVarInt();
+ int secondaryIndex = data.readVarInt();
+
+ ((ContainerImprinter) container).setSelection(primaryIndex, secondaryIndex);
+ }
+ }
}
}
diff --git a/src/main/java/forestry/apiculture/network/packets/package-info.java b/src/main/java/forestry/apiculture/network/packets/package-info.java
new file mode 100644
index 000000000..cc88e6559
--- /dev/null
+++ b/src/main/java/forestry/apiculture/network/packets/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.network.packets;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/package-info.java b/src/main/java/forestry/apiculture/package-info.java
new file mode 100644
index 000000000..c7e8cd695
--- /dev/null
+++ b/src/main/java/forestry/apiculture/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/proxy/package-info.java b/src/main/java/forestry/apiculture/proxy/package-info.java
new file mode 100644
index 000000000..0d78f64ab
--- /dev/null
+++ b/src/main/java/forestry/apiculture/proxy/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.proxy;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/render/ModelAnalyzer.java b/src/main/java/forestry/apiculture/render/ModelAnalyzer.java
index 5e4164881..18ed1aad6 100755
--- a/src/main/java/forestry/apiculture/render/ModelAnalyzer.java
+++ b/src/main/java/forestry/apiculture/render/ModelAnalyzer.java
@@ -61,9 +61,6 @@ public class ModelAnalyzer extends ModelBase {
GlStateManager.translate(posX, posY, posZ);
float[] angle = {0, 0, 0};
- if (orientation == null) {
- orientation = EnumFacing.WEST;
- }
switch (orientation) {
case EAST:
angle[1] = (float) Math.PI / 2;
diff --git a/src/main/java/forestry/apiculture/render/ModelBee.java b/src/main/java/forestry/apiculture/render/ModelBee.java
deleted file mode 100755
index a7ad29c9d..000000000
--- a/src/main/java/forestry/apiculture/render/ModelBee.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011-2014 SirSengir.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser Public License v3
- * which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl-3.0.txt
- *
- * Various Contributors including, but not limited to:
- * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
- ******************************************************************************/
-package forestry.apiculture.render;
-
-import net.minecraft.client.model.ModelBase;
-import net.minecraft.client.model.ModelRenderer;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.entity.Entity;
-import net.minecraft.util.math.MathHelper;
-
-import forestry.api.apiculture.EnumBeeType;
-
-public class ModelBee extends ModelBase {
-
- //fields
- private final ModelRenderer snout;
- private final ModelRenderer torsoWing;
- private final ModelRenderer rump;
- private final ModelRenderer tail;
- private final ModelRenderer tailEnd;
- private final ModelRenderer bridge;
- private final ModelRenderer eyeRight;
- private final ModelRenderer eyeLeft;
- private final ModelRenderer wingLeft;
- private final ModelRenderer wingRight;
- private final ModelRenderer crownQueen;
- private final ModelRenderer crownPrincess;
-
- private EnumBeeType type = EnumBeeType.DRONE;
-
- public ModelBee() {
- textureWidth = 64;
- textureHeight = 32;
-
- snout = new ModelRenderer(this, 18, 11);
- snout.addBox(0F, 0F, 0F, 1, 2, 1);
- snout.setRotationPoint(0F, 1F, -2F);
- snout.setTextureSize(64, 32);
- snout.mirror = true;
- setRotation(snout, 0F, 0F, 0F);
- torsoWing = new ModelRenderer(this, 28, 14);
- torsoWing.addBox(0F, 0F, 0F, 3, 3, 1);
- torsoWing.setRotationPoint(-1F, 0F, -1F);
- torsoWing.setTextureSize(64, 32);
- torsoWing.mirror = true;
- setRotation(torsoWing, 0F, 0F, 0F);
- rump = new ModelRenderer(this, 10, 14);
- rump.addBox(-1F, -1F, 0F, 3, 3, 3);
- rump.setRotationPoint(0F, 1F, 1F);
- rump.setTextureSize(64, 32);
- rump.mirror = true;
- setRotation(rump, 0F, 0F, 0F);
- tail = new ModelRenderer(this, 4, 14);
- tail.addBox(0F, 0F, 0F, 2, 2, 1);
- tail.setRotationPoint(-0.5F, 0.5333334F, 4F);
- tail.setTextureSize(64, 32);
- tail.mirror = true;
- setRotation(tail, 0F, 0F, 0F);
- tailEnd = new ModelRenderer(this, 0, 14);
- tailEnd.addBox(0F, 0F, 0F, 1, 1, 1);
- tailEnd.setRotationPoint(0F, 1F, 5F);
- tailEnd.setTextureSize(64, 32);
- tailEnd.mirror = true;
- setRotation(tailEnd, 0F, 0F, 0F);
- bridge = new ModelRenderer(this, 22, 14);
- bridge.addBox(0F, 0F, 0F, 2, 2, 1);
- bridge.setRotationPoint(-0.5F, 0.5F, 0F);
- bridge.setTextureSize(64, 32);
- bridge.mirror = true;
- setRotation(bridge, 0F, 0F, 0F);
- eyeRight = new ModelRenderer(this, 22, 9);
- eyeRight.addBox(0F, 0F, 0F, 1, 1, 1);
- eyeRight.setRotationPoint(-1F, 0F, -2F);
- eyeRight.setTextureSize(64, 32);
- eyeRight.mirror = true;
- setRotation(eyeRight, 0F, 0F, 0F);
- eyeLeft = new ModelRenderer(this, 18, 9);
- eyeLeft.addBox(0F, 0F, 0F, 1, 1, 1);
- eyeLeft.setRotationPoint(1F, 0F, -2F);
- eyeLeft.setTextureSize(64, 32);
- eyeLeft.mirror = true;
- setRotation(eyeLeft, 0F, 0F, 0F);
- wingLeft = new ModelRenderer(this, 0, 0);
- wingLeft.addBox(0F, 0F, 0F, 3, 1, 6);
- wingLeft.setRotationPoint(1F, -0.1F, -0.5F);
- wingLeft.setTextureSize(64, 32);
- wingLeft.mirror = true;
- setRotation(wingLeft, 0F, 0.1396263F, 0F);
- wingRight = new ModelRenderer(this, 0, 7);
- wingRight.addBox(-3F, 0F, 0F, 3, 1, 6);
- wingRight.setRotationPoint(0F, -0.1F, -0.5F);
- wingRight.setTextureSize(64, 32);
- wingRight.mirror = true;
- setRotation(wingRight, 0F, -0.1396263F, 0F);
-
- crownQueen = new ModelRenderer(this, 0, 17);
- crownQueen.addBox(0F, 0F, 0F, 2, 1, 2);
- crownQueen.setRotationPoint(-0.5F, -1.5F, -1.5F);
- crownQueen.setTextureSize(64, 32);
- crownQueen.mirror = true;
- setRotation(crownQueen, 0F, 0F, 0F);
-
- crownPrincess = new ModelRenderer(this, 0, 20);
- crownPrincess.addBox(0F, 0F, 0F, 2, 1, 2);
- crownPrincess.setRotationPoint(-0.5F, -1.5F, -1.5F);
- crownPrincess.setTextureSize(64, 32);
- crownPrincess.mirror = true;
- setRotation(crownPrincess, 0F, 0F, 0F);
-
- }
-
- public void setType(EnumBeeType type) {
- this.type = type;
- }
-
- @Override
- public void render(Entity entity, float f, float f1, float swing, float f3, float f4, float f5) {
- super.render(entity, f, f1, swing, f3, f4, f5);
- //setRotationAngles(f, f1, f2, f3, f4, f5, entity);
-
- wingRight.rotateAngleZ = MathHelper.cos(swing * 1.3F) * (float) Math.PI * 0.25F;
- wingLeft.rotateAngleZ = -wingRight.rotateAngleZ;
-
- GlStateManager.pushMatrix();
- float scale = 0.75f;
- GlStateManager.scale(scale, scale, scale);
- GlStateManager.translate(0.0F, 12.0f / scale * f5, 0.0F);
-
- snout.render(f5);
- torsoWing.render(f5);
- rump.render(f5);
- tail.render(f5);
- tailEnd.render(f5);
- bridge.render(f5);
- eyeRight.render(f5);
- eyeLeft.render(f5);
- wingLeft.render(f5);
- wingRight.render(f5);
-
- if (type == EnumBeeType.PRINCESS) {
- crownPrincess.render(f5);
- } else if (type == EnumBeeType.QUEEN) {
- crownQueen.render(f5);
- }
-
- GlStateManager.popMatrix();
- }
-
- private static void setRotation(ModelRenderer model, float x, float y, float z) {
- model.rotateAngleX = x;
- model.rotateAngleY = y;
- model.rotateAngleZ = z;
- }
-
-}
diff --git a/src/main/java/forestry/apiculture/render/RenderBeeItem.java b/src/main/java/forestry/apiculture/render/RenderBeeItem.java
deleted file mode 100644
index c72e5f5d3..000000000
--- a/src/main/java/forestry/apiculture/render/RenderBeeItem.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011-2014 SirSengir.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the GNU Lesser Public License v3
- * which accompanies this distribution, and is available at
- * http://www.gnu.org/licenses/lgpl-3.0.txt
- *
- * Various Contributors including, but not limited to:
- * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
- ******************************************************************************/
-package forestry.apiculture.render;
-
-public class RenderBeeItem/* implements IItemRenderer*/ {
-
- /*private EntityBee entity;
-
- private static float getWingYaw(IBee bee) {
- float wingYaw = 1f;
-
- if (bee.isAlive()) {
- long systemTime = System.currentTimeMillis();
- long flapping = systemTime + bee.getIdent().hashCode();
- float flap = (float) (flapping % 1000) / 1000; // 0 to 1
-
- wingYaw = getIrregularWingYaw(flapping, flap);
-
- }
-
- return wingYaw;
- }
-
- private static float getIrregularWingYaw(long flapping, float flap) {
- long irregular = flapping / 1000;
- float wingYaw;
-
- if (irregular % 11 == 0) {
- wingYaw = 0.75f;
- } else {
- if (irregular % 7 == 0 || irregular % 19 == 0) {
- flap *= 8;
- flap = flap % 1;
- }
- wingYaw = getRegularWingYaw(flap);
- }
-
- return wingYaw;
- }
-
- private static float getRegularWingYaw(float flap) {
- return flap < 0.5 ? 0.75f + flap : 1.75f - flap;
- }
-
- private IBee initBee(ItemStack item, boolean scaled) {
- IBee bee = BeeManager.beeRoot.getMember(item);
- if (bee == null) {
- bee = BeeManager.beeRoot.templateAsIndividual(BeeManager.beeRoot.getDefaultTemplate());
- }
-
- if (entity == null) {
- entity = new EntityBee(Proxies.common.getClientInstance().theWorld);
- }
- entity.setSpecies(bee.getGenome().getPrimary());
- entity.setType(BeeManager.beeRoot.getType(item));*/
- /*
- if(scaled)
- entity.setScale(butterfly.getSize());
- else
- entity.setScale(EntityButterfly.DEFAULT_BUTTERFLY_SIZE);
- */
-
- /* return bee;
- }*/
-
- /*private void renderBeeHalo() {
-
- IIcon background = TextureManager.getInstance().getDefault("habitats/desert");
- float xPos = 1.0f; float yPos = 1.0f;
- float width = 1f; float height = 1f;
-
- Proxies.render.bindTexture(SpriteSheet.ITEMS);
- Tessellator tessellator = Tessellator.instance;
- tessellator.startDrawingQuads();
- tessellator.addVertexWithUV((double)(xPos + 0), (double)(yPos + height), 0f, (double)background.getMinU(), (double)background.getMaxV());
- tessellator.addVertexWithUV((double)(xPos + width), (double)(yPos + height), 0f, (double)background.getMaxU(), (double)background.getMaxV());
- tessellator.addVertexWithUV((double)(xPos + width), (double)(yPos + 0), 0f, (double)background.getMaxU(), (double)background.getMinV());
- tessellator.addVertexWithUV((double)(xPos + 0), (double)(yPos + 0), 0f, (double)background.getMinU(), (double)background.getMinV());
- tessellator.draw();
- }*/
-
- /*private void renderBeeItem(IBee bee, float translateX, float translateY, float translateZ) {
- float yaw = 1;
- float pitch = 1;
-
- GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
- GL11.glEnable(GL11.GL_DEPTH_TEST);
- GL11.glEnable(GL11.GL_COLOR_MATERIAL);
-
- GlStateManager.pushMatrix();
-
- GlStateManager.scale(2.0f, 2.0f, 2.0f);
- GlStateManager.translate(translateX, translateY, translateZ);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
- GlStateManager.rotate(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
-
- entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F;
- entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F;
- entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F;
- entity.rotationYawHead = entity.rotationYaw;
-
- RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(bee));
-
- GlStateManager.popMatrix();
-
- RenderHelper.disableStandardItemLighting();
- GL11.glDisable(GL12.GL_RESCALE_NORMAL);
- OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
- GL11.glPopAttrib();
-
- }
-
- private void renderBeeInInventory(IBee bee) {*/
-
- /*
- GlStateManager.pushMatrix();
- //GlStateManager.translate(-0.3f, -2.5f, 0f);
- GlStateManager.scale(-1.0f, 1.0f, 1.0f);
- //GlStateManager.scale((float)Math.PI / 2, 1.0f, 1.0f);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
- //GlStateManager.rotate(-((float) Math.atan((double) (1 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
- renderBeeHalo();
- GlStateManager.popMatrix();
- */
-
- /*GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
- GL11.glEnable(GL11.GL_DEPTH_TEST);
- GL11.glEnable(GL11.GL_COLOR_MATERIAL);
- RenderHelper.enableStandardItemLighting();
-
- GlStateManager.pushMatrix();
-
- GlStateManager.translate(-0.3f, -2.5f, 0f);
- GlStateManager.scale(-3.0f, 3.0f, 3.0f);
- GlStateManager.rotate(32.0F, 0.0F, 1.0F, 0.0F);
- GlStateManager.scale(1.6f, 1f, 1f);
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- entity.renderYawOffset = 0;
- entity.rotationYaw = 0;
- entity.rotationPitch = 0;
- entity.rotationYawHead = entity.rotationYaw;
-
- RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(bee));
-
- GlStateManager.popMatrix();
- RenderHelper.disableStandardItemLighting();
- GL11.glDisable(GL12.GL_RESCALE_NORMAL);
- OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
- GL11.glPopAttrib();
- }
-
- @Override
- public boolean handleRenderType(ItemStack item, ItemRenderType type) {
- switch (type) {
- case ENTITY:
- return true;
- case EQUIPPED:
- return true;
- case INVENTORY:
- return true;
- default:
- return false;
- }
- }
-
- @Override
- public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
- switch (helper) {
- case ENTITY_BOBBING:
- case ENTITY_ROTATION:
- return false;
- default:
- return true;
- }
- }
-
- @Override
- public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
-
- switch (type) {
- case ENTITY:
- renderBeeItem(initBee(item, true), 0f, 0f, 0f);
- break;
- case EQUIPPED:
- renderBeeItem(initBee(item, true), 1.0f, 0f, 0.5f);
- break;
- case INVENTORY:
- renderBeeInInventory(initBee(item, false));
- break;
- default:
- }
- }*/
-
-}
diff --git a/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java b/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java
index a9a0fcfc4..62f88b4d3 100644
--- a/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java
+++ b/src/main/java/forestry/apiculture/render/TextureHabitatLocator.java
@@ -48,8 +48,8 @@ public class TextureHabitatLocator extends TextureAtlasSprite {
public void updateAnimation() {
Minecraft minecraft = Minecraft.getMinecraft();
- if (minecraft.theWorld != null && minecraft.thePlayer != null) {
- updateCompass(minecraft.theWorld, minecraft.thePlayer.posX, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw);
+ if (minecraft.world != null && minecraft.player != null) {
+ updateCompass(minecraft.world, minecraft.player.posX, minecraft.player.posZ, minecraft.player.rotationYaw);
} else {
updateCompass(null, 0.0d, 0.0d, 0.0d);
}
diff --git a/src/main/java/forestry/apiculture/render/package-info.java b/src/main/java/forestry/apiculture/render/package-info.java
new file mode 100644
index 000000000..697931a8b
--- /dev/null
+++ b/src/main/java/forestry/apiculture/render/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.render;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/tiles/FakeBeeHousingInventory.java b/src/main/java/forestry/apiculture/tiles/FakeBeeHousingInventory.java
index 734368368..03cb8ed07 100644
--- a/src/main/java/forestry/apiculture/tiles/FakeBeeHousingInventory.java
+++ b/src/main/java/forestry/apiculture/tiles/FakeBeeHousingInventory.java
@@ -1,13 +1,10 @@
package forestry.apiculture.tiles;
-import javax.annotation.Nonnull;
-
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.IBeeHousingInventory;
public class FakeBeeHousingInventory implements IBeeHousingInventory {
- @Nonnull
public static final FakeBeeHousingInventory instance = new FakeBeeHousingInventory();
private FakeBeeHousingInventory() {
@@ -16,12 +13,12 @@ public class FakeBeeHousingInventory implements IBeeHousingInventory {
@Override
public ItemStack getQueen() {
- return null;
+ return ItemStack.EMPTY;
}
@Override
public ItemStack getDrone() {
- return null;
+ return ItemStack.EMPTY;
}
@Override
diff --git a/src/main/java/forestry/apiculture/tiles/HiveBeeHousingInventory.java b/src/main/java/forestry/apiculture/tiles/HiveBeeHousingInventory.java
index dad680c90..7dd343438 100644
--- a/src/main/java/forestry/apiculture/tiles/HiveBeeHousingInventory.java
+++ b/src/main/java/forestry/apiculture/tiles/HiveBeeHousingInventory.java
@@ -1,6 +1,6 @@
package forestry.apiculture.tiles;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
@@ -10,12 +10,14 @@ import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousingInventory;
class HiveBeeHousingInventory implements IBeeHousingInventory {
+ @Nullable
private ItemStack queen;
+ @Nullable
private ItemStack drone;
private final TileHive hive;
- public HiveBeeHousingInventory(@Nonnull TileHive hive) {
+ public HiveBeeHousingInventory(TileHive hive) {
this.hive = hive;
}
@@ -23,9 +25,7 @@ class HiveBeeHousingInventory implements IBeeHousingInventory {
public ItemStack getQueen() {
if (queen == null) {
IBee bee = hive.getContainedBee();
- if (bee != null) {
- queen = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.QUEEN);
- }
+ queen = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.QUEEN);
}
return queen;
}
@@ -34,9 +34,7 @@ class HiveBeeHousingInventory implements IBeeHousingInventory {
public ItemStack getDrone() {
if (drone == null) {
IBee bee = hive.getContainedBee();
- if (bee != null) {
- drone = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
- }
+ drone = BeeManager.beeRoot.getMemberStack(bee, EnumBeeType.DRONE);
}
return drone;
}
diff --git a/src/main/java/forestry/apiculture/tiles/TileApiary.java b/src/main/java/forestry/apiculture/tiles/TileApiary.java
index 2b5bcd887..1c7f15c43 100644
--- a/src/main/java/forestry/apiculture/tiles/TileApiary.java
+++ b/src/main/java/forestry/apiculture/tiles/TileApiary.java
@@ -10,14 +10,11 @@
******************************************************************************/
package forestry.apiculture.tiles;
-import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import net.minecraft.entity.player.EntityPlayer;
-
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
@@ -29,13 +26,11 @@ import forestry.apiculture.gui.ContainerBeeHousing;
import forestry.apiculture.gui.GuiBeeHousing;
import forestry.apiculture.inventory.IApiaryInventory;
import forestry.apiculture.inventory.InventoryApiary;
+import net.minecraft.entity.player.EntityPlayer;
public class TileApiary extends TileBeeHousingBase implements IApiary {
- @Nonnull
private final IBeeModifier beeModifier = new ApiaryBeeModifier();
- @Nonnull
private final IBeeListener beeListener = new ApiaryBeeListener(this);
- @Nonnull
private final InventoryApiary inventory = new InventoryApiary();
public TileApiary() {
@@ -43,7 +38,6 @@ public class TileApiary extends TileBeeHousingBase implements IApiary {
setInternalInventory(inventory);
}
- @Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
diff --git a/src/main/java/forestry/apiculture/tiles/TileBeeHouse.java b/src/main/java/forestry/apiculture/tiles/TileBeeHouse.java
index bfc72e184..4ab649787 100644
--- a/src/main/java/forestry/apiculture/tiles/TileBeeHouse.java
+++ b/src/main/java/forestry/apiculture/tiles/TileBeeHouse.java
@@ -10,11 +10,8 @@
******************************************************************************/
package forestry.apiculture.tiles;
-import javax.annotation.Nonnull;
import java.util.Collections;
-import net.minecraft.entity.player.EntityPlayer;
-
import forestry.api.apiculture.DefaultBeeListener;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
@@ -23,14 +20,12 @@ import forestry.apiculture.BeehouseBeeModifier;
import forestry.apiculture.InventoryBeeHousing;
import forestry.apiculture.gui.ContainerBeeHousing;
import forestry.apiculture.gui.GuiBeeHousing;
+import net.minecraft.entity.player.EntityPlayer;
public class TileBeeHouse extends TileBeeHousingBase {
- @Nonnull
private static final IBeeModifier beeModifier = new BeehouseBeeModifier();
- @Nonnull
private final IBeeListener beeListener;
- @Nonnull
private final InventoryBeeHousing beeInventory;
public TileBeeHouse() {
@@ -42,7 +37,6 @@ public class TileBeeHouse extends TileBeeHousingBase {
setInternalInventory(beeInventory);
}
- @Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return beeInventory;
diff --git a/src/main/java/forestry/apiculture/tiles/TileBeeHousingBase.java b/src/main/java/forestry/apiculture/tiles/TileBeeHousingBase.java
index a0b4467db..5408e7cfc 100644
--- a/src/main/java/forestry/apiculture/tiles/TileBeeHousingBase.java
+++ b/src/main/java/forestry/apiculture/tiles/TileBeeHousingBase.java
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture.tiles;
-import javax.annotation.Nonnull;
import java.io.IOException;
import com.mojang.authlib.GameProfile;
@@ -22,9 +21,8 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.apiculture.gui.IGuiBeeHousingInventory;
-import forestry.core.network.DataInputStreamForestry;
-import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamableGui;
+import forestry.core.network.PacketBufferForestry;
import forestry.core.owner.IOwnedTile;
import forestry.core.owner.IOwnerHandler;
import forestry.core.owner.OwnerHandler;
@@ -55,7 +53,6 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
}
/* LOADING & SAVING */
- @Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -71,7 +68,6 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
ownerHandler.readFromNBT(nbttagcompound);
}
- @Nonnull
@Override
public NBTTagCompound getUpdateTag() {
NBTTagCompound updateTag = super.getUpdateTag();
@@ -81,7 +77,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
}
@Override
- public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
+ public void handleUpdateTag(NBTTagCompound tag) {
super.handleUpdateTag(tag);
beeLogic.readFromNBT(tag);
ownerHandler.readFromNBT(tag);
@@ -95,7 +91,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
/* ICLIMATISED */
@Override
public EnumTemperature getTemperature() {
- return EnumTemperature.getFromBiome(getBiome(), worldObj, getPos());
+ return EnumTemperature.getFromBiome(getBiome(), world, getPos());
}
@Override
@@ -105,12 +101,12 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
@Override
public float getExactTemperature() {
- return ForestryAPI.climateManager.getTemperature(worldObj, getPos());
+ return ForestryAPI.climateManager.getTemperature(world, getPos());
}
@Override
public float getExactHumidity() {
- return ForestryAPI.climateManager.getHumidity(worldObj, getPos());
+ return ForestryAPI.climateManager.getHumidity(world, getPos());
}
/* UPDATING */
@@ -120,7 +116,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
beeLogic.doBeeFX();
if (updateOnInterval(50)) {
- doPollenFX(worldObj, getPos().getX(), getPos().getY(), getPos().getZ());
+ doPollenFX(world, getPos().getX(), getPos().getY(), getPos().getZ());
}
}
}
@@ -153,19 +149,19 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
}
@Override
- public void writeGuiData(DataOutputStreamForestry data) throws IOException {
+ public void writeGuiData(PacketBufferForestry data) {
data.writeVarInt(beeLogic.getBeeProgressPercent());
- IClimatePosition position = ForestryAPI.climateManager.getPosition(worldObj, getPos());
- if(position != null){
+ IClimatePosition position = ForestryAPI.climateManager.getPosition(world, getPos());
+ if (position != null) {
ClimateUtil.writePositionData(position, data);
}
}
@Override
- public void readGuiData(DataInputStreamForestry data) throws IOException {
+ public void readGuiData(PacketBufferForestry data) throws IOException {
breedingProgressPercent = data.readVarInt();
- IClimatePosition position = ForestryAPI.climateManager.getPosition(worldObj, getPos());
- if(position != null){
+ IClimatePosition position = ForestryAPI.climateManager.getPosition(world, getPos());
+ if (position != null) {
ClimateUtil.readPositionData(position, data);
}
}
@@ -173,22 +169,22 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
// / IBEEHOUSING
@Override
public Biome getBiome() {
- return worldObj.getBiome(getPos());
+ return world.getBiome(getPos());
}
@Override
public int getBlockLightValue() {
- return worldObj.getLightFromNeighbors(getPos().up());
+ return world.getLightFromNeighbors(getPos().up());
}
@Override
public boolean canBlockSeeTheSky() {
- return worldObj.canBlockSeeSky(getPos().up());
+ return world.canBlockSeeSky(getPos().up());
}
-
+
@Override
public boolean isRaining() {
- return worldObj.isRainingAt(getPos().up());
+ return world.isRainingAt(getPos().up());
}
@Override
diff --git a/src/main/java/forestry/apiculture/tiles/TileCandle.java b/src/main/java/forestry/apiculture/tiles/TileCandle.java
index a0c005986..c1a6c7340 100644
--- a/src/main/java/forestry/apiculture/tiles/TileCandle.java
+++ b/src/main/java/forestry/apiculture/tiles/TileCandle.java
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.apiculture.tiles;
-import javax.annotation.Nonnull;
-
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
@@ -21,7 +19,6 @@ public class TileCandle extends TileEntity {
private int colour;
private boolean lit;
- @Nonnull
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
return new SPacketUpdateTileEntity(getPos(), 0, getUpdateTag());
@@ -34,7 +31,6 @@ public class TileCandle extends TileEntity {
handleUpdateTag(nbt);
}
- @Nonnull
@Override
public NBTTagCompound getUpdateTag() {
NBTTagCompound tag = super.getUpdateTag();
@@ -42,7 +38,7 @@ public class TileCandle extends TileEntity {
}
@Override
- public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
+ public void handleUpdateTag( NBTTagCompound tag) {
super.handleUpdateTag(tag);
readFromNBT(tag);
}
@@ -59,7 +55,6 @@ public class TileCandle extends TileEntity {
lit = tagRoot.getBoolean("lit");
}
- @Nonnull
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagRoot) {
tagRoot = super.writeToNBT(tagRoot);
diff --git a/src/main/java/forestry/apiculture/tiles/TileHive.java b/src/main/java/forestry/apiculture/tiles/TileHive.java
index a8392e4e8..fbd4cefe9 100644
--- a/src/main/java/forestry/apiculture/tiles/TileHive.java
+++ b/src/main/java/forestry/apiculture/tiles/TileHive.java
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture.tiles;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
@@ -69,17 +68,13 @@ import net.minecraft.world.biome.Biome;
public class TileHive extends TileEntity implements ITickable, IHiveTile, IActivatable, IBeeHousing {
private static final DamageSource damageSourceBeeHive = new DamageSourceForestry("bee.hive");
- @Nonnull
private final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
- @Nonnull
private final HiveBeeHousingInventory inventory;
- @Nonnull
private final BeekeepingLogic beeLogic;
- @Nonnull
private final IErrorLogic errorLogic;
- @Nonnull
private final Predicate beeTargetPredicate;
+ @Nullable
private IBee containedBee = null;
private boolean active = false;
private boolean angry = false;
@@ -104,11 +99,11 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
return;
}
- if (worldObj.isRemote) {
- if (!updatedLight && worldObj.getWorldTime() % 100 == 0) {
- updatedLight = worldObj.checkLightFor(EnumSkyBlock.BLOCK, getPos());
+ if (world.isRemote) {
+ if (!updatedLight && world.getWorldTime() % 100 == 0) {
+ updatedLight = world.checkLightFor(EnumSkyBlock.BLOCK, getPos());
}
- if (active && worldObj.rand.nextInt(4) == 0) {
+ if (active && world.rand.nextInt(4) == 0) {
if (beeLogic.canDoBeeFX()) {
beeLogic.doBeeFX();
}
@@ -116,11 +111,11 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
} else {
boolean canWork = beeLogic.canWork(); // must be called every tick to stay updated
- if (worldObj.rand.nextInt(angry ? 10 : 200) == 0) {
+ if (world.rand.nextInt(angry ? 10 : 200) == 0) {
if (calmTime == 0) {
if (canWork) {
AxisAlignedBB boundingBox = AlleleEffect.getBounding(getContainedBee().getGenome(), this);
- List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox, beeTargetPredicate);
+ List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox, beeTargetPredicate);
if (!entities.isEmpty()) {
Collections.shuffle(entities);
EntityLivingBase entity = entities.get(0);
@@ -141,7 +136,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
if (this.containedBee == null) {
IBeeGenome beeGenome = null;
ItemStack containedBee = contained.getStackInSlot(0);
- if (containedBee != null) {
+ if (!containedBee.isEmpty()) {
IBee bee = BeeManager.beeRoot.getMember(containedBee);
if (bee != null) {
beeGenome = bee.getGenome();
@@ -158,25 +153,24 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
return this.containedBee;
}
+ @Nullable
private IBeeGenome getGenomeFromBlock() {
- IBlockState blockState = worldObj.getBlockState(pos);
- if (blockState != null) {
+ if (world.isBlockLoaded(pos)) {
+ IBlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
if (block instanceof BlockBeeHives) {
IHiveRegistry.HiveType hiveType = BlockBeeHives.getHiveType(blockState);
- if (hiveType != null) {
- String speciesUid = hiveType.getSpeciesUid();
- IAllele[] template = BeeManager.beeRoot.getTemplate(speciesUid);
- if (template != null) {
- return BeeManager.beeRoot.templateAsGenome(template);
- }
+ String speciesUid = hiveType.getSpeciesUid();
+ IAllele[] template = BeeManager.beeRoot.getTemplate(speciesUid);
+ if (template != null) {
+ return BeeManager.beeRoot.templateAsGenome(template);
}
}
}
return null;
}
- public void setContained(@Nonnull List bees) {
+ public void setContained(List bees) {
for (ItemStack itemstack : bees) {
InventoryUtil.addStack(contained, itemstack, true);
}
@@ -189,7 +183,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
beeLogic.readFromNBT(nbttagcompound);
}
- @Nonnull
+
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
@@ -226,19 +220,19 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
if (canHarvest) {
for (ItemStack beeStack : InventoryUtil.getStacks(contained)) {
if (beeStack != null) {
- ItemStackUtil.dropItemStackAsEntity(beeStack, worldObj, pos);
+ ItemStackUtil.dropItemStackAsEntity(beeStack, world, pos);
}
}
}
}
private static void attack(EntityLivingBase entity, int maxDamage) {
- double attackAmount = entity.worldObj.rand.nextDouble() / 2.0 + 0.5;
+ double attackAmount = entity.world.rand.nextDouble() / 2.0 + 0.5;
int damage = (int) (attackAmount * maxDamage);
if (damage > 0) {
// Entities are not attacked if they wear a full set of apiarist's armor.
int count = BeeManager.armorApiaristHelper.wearsItems(entity, damageSourceBeeHive.damageType, true);
- if (entity.worldObj.rand.nextInt(4) >= count) {
+ if (entity.world.rand.nextInt(4) >= count) {
entity.attackEntityFrom(damageSourceBeeHive, damage);
}
}
@@ -256,8 +250,8 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
}
this.active = active;
- if (!worldObj.isRemote) {
- Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
+ if (!world.isRemote) {
+ Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), pos, world);
}
}
@@ -267,7 +261,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
return new SPacketUpdateTileEntity(pos, 0, getUpdateTag());
}
- @Nonnull
+
@Override
public NBTTagCompound getUpdateTag() {
NBTTagCompound nbt = super.getUpdateTag();
@@ -277,7 +271,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
}
@Override
- public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
+ public void handleUpdateTag(NBTTagCompound tag) {
super.handleUpdateTag(tag);
setActive(tag.getBoolean("active"));
beeLogic.readFromNBT(tag);
@@ -300,7 +294,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
return Collections.emptyList();
}
- @Nonnull
+
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
@@ -331,15 +325,15 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
public boolean canBlockSeeTheSky() {
return true; // hives may have the sky obstructed but should still be active
}
-
+
@Override
public boolean isRaining() {
- return worldObj.isRainingAt(getPos().up());
+ return world.isRainingAt(getPos().up());
}
@Override
public World getWorldObj() {
- return worldObj;
+ return world;
}
@Override
@@ -348,6 +342,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
}
@Override
+ @Nullable
public GameProfile getOwner() {
return null;
}
@@ -358,7 +353,6 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
return new Vec3d(pos.getX() + 0.5, pos.getY() + 0.25, pos.getZ() + 0.5);
}
- @Nonnull
@Override
public IErrorLogic getErrorLogic() {
return errorLogic;
@@ -370,10 +364,10 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
}
private static class BeeTargetPredicate implements Predicate {
- @Nonnull
+
private final IHiveTile hive;
- public BeeTargetPredicate(@Nonnull IHiveTile hive) {
+ public BeeTargetPredicate(IHiveTile hive) {
this.hive = hive;
}
diff --git a/src/main/java/forestry/apiculture/tiles/package-info.java b/src/main/java/forestry/apiculture/tiles/package-info.java
new file mode 100644
index 000000000..edf75b3b5
--- /dev/null
+++ b/src/main/java/forestry/apiculture/tiles/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.tiles;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/trigger/package-info.java b/src/main/java/forestry/apiculture/trigger/package-info.java
new file mode 100644
index 000000000..3d53ea468
--- /dev/null
+++ b/src/main/java/forestry/apiculture/trigger/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.trigger;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/apiculture/worldgen/Hive.java b/src/main/java/forestry/apiculture/worldgen/Hive.java
index 358ec70b7..067bec4c7 100644
--- a/src/main/java/forestry/apiculture/worldgen/Hive.java
+++ b/src/main/java/forestry/apiculture/worldgen/Hive.java
@@ -31,9 +31,6 @@ public final class Hive {
private final List drops = new ArrayList<>();
public Hive(IHiveDescription hiveDescription) {
- if (hiveDescription == null) {
- throw new IllegalArgumentException("Tried to create hive with null hive description");
- }
this.hiveDescription = hiveDescription;
}
diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDescription.java b/src/main/java/forestry/apiculture/worldgen/HiveDescription.java
index df6fe262c..fa4aa451c 100644
--- a/src/main/java/forestry/apiculture/worldgen/HiveDescription.java
+++ b/src/main/java/forestry/apiculture/worldgen/HiveDescription.java
@@ -65,7 +65,7 @@ public enum HiveDescription implements IHiveDescription {
END(IHiveRegistry.HiveType.END, 2.0f, BeeDefinition.ENDED, HiveManager.genHelper.ground(Blocks.END_STONE, Blocks.END_BRICKS)) {
@Override
public boolean isGoodBiome(Biome biome) {
- return BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.END);
+ return BiomeDictionary.hasType(biome, BiomeDictionary.Type.END);
}
},
SNOW(IHiveRegistry.HiveType.SNOW, 2.0f, BeeDefinition.WINTRY, HiveManager.genHelper.ground(Blocks.DIRT, Blocks.GRASS, Blocks.SNOW)) {
diff --git a/src/main/java/forestry/apiculture/worldgen/VillageApiaristHouse.java b/src/main/java/forestry/apiculture/worldgen/VillageApiaristHouse.java
index f8bea0fee..cd35e92df 100644
--- a/src/main/java/forestry/apiculture/worldgen/VillageApiaristHouse.java
+++ b/src/main/java/forestry/apiculture/worldgen/VillageApiaristHouse.java
@@ -10,7 +10,7 @@
******************************************************************************/
package forestry.apiculture.worldgen;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -107,6 +107,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
this.fenceGate = woodAccess.getBlock(woodType, WoodBlockKind.FENCE_GATE, fireproof);
}
+ @Nullable
public static VillageApiaristHouse buildComponent(StructureVillagePieces.Start startPiece, List pieces, Random random, int structureMinX, int structureMinY, int structureMinZ, EnumFacing facing, int componentType) {
StructureBoundingBox bbox = StructureBoundingBox.getComponentToAddBoundingBox(structureMinX, structureMinY, structureMinZ, -4, 0, 0, 12, 9, 12, facing);
if (!canVillageGoDeeper(bbox) || StructureComponent.findIntersecting(pieces, bbox) != null) {
@@ -117,7 +118,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
}
@Override
- public boolean addComponentParts(@Nonnull World world, @Nonnull Random random, @Nonnull StructureBoundingBox structBoundingBox) {
+ public boolean addComponentParts(World world, Random random, StructureBoundingBox structBoundingBox) {
if (averageGroundLevel < 0) {
averageGroundLevel = getAverageGroundLevel(world, structBoundingBox);
@@ -165,7 +166,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
fillWithBlocks(world, structBoundingBox, 8, 3, 0, 8, 3, 5, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 1, 2, 0, 7, 3, 0, planks, planks, false);
fillWithBlocks(world, structBoundingBox, 1, 2, 5, 7, 3, 5, planks, planks, false);
-
+
// Ceiling
IBlockState slabCeiling = slabs.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
fillWithBlocks(world, structBoundingBox, 1, 4, 1, 7, 4, 4, slabCeiling, slabCeiling, false);
diff --git a/src/main/java/forestry/apiculture/worldgen/package-info.java b/src/main/java/forestry/apiculture/worldgen/package-info.java
new file mode 100644
index 000000000..f0db835b3
--- /dev/null
+++ b/src/main/java/forestry/apiculture/worldgen/package-info.java
@@ -0,0 +1,9 @@
+@ParametersAreNonnullByDefault
+@FieldsAreNonnullByDefault
+@MethodsReturnNonnullByDefault
+package forestry.apiculture.worldgen;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
+import forestry.core.utils.FieldsAreNonnullByDefault;
+import mcp.MethodsReturnNonnullByDefault;
\ No newline at end of file
diff --git a/src/main/java/forestry/arboriculture/CamouflageHandlerArbDoor.java b/src/main/java/forestry/arboriculture/CamouflageHandlerArbDoor.java
index 2472490e0..81a49cb11 100644
--- a/src/main/java/forestry/arboriculture/CamouflageHandlerArbDoor.java
+++ b/src/main/java/forestry/arboriculture/CamouflageHandlerArbDoor.java
@@ -10,13 +10,12 @@
******************************************************************************/
package forestry.arboriculture;
+import com.google.common.base.Preconditions;
import forestry.api.core.CamouflageManager;
import forestry.api.core.ICamouflageHandler;
import forestry.api.core.ICamouflageItemHandler;
import forestry.api.core.ICamouflagedTile;
import forestry.arboriculture.items.ItemBlockWoodDoor;
-import org.apache.commons.lang3.tuple.Pair;
-
import net.minecraft.block.BlockDoor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@@ -25,21 +24,15 @@ import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
-
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.apache.commons.lang3.tuple.Pair;
public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
@Override
public boolean canHandle(ItemStack stack) {
- if(stack == null || stack.getItem() == null || stack.stackSize <= 0){
- return false;
- }
- if(stack.getItem() instanceof ItemBlockWoodDoor){
- return true;
- }
- return false;
+ return stack.getItem() instanceof ItemBlockWoodDoor;
}
@Override
@@ -55,9 +48,9 @@ public class CamouflageHandlerArbDoor implements ICamouflageItemHandler {
@SideOnly(Side.CLIENT)
@Override
public Pair getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile) {
- if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemBlockWoodDoor)){
- return null;
- }
+ Preconditions.checkArgument(!stack.isEmpty(), "Stack must not be empty");
+ Preconditions.checkArgument(stack.getItem() instanceof ItemBlockWoodDoor, "Item must be ItemBlockWoodDoor");
+
World world = camouflageHandler.getWorldObj();
BlockPos pos = camouflageTile.getCoordinates();
IBlockState blockState = world.getBlockState(pos);
diff --git a/src/main/java/forestry/arboriculture/FruitProviderNone.java b/src/main/java/forestry/arboriculture/FruitProviderNone.java
index 561a8d025..caacd2cfb 100755
--- a/src/main/java/forestry/arboriculture/FruitProviderNone.java
+++ b/src/main/java/forestry/arboriculture/FruitProviderNone.java
@@ -10,27 +10,25 @@
******************************************************************************/
package forestry.arboriculture;
-import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Random;
-import net.minecraft.client.renderer.texture.TextureMap;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.IBlockAccess;
-import net.minecraft.world.World;
-
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.genetics.IFruitFamily;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Translator;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
public class FruitProviderNone implements IFruitProvider {
@@ -59,6 +57,7 @@ public class FruitProviderNone implements IFruitProvider {
protected int ripeningPeriod = 10;
+ @Nullable
private OverlayType overlay = null;
public FruitProviderNone(String unlocalizedDescription, IFruitFamily family) {
@@ -76,10 +75,9 @@ public class FruitProviderNone implements IFruitProvider {
return family;
}
- @Nonnull
@Override
- public List getFruits(ITreeGenome genome, World world, BlockPos pos, int ripeningTime) {
- return Collections.emptyList();
+ public NonNullList getFruits(ITreeGenome genome, World world, BlockPos pos, int ripeningTime) {
+ return NonNullList.create();
}
@Override
@@ -112,13 +110,11 @@ public class FruitProviderNone implements IFruitProvider {
return ripeningPeriod;
}
- @Nonnull
@Override
public Map getProducts() {
return Collections.emptyMap();
}
- @Nonnull
@Override
public Map getSpecialty() {
return Collections.emptyMap();
@@ -161,7 +157,6 @@ public class FruitProviderNone implements IFruitProvider {
return null;
}
- @Nonnull
@Override
public String getModID() {
return Constants.MOD_ID;
diff --git a/src/main/java/forestry/arboriculture/FruitProviderPod.java b/src/main/java/forestry/arboriculture/FruitProviderPod.java
index 1f5f7ecf6..5a9ce44c3 100755
--- a/src/main/java/forestry/arboriculture/FruitProviderPod.java
+++ b/src/main/java/forestry/arboriculture/FruitProviderPod.java
@@ -10,16 +10,15 @@
******************************************************************************/
package forestry.arboriculture;
-import javax.annotation.Nonnull;
-import java.util.ArrayList;
+import javax.annotation.Nullable;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
@@ -43,7 +42,7 @@ public class FruitProviderPod extends FruitProviderNone {
}
private final EnumPodType type;
- @Nonnull
+
private final Map drops;
public FruitProviderPod(String unlocalizedDescription, IFruitFamily family, EnumPodType type, ItemStack... dropOnMature) {
@@ -60,22 +59,21 @@ public class FruitProviderPod extends FruitProviderNone {
return true;
}
- @Nonnull
@Override
- public List getFruits(ITreeGenome genome, World world, BlockPos pos, int ripeningTime) {
+ public NonNullList getFruits(@Nullable ITreeGenome genome, World world, BlockPos pos, int ripeningTime) {
if (drops.isEmpty()) {
- return Collections.emptyList();
+ return NonNullList.create();
}
if (ripeningTime >= 2) {
- List drops = new ArrayList<>();
+ NonNullList drops = NonNullList.create();
for (ItemStack aDrop : this.drops.keySet()) {
drops.add(aDrop.copy());
}
return drops;
}
- return Collections.emptyList();
+ return NonNullList.create();
}
@Override
@@ -89,7 +87,7 @@ public class FruitProviderPod extends FruitProviderNone {
return BlockUtil.tryPlantCocoaPod(world, pos);
} else {
IAlleleFruit activeAllele = (IAlleleFruit) genome.getActiveAllele(EnumTreeChromosome.FRUITS);
- return TreeManager.treeRoot.setFruitBlock(world, activeAllele, genome.getSappiness(), pos);
+ return TreeManager.treeRoot.setFruitBlock(world, genome, activeAllele, genome.getSappiness(), pos);
}
}
@@ -102,8 +100,7 @@ public class FruitProviderPod extends FruitProviderNone {
public ResourceLocation getDecorativeSprite() {
return null;
}
-
- @Nonnull
+
@Override
public Map getProducts() {
return Collections.unmodifiableMap(drops);
@@ -112,11 +109,9 @@ public class FruitProviderPod extends FruitProviderNone {
@Override
public void registerSprites() {
}
-
- @Nonnull
+
@Override
public String getModelName() {
return type.getModelName();
}
-
}
diff --git a/src/main/java/forestry/arboriculture/FruitProviderRandom.java b/src/main/java/forestry/arboriculture/FruitProviderRandom.java
index 56c35c7bd..34acd6865 100755
--- a/src/main/java/forestry/arboriculture/FruitProviderRandom.java
+++ b/src/main/java/forestry/arboriculture/FruitProviderRandom.java
@@ -10,15 +10,13 @@
******************************************************************************/
package forestry.arboriculture;
-import javax.annotation.Nonnull;
import java.awt.Color;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -31,8 +29,6 @@ import forestry.api.genetics.IFruitFamily;
* Simple fruit provider which drops from any leaf block according to yield and either marks all leave blocks as fruit leaves or none.
*/
public class FruitProviderRandom extends FruitProviderNone {
-
- @Nonnull
private final Map products = new HashMap<>();
private int colour = 0xffffff;
@@ -56,10 +52,9 @@ public class FruitProviderRandom extends FruitProviderNone {
return colour;
}
- @Nonnull
@Override
- public List getFruits(ITreeGenome genome, World world, BlockPos pos, int ripeningTime) {
- List product = new ArrayList<>();
+ public NonNullList getFruits(ITreeGenome genome, World world, BlockPos pos, int ripeningTime) {
+ NonNullList product = NonNullList.create();
float modeYieldMod = TreeManager.treeRoot.getTreekeepingMode(world).getYieldModifier(genome, 1f);
@@ -72,7 +67,6 @@ public class FruitProviderRandom extends FruitProviderNone {
return product;
}
- @Nonnull
@Override
public Map getProducts() {
return Collections.unmodifiableMap(products);
diff --git a/src/main/java/forestry/arboriculture/FruitProviderRipening.java b/src/main/java/forestry/arboriculture/FruitProviderRipening.java
index 25038f666..50b4fa450 100755
--- a/src/main/java/forestry/arboriculture/FruitProviderRipening.java
+++ b/src/main/java/forestry/arboriculture/FruitProviderRipening.java
@@ -10,15 +10,13 @@
******************************************************************************/
package forestry.arboriculture;
-import javax.annotation.Nonnull;
import java.awt.Color;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -28,12 +26,8 @@ import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IFruitFamily;
public class FruitProviderRipening extends FruitProviderNone {
-
- @Nonnull
private final Map