Compare commits

...
34 Commits
Author SHA1 Message Date
mezz 40eece7d77 Fix bee carts dropping invalid item when broken 2016-06-28 13:01:39 -07:00
mezz 4fcc785e85 Make Escritoire give unlearned mutation notes first 2016-06-28 02:24:00 -07:00
mezz 11e4097bd8 Use List in the API where appropriate 2016-06-28 02:10:03 -07:00
mezz f8c37da06d Improve escritoire responsiveness on slow networks or laggy servers 2016-06-28 01:54:32 -07:00
mezz 09756f21fd Fix grafter break sounds and animation on Forestry leaves
(no fix for vanilla leaves, the harvest event is fired server-side only)
2016-06-25 01:37:44 -07:00
mezz a06c4bd1dc Make grafter work on vanilla leaves 2016-06-25 01:36:33 -07:00
mezz bb477f0dfb Add tooltip for grafter use count on a new grafter 2016-06-25 00:34:51 -07:00
mezz 0b86b3df8f Buff the grafter slightly from 5 uses to 10 uses 2016-06-25 00:34:31 -07:00
mezz edd5357008 Make princess bee crown silver to stand out better 2016-06-25 00:23:24 -07:00
mezz dfb4e04f4a Update Forge 2016-06-25 00:04:26 -07:00
mezz 45c0375387 Fix bee particles becoming active at night when hive is opened 2016-06-25 00:04:11 -07:00
mezz 5e4cfa5112 Add oredict for charcoal 2016-06-25 00:03:16 -07:00
mezz 086b53e4a3 Add beetroot seeds to the squeezer for seed oil 2016-06-24 19:29:02 -07:00
mezz fbb5612b8c Slightly improve the look of larch bark 2016-06-24 19:21:54 -07:00
mezz c3c471ab33 Fix localization for backpack modes 2016-06-24 18:32:48 -07:00
mezz 67ddc252aa Stop Balsa leaves from generating infinitely downwards 2016-06-24 16:50:01 -07:00
mezz 59945a8961 Change name of "managed" farm to "automatic" 2016-06-24 16:40:57 -07:00
mezz bbabb967b1 Fix localization of latticed heath butterfly and ash pile 2016-06-24 16:34:52 -07:00
mezz 4cb1ee4cb1 Simply tree genomes, move charcoal properties to Species 2016-06-24 16:00:11 -07:00
mezz 95135544e2 Fix #1330 Fix resource checks for resources below an Alveary 2016-06-23 15:31:36 -07:00
mezz e34b71c13e Update dependencies 2016-06-23 14:51:32 -07:00
mezz cc8bcf384a Fix rare crash when getting rewards from escritoire 2016-06-23 14:51:12 -07:00
mezz 1f21952beb Fix #1328 Crash when trying to pick up wheat from Moistener process slot 2016-06-23 14:50:35 -07:00
mezz 1ed4ced65f Remove "useDepAts = true" in gradle, it's no longer needed for JEI's API 2016-06-23 02:54:25 -07:00
mezz beb74e635d Use JEI API jar at compile time 2016-06-23 02:34:50 -07:00
mezz 40c4fc5d1f Update for Minecraft 1.10 2016-06-23 02:19:36 -07:00
mezz 645dba903d Improve the look of cherry tree leaf generation 2016-06-22 21:14:38 -07:00
mezz 1ac4acdb47 Fix ebony trees growing offcenter from their saplings 2016-06-22 21:13:52 -07:00
mezz 74aa33e80c Remove all the saplings when a large tree grows 2016-06-22 21:13:35 -07:00
mezz 6f6b45abcf Add EnderIO compat for ice coolant and ethanol fuel 2016-06-22 19:00:05 -07:00
mezz 7297a6a5d3 Add ExtraUtils2 EnderLily compat for the farm 2016-06-22 18:40:07 -07:00
mezz 5ef76cffca Fix invalid recipes warning when BoP plugin is enabled 2016-06-22 16:19:40 -07:00
mezz 9284f84645 Fix pipette filling bug 2016-06-22 16:18:55 -07:00
mezz 85ba33e1ff Add trapdoorWood oredict name 2016-06-20 23:11:44 -07:00
105 changed files with 1216 additions and 1260 deletions

No files matched your search

+2 -2
View File
@@ -40,7 +40,6 @@ targetCompatibility = 1.8
minecraft {
version = mcversion + "-" + forgeversion
runDir = "run"
useDepAts = true
mappings = mcp_mappings
replace '@VERSION@', project.version
@@ -66,7 +65,8 @@ repositories {
}
dependencies {
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}"
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}:api"
runtime "mezz.jei:jei_${mcversion}:${jei_version}"
deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
}
+5 -5
View File
@@ -1,10 +1,10 @@
mcversion=1.9.4
forgeversion=12.17.0.1957
mcversion=1.10
forgeversion=12.18.0.1989-1.10.0
mcp_mappings=snapshot_20160525
jei_version=3.6.4.+
jei_version=3.7.0.+
ic2_version=2.5.5-ex19
version_major=5
version_minor=0
version_patch=20
version_minor=1
version_patch=7
+2 -2
View File
@@ -1,6 +1,6 @@
#Mon Sep 14 12:28:28 PDT 2015
#Tue Jun 21 15:23:47 PDT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip
+1 -1
Submodule lang updated: 9be86d3c99...2d88011e4a.
+3 -10
View File
@@ -49,16 +49,9 @@ import forestry.plugins.PluginManager;
name = "Forestry",
version = Constants.VERSION,
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
dependencies = "required-after:Forge@[12.17.0.1949,);"
+ "after:Buildcraft|Core@[7.2,);"
+ "after:BuildCraft|Energy@[7.2,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.3.235,);"
+ "after:Natura@[2.2.0,);"
+ "after:HardcoreEnderExpansion;"
+ "after:JEI@[3.6.4,);"
+ "after:basemetals;")
acceptedMinecraftVersions = "[1.10]",
dependencies = "required-after:Forge@[12.18.0.1989,);"
+ "after:JEI@[3.7.0,);")
public class Forestry {
@Mod.Instance(Constants.MOD_ID)
@@ -7,17 +7,15 @@ package forestry.api.apiculture;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot;
public interface IBeeRoot extends ISpeciesRoot {
/**
@@ -100,7 +98,7 @@ public interface IBeeRoot extends ISpeciesRoot {
/* MUTATIONS */
@Override
Collection<IBeeMutation> getMutations(boolean shuffle);
List<IBeeMutation> getMutations(boolean shuffle);
/* GAME MODE */
void resetBeekeepingMode();
@@ -5,12 +5,12 @@
******************************************************************************/
package forestry.api.apiculture;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
public interface IJubilanceFactory {
/** The default Jubilance Provider is satisfied when the humidity and temperature are ideal for the bee. */
IJubilanceProvider getDefault();
/** The Requires Resource Jubilance Provider is satisfied when a specific block is under the hive. */
IJubilanceProvider getRequiresResource(Block block, int meta);
IJubilanceProvider getRequiresResource(IBlockState... acceptedBlockStates);
}
@@ -10,28 +10,53 @@ import java.util.Locale;
import java.util.Random;
public enum EnumForestryWoodType implements IWoodType {
LARCH, TEAK, ACACIA, LIME,
CHESTNUT, WENGE, BAOBAB, SEQUOIA(4.0f),
LARCH(4, 20),
TEAK(4, 20),
ACACIA(4, 20),
LIME(4, 19),
CHESTNUT(4, 21),
WENGE(4, 20),
BAOBAB(4, 20),
SEQUOIA(3, 18, 4.0f),
KAPOK, EBONY, MAHOGANY, BALSA(1.0f),
WILLOW, WALNUT, GREENHEART(7.5f), CHERRY,
KAPOK(4, 20),
EBONY(4, 20),
MAHOGANY(4, 20),
BALSA(4, 20, 1.0f),
WILLOW(4, 20),
WALNUT(4, 21),
GREENHEART(4, 20, 7.5f),
CHERRY(4, 20),
MAHOE, POPLAR, PALM, PAPAYA,
PINE(3.0f), PLUM, MAPLE, CITRUS,
MAHOE(4, 20),
POPLAR(4, 20),
PALM(4, 20),
PAPAYA(4, 20),
PINE(4, 20, 3.0f),
PLUM(4, 20),
MAPLE(4, 20),
CITRUS(4, 20),
GIGANTEUM, IPE, PADAUK, COCOBOLO,
ZEBRAWOOD;
GIGANTEUM(3, 18, 4.0f),
IPE(4, 20),
PADAUK(4, 20),
COCOBOLO(4, 20),
ZEBRAWOOD(4, 20);
public static final float DEFAULT_HARDNESS = 2.0f;
public static final EnumForestryWoodType[] VALUES = values();
private final int carbonization;
private final int combustability;
private final float hardness;
EnumForestryWoodType() {
this(DEFAULT_HARDNESS);
EnumForestryWoodType(int carbonization, int combustability) {
this(carbonization, combustability, DEFAULT_HARDNESS);
}
EnumForestryWoodType(float hardness) {
EnumForestryWoodType(int carbonization, int combustability, float hardness) {
this.carbonization = carbonization;
this.combustability = combustability;
this.hardness = hardness;
}
@@ -66,4 +91,12 @@ public enum EnumForestryWoodType implements IWoodType {
}
return VALUES[meta];
}
public int getCarbonization() {
return carbonization;
}
public int getCombustability() {
return combustability;
}
}
@@ -7,8 +7,6 @@ package forestry.api.arboriculture;
import java.util.Locale;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleArea;
import forestry.api.genetics.IAlleleBoolean;
@@ -18,6 +16,7 @@ import forestry.api.genetics.IAllelePlantType;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IFruitFamily;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraftforge.common.EnumPlantType;
public enum EnumTreeChromosome implements IChromosomeType {
@@ -28,7 +27,9 @@ public enum EnumTreeChromosome implements IChromosomeType {
SPECIES(IAlleleTreeSpecies.class),
/**
* {@link IGrowthProvider}, determines conditions required by the tree to grow.
* @deprecated unused
*/
@Deprecated
GROWTH(IAlleleGrowth.class),
/**
* A float modifying the height of the tree. Taken into account at worldgen.
@@ -48,15 +49,19 @@ public enum EnumTreeChromosome implements IChromosomeType {
YIELD(IAlleleFloat.class),
/**
* May add additional tolerances for {@link EnumPlantType}.
* @deprecated this is tied to species directly
*/
@Deprecated
PLANT(IAllelePlantType.class),
/**
* Determines the speed at which fruit will ripen on this tree.
*/
SAPPINESS(IAlleleFloat.class),
/**
* Territory for leaf effects. Unused.
* Territory for leaf effects.
* @deprecated unused
*/
@Deprecated
TERRITORY(IAlleleArea.class),
/**
* Leaf effect. Unused.
@@ -70,11 +75,15 @@ public enum EnumTreeChromosome implements IChromosomeType {
GIRTH(IAlleleInteger.class),
/**
* The combustibility of the wood, when it burn to charcoal and the combustibility of the charcoal.
* @deprecated this is tied to species directly
*/
@Deprecated
COMBUSTIBILITY(IAlleleInteger.class),
/**
* The amount of charcoal that a wood pile ash drop;
* @deprecated this is tied to species directly
*/
@Deprecated
CARBONIZATION(IAlleleInteger.class),
/**
* Determines if the tree can burn.
@@ -7,12 +7,12 @@ import java.util.Random;
import net.minecraft.block.BlockPlanks;
public enum EnumVanillaWoodType implements IWoodType {
OAK(BlockPlanks.EnumType.OAK),
SPRUCE(BlockPlanks.EnumType.SPRUCE),
BIRCH(BlockPlanks.EnumType.BIRCH),
JUNGLE(BlockPlanks.EnumType.JUNGLE),
ACACIA(BlockPlanks.EnumType.ACACIA),
DARK_OAK(BlockPlanks.EnumType.DARK_OAK);
OAK(BlockPlanks.EnumType.OAK, 5, 20),
SPRUCE(BlockPlanks.EnumType.SPRUCE, 4, 19),
BIRCH(BlockPlanks.EnumType.BIRCH, 4, 19),
JUNGLE(BlockPlanks.EnumType.JUNGLE, 5, 20),
ACACIA(BlockPlanks.EnumType.ACACIA, 4, 20),
DARK_OAK(BlockPlanks.EnumType.DARK_OAK, 5, 20);
public static final EnumVanillaWoodType[] VALUES = values();
@@ -21,9 +21,13 @@ public enum EnumVanillaWoodType implements IWoodType {
}
private final BlockPlanks.EnumType vanillaType;
private final int carbonization;
private final int combustability;
EnumVanillaWoodType(BlockPlanks.EnumType vanillaType) {
EnumVanillaWoodType(BlockPlanks.EnumType vanillaType, int carbonization, int combustability) {
this.vanillaType = vanillaType;
this.carbonization = carbonization;
this.combustability = combustability;
}
public BlockPlanks.EnumType getVanillaType() {
@@ -57,4 +61,14 @@ public enum EnumVanillaWoodType implements IWoodType {
public float getHardness() {
return 2.0F;
}
@Override
public int getCarbonization() {
return carbonization;
}
@Override
public int getCombustability() {
return combustability;
}
}
@@ -10,6 +10,10 @@ import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
/**
* @deprecated this is being removed to simplify trees
*/
@Deprecated
public interface IGrowthProvider {
/**
@@ -25,8 +29,6 @@ public interface IGrowthProvider {
@Nullable
BlockPos canGrow(ITreeGenome genome, World world, BlockPos pos, int expectedGirth, int expectedHeight);
EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, BlockPos pos);
/**
* @return Short, human-readable identifier used in the treealyzer.
*/
@@ -7,24 +7,19 @@ package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.world.ITreeGenData;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.world.ITreeGenData;
public interface ITree extends IIndividual, ITreeGenData {
void mate(ITree other);
@@ -39,8 +34,6 @@ public interface ITree extends IIndividual, ITreeGenData {
ITreeGenome getMate();
EnumSet<EnumPlantType> getPlantTypes();
/**
* @since Forestry 4.0
*/
@@ -84,12 +77,7 @@ public interface ITree extends IIndividual, ITreeGenData {
* @return Integer denoting the size of the tree trunk.
*/
@Override
int getGirth(World world, BlockPos pos);
/**
* @return Growth conditions at the given position.
*/
EnumGrowthConditions getGrowthCondition(World world, BlockPos pos);
int getGirth();
WorldGenerator getTreeGenerator(World world, BlockPos pos, boolean wasBonemealed);
@@ -6,9 +6,6 @@
package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.genetics.IGenome;
@@ -23,8 +20,6 @@ public interface ITreeGenome extends IGenome {
@Nonnull
IFruitProvider getFruitProvider();
IGrowthProvider getGrowthProvider();
float getHeight();
float getFertility();
@@ -37,18 +32,12 @@ public interface ITreeGenome extends IGenome {
float getSappiness();
EnumSet<EnumPlantType> getPlantTypes();
/**
* @return Amount of random block ticks required for a sapling to mature into a fully grown tree.
*/
int getMaturationTime();
int getGirth();
int getCombustibility();
int getCarbonization();
IAlleleLeafEffect getEffect();
}
@@ -8,18 +8,17 @@ package forestry.api.arboriculture;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.ISpeciesRoot;
public interface ITreeRoot extends ISpeciesRoot {
@Override
@@ -82,7 +81,7 @@ public interface ITreeRoot extends ISpeciesRoot {
boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, BlockPos pos);
/* GAME MODE */
ArrayList<ITreekeepingMode> getTreekeepingModes();
List<ITreekeepingMode> getTreekeepingModes();
ITreekeepingMode getTreekeepingMode(World world);
@@ -98,6 +97,5 @@ public interface ITreeRoot extends ISpeciesRoot {
/* MUTATIONS */
@Override
Collection<ITreeMutation> getMutations(boolean shuffle);
List<ITreeMutation> getMutations(boolean shuffle);
}
@@ -7,12 +7,12 @@ package forestry.api.arboriculture;
import javax.annotation.Nonnull;
import forestry.api.core.ITextureManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
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.ITextureManager;
public interface IWoodProvider {
@SideOnly(Side.CLIENT)
@@ -30,4 +30,14 @@ public interface IWoodProvider {
* @return A stack of wood from the tree to craft wood pile's or other things.
*/
ItemStack getWoodStack();
/**
* @return how long this wood's charcoal burns / 1000
*/
int getCombustibility();
/**
* The amount of charcoal dropped from a charcoal pile of this wood.
*/
int getCarbonization();
}
@@ -10,4 +10,8 @@ public interface IWoodType extends IStringSerializable {
int getMetadata();
float getHardness();
int getCarbonization();
int getCombustability();
}
@@ -10,11 +10,8 @@
******************************************************************************/
package forestry.api.genetics;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.arboriculture.ITree;
import net.minecraftforge.common.EnumPlantType;
/**
* Used to check for pollination traits without altering the world by changing vanilla leaves to forestry ones.
@@ -23,10 +20,10 @@ import forestry.api.arboriculture.ITree;
public interface ICheckPollinatable {
/**
* @return plant types this pollinatable is classified as.
* @return plant type this pollinatable is classified as.
* (Can be used by bees to determine whether to interact or not.)
*/
EnumSet<EnumPlantType> getPlantType();
EnumPlantType getPlantType();
/**
* @return IIndividual containing the genetic information of this IPollinatable
@@ -5,13 +5,10 @@
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraftforge.common.BiomeDictionary;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import net.minecraft.block.state.IBlockState;
import net.minecraftforge.common.BiomeDictionary;
/** Set custom mutation requirements */
public interface IMutationBuilder {
@@ -46,7 +43,7 @@ public interface IMutationBuilder {
IMutationBuilder requireNight();
/** Require a specific resource to be under the location of the mutation */
IMutationBuilder requireResource(IBlockState requiredBlockState);
IMutationBuilder requireResource(IBlockState... acceptedBlockStates);
IMutationBuilder requireResource(String oreDictName);
@@ -12,12 +12,11 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import com.mojang.authlib.GameProfile;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
/**
* Describes a class of species (i.e. bees, trees, butterflies), provides helper functions and access to common functionality.
*/
@@ -105,9 +104,9 @@ public interface ISpeciesRoot {
void registerTemplate(String identifier, IAllele[] template);
/**
* Retrieves a registered template using the passed identifier.
* Retrieves a registered template using the passed species unique identifier.
*
* @param identifier
* @param identifier species UID
* @return Array of {@link IAllele} representing a genome.
*/
IAllele[] getTemplate(String identifier);
@@ -139,13 +138,13 @@ public interface ISpeciesRoot {
/**
* @return All registered mutations.
*/
Collection<? extends IMutation> getMutations(boolean shuffle);
List<? extends IMutation> getMutations(boolean shuffle);
/**
* @param other Allele to match mutations against.
* @return All registered mutations the given allele is part of.
*/
Collection<? extends IMutation> getCombinations(IAllele other);
List<? extends IMutation> getCombinations(IAllele other);
/**
* @since Forestry 3.7
@@ -170,14 +169,14 @@ public interface ISpeciesRoot {
void setResearchSuitability(ItemStack itemstack, float suitability);
/**
* @return Array of {@link IChromosomeType} which are in this species genome
* @return Array of all {@link IChromosomeType} which are in this species genome
*/
IChromosomeType[] getKaryotype();
/**
* @return {@link IChromosomeType} which is the "key" for this species class, usually the species chromosome.
* @return {@link IChromosomeType} which is the "key" for this species class, the species chromosome.
*/
IChromosomeType getKaryotypeKey();
IChromosomeType getSpeciesChromosomeType();
/**
* Plugin to add information for the handheld genetic analyzer.
@@ -7,18 +7,16 @@ package forestry.api.lepidopterology;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.entity.EntityLiving;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.ISpeciesRoot;
public interface IButterflyRoot extends ISpeciesRoot {
@Override
@@ -67,7 +65,7 @@ public interface IButterflyRoot extends ISpeciesRoot {
/* MUTATIONS */
@Override
Collection<IButterflyMutation> getMutations(boolean shuffle);
List<IButterflyMutation> getMutations(boolean shuffle);
@Nullable
@Override
@@ -8,9 +8,8 @@ package forestry.api.multiblock;
import javax.annotation.Nonnull;
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -23,11 +22,10 @@ public interface ICharcoalPileComponent<T extends IMultiblockLogicCharcoalPile>
@Override
T getMultiblockLogic();
@Nonnull
ITree getTree();
void setTree(@Nonnull ITree tree);
IAlleleTreeSpecies getTreeSpecies();
void setTreeSpecies(@Nonnull IAlleleTreeSpecies treeSpecies);
@Override
@Nonnull
@@ -38,6 +36,6 @@ public interface ICharcoalPileComponent<T extends IMultiblockLogicCharcoalPile>
EnumPileType getPileType();
@SideOnly(Side.CLIENT)
ITree getNextWoodPile();
IAlleleTreeSpecies getNextWoodPile();
}
@@ -18,7 +18,7 @@ import forestry.api.arboriculture.ITreeGenome;
public interface ITreeGenData {
int getGirth(World world, BlockPos pos);
int getGirth();
float getHeightModifier();
@@ -239,9 +239,11 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
@Override
public void clearCachedValues() {
hasFlowersCache.clear();
queenCanWorkCache.clear();
canWork();
if (!housing.getWorldObj().isRemote) {
hasFlowersCache.clear();
queenCanWorkCache.clear();
canWork();
}
}
private void queenWorkTick(IBee queen) {
@@ -5,16 +5,15 @@ import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.BeeManager;
import forestry.api.genetics.IAlleleSpecies;
import forestry.apiculture.PluginApiculture;
import forestry.apiculture.genetics.BeeGenome;
import forestry.core.genetics.Genome;
import mezz.jei.api.BlankModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.ISubtypeRegistry;
import mezz.jei.api.JEIPlugin;
import net.minecraft.item.ItemStack;
@JEIPlugin
public class ApicultureJeiPlugin extends BlankModPlugin {
@@ -51,7 +50,7 @@ public class ApicultureJeiPlugin extends BlankModPlugin {
@Nullable
@Override
public String getSubtypeInfo(@Nonnull ItemStack itemStack) {
IAlleleSpecies species = BeeGenome.getSpeciesDirectly(itemStack);
IAlleleSpecies species = Genome.getSpeciesDirectly(BeeManager.beeRoot, itemStack);
return species == null ? null : species.getUID();
}
}
@@ -66,7 +66,7 @@ public class AIAvoidPlayers extends EntityAIBase {
}
path = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
return path != null && path.isDestinationSame(randomTarget);
return path != null;
}
@Override
@@ -10,19 +10,15 @@
******************************************************************************/
package forestry.apiculture.flowers;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.ICheckPollinatable;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.core.utils.Translator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class FlowerProvider implements IFlowerProvider {
@@ -42,15 +38,15 @@ public class FlowerProvider implements IFlowerProvider {
@Override
public boolean isAcceptedPollinatable(World world, ICheckPollinatable pollinatable) {
EnumSet<EnumPlantType> plantTypes = pollinatable.getPlantType();
EnumPlantType plantType = pollinatable.getPlantType();
switch (flowerType) {
case FlowerManager.FlowerTypeNether:
return plantTypes.contains(EnumPlantType.Nether);
return plantType == EnumPlantType.Nether;
case FlowerManager.FlowerTypeCacti:
return plantTypes.contains(EnumPlantType.Desert);
return plantType == EnumPlantType.Desert;
default:
return plantTypes.size() > 1 || !plantTypes.contains(EnumPlantType.Nether);
return plantType != EnumPlantType.Nether;
}
}
@@ -10,17 +10,12 @@
******************************************************************************/
package forestry.apiculture.genetics;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import javax.annotation.Nonnull;
import java.util.concurrent.TimeUnit;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.Vec3i;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
@@ -38,6 +33,9 @@ import forestry.core.genetics.Genome;
import forestry.core.genetics.alleles.AlleleArea;
import forestry.core.genetics.alleles.AlleleBoolean;
import forestry.core.genetics.alleles.AlleleTolerance;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.Vec3i;
public class BeeGenome extends Genome implements IBeeGenome {
/**
@@ -90,7 +88,7 @@ public class BeeGenome extends Genome implements IBeeGenome {
return null;
}
IAlleleSpecies species = getSpeciesDirectly(itemStack);
IAlleleSpecies species = getSpeciesDirectly(BeeManager.beeRoot, itemStack);
if (species instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) species;
}
@@ -12,20 +12,12 @@ package forestry.apiculture.genetics;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.fml.common.FMLCommonHandler;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
@@ -53,6 +45,11 @@ import forestry.apiculture.BeeHousingModifier;
import forestry.apiculture.BeekeepingLogic;
import forestry.apiculture.PluginApiculture;
import forestry.core.genetics.SpeciesRoot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
public class BeeRoot extends SpeciesRoot implements IBeeRoot {
@@ -252,10 +249,10 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
/**
* List of possible mutations on species alleles.
*/
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<>();
private static final List<IBeeMutation> beeMutations = new ArrayList<>();
@Override
public Collection<IBeeMutation> getMutations(boolean shuffle) {
public List<IBeeMutation> getMutations(boolean shuffle) {
if (shuffle) {
Collections.shuffle(beeMutations);
}
@@ -371,7 +368,7 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
}
@Override
public IChromosomeType getKaryotypeKey() {
public IChromosomeType getSpeciesChromosomeType() {
return EnumBeeChromosome.SPECIES;
}
@@ -10,10 +10,9 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import forestry.api.apiculture.IJubilanceFactory;
import forestry.api.apiculture.IJubilanceProvider;
import net.minecraft.block.state.IBlockState;
public class JubilanceFactory implements IJubilanceFactory {
@Override
@@ -22,7 +21,7 @@ public class JubilanceFactory implements IJubilanceFactory {
}
@Override
public IJubilanceProvider getRequiresResource(Block block, int meta) {
return new JubilanceRequiresResource(block, meta);
public IJubilanceProvider getRequiresResource(IBlockState... acceptedBlockStates) {
return new JubilanceRequiresResource(acceptedBlockStates);
}
}
@@ -10,33 +10,40 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IJubilanceProvider;
import forestry.core.utils.ItemStackUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class JubilanceRequiresResource implements IJubilanceProvider {
private final ItemStack blockRequired;
private final Set<IBlockState> acceptedBlockStates = new HashSet<>();
public JubilanceRequiresResource(Block block, int meta) {
this.blockRequired = new ItemStack(block, meta);
public JubilanceRequiresResource(IBlockState... acceptedBlockStates) {
Collections.addAll(this.acceptedBlockStates, acceptedBlockStates);
}
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorldObj();
BlockPos housingCoords = housing.getCoordinates();
BlockPos pos = housing.getCoordinates();
IBlockState state = world.getBlockState(housingCoords.down());
return ItemStackUtil.equals(state, blockRequired);
TileEntity tile;
do {
pos = pos.down();
tile = world.getTileEntity(pos);
} while (tile instanceof IBeeHousing && pos.getY() > 0);
IBlockState blockState = world.getBlockState(pos);
return this.acceptedBlockStates.contains(blockState);
}
}
@@ -57,7 +57,7 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
super.addInformation(stack, playerIn, tooltip, advanced);
beeModifier.addInformation(stack, playerIn, tooltip, advanced);
if (!stack.isItemDamaged()) {
tooltip.add(Translator.translateToLocalFormatted("item.for.frame.durability", stack.getMaxDamage()));
tooltip.add(Translator.translateToLocalFormatted("item.for.durability", stack.getMaxDamage()));
}
}
@@ -69,7 +69,6 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
private static final Random random = new Random();
private int averageGroundLevel = -1;
private boolean isInDesert = false;
private IBlockState planks;
private IBlockState slabs;
private IBlockState logs;
@@ -86,8 +85,6 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
public VillageApiaristHouse(StructureVillagePieces.Start startPiece, int componentType, Random random, StructureBoundingBox boundingBox, EnumFacing facing) {
super(startPiece, componentType, random, boundingBox, facing);
isInDesert = startPiece.inDesert;
createBuildingBlocks(random);
}
@@ -280,7 +277,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
private void buildGarden(World world, StructureBoundingBox box) {
Block ground = Blocks.DIRT;
if (isInDesert) {
if (field_189928_h == 1) { // desert
ground = Blocks.SAND;
}
@@ -293,7 +290,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
private void plantFlowerGarden(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
if (isInDesert) {
if (field_189928_h == 1) { // desert
setBlockState(world, Blocks.CACTUS.getDefaultState(), 4, 1, 7, box);
return;
}
@@ -17,34 +17,12 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockNewLeaf;
import net.minecraft.block.BlockOldLeaf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.IFuelHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.arboriculture.EnumForestryWoodType;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.EnumVanillaWoodType;
import forestry.api.arboriculture.IAlleleFruit;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.IWoodType;
import forestry.api.arboriculture.TreeManager;
@@ -56,6 +34,7 @@ import forestry.api.genetics.ISaplingTranslator;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.ICrateRegistry;
import forestry.api.storage.StorageManager;
import forestry.arboriculture.blocks.BlockForestryLeaves;
import forestry.arboriculture.blocks.BlockPile;
import forestry.arboriculture.blocks.BlockRegistryArboriculture;
import forestry.arboriculture.blocks.log.BlockArbLog;
@@ -71,6 +50,7 @@ import forestry.arboriculture.genetics.alleles.AlleleFruit;
import forestry.arboriculture.genetics.alleles.AlleleGrowth;
import forestry.arboriculture.genetics.alleles.AlleleLeafEffect;
import forestry.arboriculture.items.ItemCharcoal;
import forestry.arboriculture.items.ItemGrafter;
import forestry.arboriculture.items.ItemRegistryArboriculture;
import forestry.arboriculture.models.TextureLeaves;
import forestry.arboriculture.network.PacketRegistryArboriculture;
@@ -95,6 +75,31 @@ import forestry.factory.recipes.FabricatorRecipe;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockNewLeaf;
import net.minecraft.block.BlockOldLeaf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.common.IFuelHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
@ForestryPlugin(pluginID = ForestryPluginUids.ARBORICULTURE, name = "Arboriculture", author = "Binnie & SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.arboriculture.description")
public class PluginArboriculture extends BlankForestryPlugin {
@@ -395,10 +400,11 @@ public class PluginArboriculture extends BlankForestryPlugin {
'Y', "chestWood");
//Wood Piles
for(ITree tree : TreeManager.treeRoot.getIndividualTemplates()){
ItemStack log = tree.getGenome().getPrimary().getWoodProvider().getWoodStack().copy();
for (ITree tree : TreeManager.treeRoot.getIndividualTemplates()) {
IAlleleTreeSpecies treeSpecies = tree.getGenome().getPrimary();
ItemStack log = treeSpecies.getWoodProvider().getWoodStack().copy();
log.stackSize = 1;
ItemStack woodPile = BlockPile.createWoodPile(tree);
ItemStack woodPile = BlockPile.createWoodPile(treeSpecies);
RecipeUtil.addShapelessRecipe(woodPile, log, log, log, log);
}
@@ -546,4 +552,31 @@ public class PluginArboriculture extends BlankForestryPlugin {
alleleFruit.getProvider().registerSprites();
}
}
@SubscribeEvent
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
IBlockState state = event.getState();
Block block = state.getBlock();
if (block instanceof BlockLeaves && !(block instanceof BlockForestryLeaves)) {
EntityPlayer player = event.getHarvester();
if (player != null) {
ItemStack harvestingTool = player.getHeldItemMainhand();
if (harvestingTool != null && harvestingTool.getItem() instanceof ItemGrafter) {
if (event.getDrops().isEmpty()) {
World world = event.getWorld();
Item itemDropped = block.getItemDropped(state, world.rand, 3);
if (itemDropped != null) {
event.getDrops().add(new ItemStack(itemDropped, 1, block.damageDropped(state)));
}
}
harvestingTool.damageItem(1, player);
if (harvestingTool.stackSize <= 0) {
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, harvestingTool, EnumHand.MAIN_HAND);
player.setHeldItem(EnumHand.MAIN_HAND, null);
}
}
}
}
}
}
@@ -7,12 +7,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList;
import forestry.api.arboriculture.EnumForestryWoodType;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.TreeManager;
@@ -22,6 +16,11 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IIndividual;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList;
public class VillagerArboristTrades {
@@ -120,7 +119,7 @@ public class VillagerArboristTrades {
j = this.emeraldPriceInfo.getPrice(random);
}
IChromosomeType treeSpeciesType = TreeManager.treeRoot.getKaryotypeKey();
IChromosomeType treeSpeciesType = TreeManager.treeRoot.getSpeciesChromosomeType();
Collection<IAllele> registeredSpecies = AlleleManager.alleleRegistry.getRegisteredAlleles(treeSpeciesType);
List<IAlleleSpecies> potentialSpecies = new ArrayList<>();
for (IAllele allele : registeredSpecies) {
@@ -16,6 +16,29 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.IToolGrafter;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.IToolScoop;
import forestry.api.core.Tabs;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.EnumFlutterType;
import forestry.api.lepidopterology.IButterfly;
import forestry.arboriculture.LeafDecayHelper;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.arboriculture.tiles.TileLeaves;
import forestry.core.blocks.IColoredBlock;
import forestry.core.blocks.propertys.UnlistedBlockAccess;
import forestry.core.blocks.propertys.UnlistedBlockPos;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.IGrowable;
@@ -40,9 +63,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
@@ -50,29 +70,6 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.IToolGrafter;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.core.IToolScoop;
import forestry.api.core.Tabs;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.EnumFlutterType;
import forestry.api.lepidopterology.IButterfly;
import forestry.arboriculture.LeafDecayHelper;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.arboriculture.tiles.TileLeaves;
import forestry.core.blocks.IColoredBlock;
import forestry.core.blocks.propertys.UnlistedBlockAccess;
import forestry.core.blocks.propertys.UnlistedBlockPos;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.ItemStackUtil;
public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvider, IGrowable, IItemModelRegister, IColoredBlock {
public BlockForestryLeaves() {
@@ -137,17 +134,16 @@ public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvi
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getActiveItemStack());
float saplingModifier = 1.0f;
if (!world.isRemote) {
ItemStack held = player.inventory.getCurrentItem();
if (held != null && held.getItem() instanceof IToolGrafter) {
saplingModifier = ((IToolGrafter) held.getItem()).getSaplingModifier(held, world, player, pos);
held.damageItem(1, player);
if (held.stackSize <= 0) {
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, held, EnumHand.MAIN_HAND);
player.setHeldItem(EnumHand.MAIN_HAND, null);
}
ItemStack held = player.inventory.getCurrentItem();
if (held != null && held.getItem() instanceof IToolGrafter) {
saplingModifier = ((IToolGrafter) held.getItem()).getSaplingModifier(held, world, player, pos);
held.damageItem(1, player);
if (held.stackSize <= 0) {
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, held, EnumHand.MAIN_HAND);
player.setHeldItem(EnumHand.MAIN_HAND, null);
}
}
GameProfile playerProfile = player.getGameProfile();
List<ItemStack> leafDrops = getLeafDrop(world, playerProfile, pos, saplingModifier, fortune);
drops.set(leafDrops);
@@ -1,7 +1,5 @@
package forestry.arboriculture.blocks;
import com.google.common.collect.Lists;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.EnumMap;
@@ -9,6 +7,36 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Lists;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.IWoodProvider;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.IModelManager;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.ITextureManager;
import forestry.api.core.Tabs;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.multiblock.ICharcoalPileComponent;
import forestry.apiculture.blocks.BlockCandle;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.genetics.Tree;
import forestry.arboriculture.multiblock.EnumPilePosition;
import forestry.arboriculture.multiblock.ICharcoalPileControllerInternal;
import forestry.arboriculture.render.PileParticleCallback;
import forestry.arboriculture.render.PileStateMapper;
import forestry.arboriculture.tiles.TilePile;
import forestry.core.PluginCore;
import forestry.core.blocks.BlockStructure;
import forestry.core.blocks.propertys.UnlistedBlockAccess;
import forestry.core.blocks.propertys.UnlistedBlockPos;
import forestry.core.multiblock.MultiblockLogic;
import forestry.core.proxy.Proxies;
import forestry.core.render.ParticleHelper;
import forestry.core.tiles.TileUtil;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
@@ -40,42 +68,12 @@ import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.IModelManager;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.IStateMapperRegister;
import forestry.api.core.ITextureManager;
import forestry.api.core.Tabs;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.multiblock.ICharcoalPileComponent;
import forestry.apiculture.blocks.BlockCandle;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.genetics.Tree;
import forestry.arboriculture.multiblock.EnumPilePosition;
import forestry.arboriculture.multiblock.ICharcoalPileControllerInternal;
import forestry.arboriculture.render.PileParticleCallback;
import forestry.arboriculture.render.PileStateMapper;
import forestry.arboriculture.tiles.TilePile;
import forestry.core.PluginCore;
import forestry.core.blocks.BlockStructure;
import forestry.core.blocks.propertys.UnlistedBlockAccess;
import forestry.core.blocks.propertys.UnlistedBlockPos;
import forestry.core.multiblock.MultiblockLogic;
import forestry.core.proxy.Proxies;
import forestry.core.render.ParticleHelper;
import forestry.core.tiles.TileUtil;
public abstract class BlockPile extends BlockStructure implements ITileEntityProvider, IStateMapperRegister, ISpriteRegister {
/**
@@ -318,13 +316,15 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> subItems) {
if(getPileType() == EnumPileType.WOOD){
if (getPileType() == EnumPileType.WOOD) {
List<ItemStack> woodPiles = new ArrayList<>();
for(ITree tree : TreeManager.treeRoot.getIndividualTemplates()) {
woodPiles.add(createWoodPile(tree));
for (ITree tree : TreeManager.treeRoot.getIndividualTemplates()) {
IAlleleTreeSpecies treeSpecies = tree.getGenome().getPrimary();
ItemStack woodPile = createWoodPile(treeSpecies);
woodPiles.add(woodPile);
}
subItems.addAll(woodPiles);
}else if(getPileType() == EnumPileType.DIRT){
} else if (getPileType() == EnumPileType.DIRT) {
super.getSubBlocks(item, tab, subItems);
}
}
@@ -412,8 +412,9 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
ICharcoalPileComponent pile = (ICharcoalPileComponent) tile;
if (getPileType() == EnumPileType.ASH) {
if (pile.getTree() != null) {
ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, pile.getTree().getGenome().getCarbonization(), pile.getTree().getGenome().getCombustibility());
if (pile.getTreeSpecies() != null) {
IWoodProvider woodProvider = pile.getTreeSpecies().getWoodProvider();
ItemStack charcoal = new ItemStack(PluginArboriculture.items.charcoal, woodProvider.getCarbonization(), woodProvider.getCombustibility());
list.add(charcoal);
list.add(new ItemStack(PluginCore.items.ash, 3));
} else {
@@ -423,7 +424,7 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
} else if (getPileType() == EnumPileType.DIRT) {
list.add(new ItemStack(this));
} else {
list.add(createWoodPile(pile.getTree()));
list.add(createWoodPile(pile.getTreeSpecies()));
}
}
return list;
@@ -485,7 +486,7 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
if(getPileType() == EnumPileType.WOOD){
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
return createWoodPile(((ICharcoalPileComponent) tile).getTree());
return createWoodPile(((ICharcoalPileComponent) tile).getTreeSpecies());
}
}else if(getPileType() == EnumPileType.DIRT){
return super.getPickBlock(state, target, world, pos, player);
@@ -528,10 +529,19 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
IBlockState blockState = world.getBlockState(pos);
return ParticleHelper.addDestroyEffects(world, this, blockState, pos, effectRenderer, particleCallback);
}
public static ITree getTree(ItemStack stack){
public static IAlleleTreeSpecies getTreeSpecies(ItemStack stack) {
if (stack != null) {
return new Tree(stack.getTagCompound().getCompoundTag("ContainedTree"));
NBTTagCompound tagCompound = stack.getTagCompound();
// legacy
if (tagCompound.hasKey("ContainedTree")) {
ITree tree = new Tree(tagCompound.getCompoundTag("ContainedTree"));
return tree.getGenome().getPrimary();
}
String treeSpeciesUid = tagCompound.getString("TreeSpecies");
return (IAlleleTreeSpecies) AlleleManager.alleleRegistry.getAllele(treeSpeciesUid);
}
return null;
}
@@ -541,10 +551,9 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
if(getPileType() == EnumPileType.WOOD){
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
ITree tree = ((ICharcoalPileComponent)tile).getTree();
if(tree != null){
ItemStack wood = tree.getGenome().getPrimary().getWoodProvider().getWoodStack();
IAlleleTreeSpecies tree = ((ICharcoalPileComponent) tile).getTreeSpecies();
if (tree != null) {
ItemStack wood = tree.getWoodProvider().getWoodStack();
if(wood != null){
Block block = Block.getBlockFromItem(wood.getItem());
return block.getFlammability(world, pos, face);
@@ -560,10 +569,9 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
if(getPileType() == EnumPileType.WOOD){
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
ITree tree = ((ICharcoalPileComponent)tile).getTree();
IAlleleTreeSpecies tree = ((ICharcoalPileComponent) tile).getTreeSpecies();
if(tree != null){
ItemStack wood = tree.getGenome().getPrimary().getWoodProvider().getWoodStack();
ItemStack wood = tree.getWoodProvider().getWoodStack();
if(wood != null){
Block block = Block.getBlockFromItem(wood.getItem());
return block.getFireSpreadSpeed(world, pos, face);
@@ -580,11 +588,11 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
if(getPileType() == EnumPileType.WOOD){
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof ICharcoalPileComponent) {
ITree tree = ((ICharcoalPileComponent)tile).getTree();
IAlleleTreeSpecies tree = ((ICharcoalPileComponent) tile).getTreeSpecies();
if(tree != null){
ItemStack wood = tree.getGenome().getPrimary().getWoodProvider().getWoodStack();
if(wood != null){
ItemStack wood = tree.getWoodProvider().getWoodStack();
if (wood != null) {
Block block = Block.getBlockFromItem(wood.getItem());
return block.getStateFromMeta(wood.getMetadata()).getBlockHardness(world, pos);
}
@@ -593,14 +601,12 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro
}
return super.getBlockHardness(blockState, world, pos);
}
public static ItemStack createWoodPile(ITree tree) {
if (tree != null) {
public static ItemStack createWoodPile(IAlleleTreeSpecies treeSpecies) {
if (treeSpecies != null) {
ItemStack stack = new ItemStack(PluginArboriculture.blocks.piles.get(EnumPileType.WOOD));
NBTTagCompound nbtTag = new NBTTagCompound();
tree.writeToNBT(nbtTag);
NBTTagCompound nbtItem = new NBTTagCompound();
nbtItem.setTag("ContainedTree", nbtTag);
nbtItem.setString("TreeSpecies", treeSpecies.getUID());
stack.setTagCompound(nbtItem);
return stack;
}
@@ -13,17 +13,16 @@ package forestry.arboriculture.commands;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.World;
import forestry.api.arboriculture.ITreekeepingMode;
import forestry.api.arboriculture.TreeManager;
import forestry.core.commands.ICommandModeHelper;
import net.minecraft.world.World;
public class TreeModeHelper implements ICommandModeHelper {
@Override
public String[] getModeNames() {
ArrayList<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
List<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
int modeStringCount = treekeepingModes.size();
List<String> modeStrings = new ArrayList<>(modeStringCount);
for (ITreekeepingMode mode : treekeepingModes) {
@@ -11,47 +11,23 @@
package forestry.arboriculture.genetics;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.state.IBlockState;
import forestry.api.arboriculture.IGrowthProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.core.utils.Translator;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import forestry.api.arboriculture.EnumGrowthConditions;
import forestry.api.arboriculture.IGrowthProvider;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.core.ForestryAPI;
import forestry.arboriculture.tiles.TileSapling;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.Translator;
/**
* @deprecated this is being removed to simplify trees
*/
@Deprecated
public class GrowthProvider implements IGrowthProvider {
@Override
@Nullable
public BlockPos canGrow(ITreeGenome genome, World world, BlockPos pos, int expectedGirth, int expectedHeight) {
BlockPos growthPos = hasSufficientSaplingsAroundSapling(genome, world, pos, expectedGirth);
if (growthPos == null) {
return null;
}
if (!hasRoom(world, growthPos, expectedGirth, expectedHeight)) {
return null;
}
if (getGrowthConditions(genome, world, growthPos) == EnumGrowthConditions.HOSTILE) {
return null;
}
return growthPos;
}
@Override
public EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, BlockPos pos) {
return getConditionFromLight(world, pos);
return TreeGrowthHelper.canGrow(world, genome, pos, expectedGirth, expectedHeight);
}
@Override
@@ -63,118 +39,4 @@ public class GrowthProvider implements IGrowthProvider {
public String[] getInfo() {
return new String[0];
}
protected static EnumGrowthConditions getConditionsFromRainfall(World world, BlockPos pos, float min, float max) {
float humidity = ForestryAPI.climateManager.getHumidity(world, pos);
if (humidity < min || humidity > max) {
return EnumGrowthConditions.HOSTILE;
}
return EnumGrowthConditions.EXCELLENT;
}
protected static EnumGrowthConditions getConditionsFromTemperature(World world, BlockPos pos, float min, float max) {
float biomeTemperature = ForestryAPI.climateManager.getTemperature(world, pos);
if (biomeTemperature < min || biomeTemperature > max) {
return EnumGrowthConditions.HOSTILE;
}
return EnumGrowthConditions.EXCELLENT;
}
protected static EnumGrowthConditions getConditionFromLight(World world, BlockPos pos) {
int lightValue = world.getLightFromNeighbors(pos.up());
if (lightValue > 13) {
return EnumGrowthConditions.EXCELLENT;
} else if (lightValue > 11) {
return EnumGrowthConditions.GOOD;
} else if (lightValue > 8) {
return EnumGrowthConditions.NORMAL;
} else if (lightValue > 6) {
return EnumGrowthConditions.PALTRY;
} else {
return EnumGrowthConditions.HOSTILE;
}
}
private static boolean hasRoom(World world, BlockPos pos, int expectedGirth, int expectedHeight) {
Vec3i area = new Vec3i(expectedGirth, expectedHeight + 1, expectedGirth);
return checkArea(world, pos.up(), area);
}
private static boolean checkArea(World world, BlockPos start, Vec3i area) {
for (int x = 0; x < area.getX(); x++) {
for (int y = 0; y < area.getY(); y++) {
for (int z = 0; z < area.getZ(); z++) {
BlockPos pos = start.add(x, y, z);
IBlockState blockState = world.getBlockState(pos);
if (!blockState.getBlock().isReplaceable(world, pos)) {
return false;
}
}
}
}
return true;
}
/**
* Checks an area for saplings.
* If saplings need to be 2x2, 3x3, etc, it will check all configurations in which pos is included in that area.
* Uses a knownSaplings cache to avoid checking the same saplings multiple times.
*/
@Nullable
private static BlockPos hasSufficientSaplingsAroundSapling(ITreeGenome genome, World world, BlockPos saplingPos, int expectedGirth) {
final int checkSize = (expectedGirth * 2) - 1;
final int offset = expectedGirth - 1;
final Map<BlockPos, Boolean> knownSaplings = new HashMap<>(checkSize * checkSize);
for (int x = -offset; x <= 0; x++) {
for (int z = -offset; z <= 0; z++) {
BlockPos startPos = saplingPos.add(x, 0, z);
if (checkForSaplings(genome, world, startPos, expectedGirth, knownSaplings)) {
return startPos;
}
}
}
return null;
}
private static boolean checkForSaplings(ITreeGenome genome, World world, BlockPos startPos, int girth, Map<BlockPos, Boolean> knownSaplings) {
for (int x = 0; x < girth; x++) {
for (int z = 0; z < girth; z++) {
BlockPos checkPos = startPos.add(x, 0, z);
Boolean knownSapling = knownSaplings.get(checkPos);
if (knownSapling == null) {
knownSapling = isSapling(genome, world, checkPos);
knownSaplings.put(checkPos, knownSapling);
}
if (!knownSapling) {
return false;
}
}
}
return true;
}
private static boolean isSapling(ITreeGenome genome, World world, BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return false;
}
if (world.isAirBlock(pos)) {
return false;
}
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
if (sapling == null) {
return false;
}
ITree tree = sapling.getTree();
return tree != null && tree.getGenome().getPrimary().getUID().equals(genome.getPrimary().getUID());
}
}
@@ -1,54 +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.arboriculture.genetics;
import java.util.EnumSet;
import net.minecraft.init.Biomes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.arboriculture.EnumGrowthConditions;
import forestry.api.arboriculture.ITreeGenome;
import forestry.core.utils.Translator;
public class GrowthProviderTropical extends GrowthProvider {
@Override
public EnumGrowthConditions getGrowthConditions(ITreeGenome genome, World world, BlockPos pos) {
EnumGrowthConditions light = getConditionFromLight(world, pos);
EnumGrowthConditions moisture = getConditionsFromRainfall(world, pos, Biomes.JUNGLE.getRainfall(), 2.0f);
float jungleTemperature = Biomes.JUNGLE.getFloatTemperature(pos);
float desertTemperature = Biomes.DESERT.getFloatTemperature(pos);
EnumGrowthConditions temperature = getConditionsFromTemperature(world, pos, jungleTemperature, desertTemperature - 0.1f);
EnumSet<EnumGrowthConditions> conditions = EnumSet.of(light, moisture, temperature);
EnumGrowthConditions result = EnumGrowthConditions.HOSTILE;
for (EnumGrowthConditions cond : conditions) {
if (cond == EnumGrowthConditions.HOSTILE) {
return EnumGrowthConditions.HOSTILE;
}
if (cond.ordinal() > result.ordinal()) {
result = cond;
}
}
return result;
}
@Override
public String getDescription() {
return Translator.translateToLocal("for.growth.tropical");
}
}
@@ -14,34 +14,16 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import forestry.api.arboriculture.EnumGrowthConditions;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleLeafEffect;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.IArboristTracker;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.IGrowthProvider;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.ITreeMutation;
@@ -57,6 +39,18 @@ import forestry.core.config.Config;
import forestry.core.genetics.Chromosome;
import forestry.core.genetics.Individual;
import forestry.core.utils.Translator;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
public class Tree extends Individual implements ITree, IPlantable {
@@ -65,13 +59,8 @@ public class Tree extends Individual implements ITree, IPlantable {
@Nullable
private ITreeGenome mate;
private final EnumSet<EnumPlantType> plantTypes;
private EnumPlantType plantType;
public Tree(@Nonnull ITreeGenome genome) {
this.genome = genome;
plantTypes = genome.getPlantTypes();
plantTypes.add(genome.getPrimary().getPlantType());
}
public Tree(@Nonnull NBTTagCompound nbttagcompound) {
@@ -83,9 +72,6 @@ public class Tree extends Individual implements ITree, IPlantable {
this.genome = TreeDefinition.Oak.getGenome();
}
this.plantTypes = genome.getPlantTypes();
this.plantTypes.add(genome.getPrimary().getPlantType());
if (nbttagcompound.hasKey("Mate")) {
mate = new TreeGenome(nbttagcompound.getCompoundTag("Mate"));
}
@@ -164,12 +150,8 @@ public class Tree extends Individual implements ITree, IPlantable {
}
Block block = blockState.getBlock();
for (EnumPlantType type : getPlantTypes()) {
this.plantType = type;
if (block.canSustainPlant(blockState, world, blockPos, EnumFacing.UP, this)) {
return true;
}
if (block.canSustainPlant(blockState, world, blockPos, EnumFacing.UP, this)) {
return true;
}
return false;
@@ -177,7 +159,7 @@ public class Tree extends Individual implements ITree, IPlantable {
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) {
return plantType;
return genome.getPrimary().getPlantType();
}
@Override
@@ -188,8 +170,7 @@ public class Tree extends Individual implements ITree, IPlantable {
@Override
@Nullable
public BlockPos canGrow(World world, BlockPos pos, int expectedGirth, int expectedHeight) {
IGrowthProvider growthProvider = genome.getGrowthProvider();
return growthProvider.canGrow(genome, world, pos, expectedGirth, expectedHeight);
return TreeGrowthHelper.canGrow(world, genome, pos, expectedGirth, expectedHeight);
}
@Override
@@ -198,12 +179,7 @@ public class Tree extends Individual implements ITree, IPlantable {
}
@Override
public EnumGrowthConditions getGrowthCondition(World world, BlockPos pos) {
return genome.getGrowthProvider().getGrowthConditions(getGenome(), world, pos);
}
@Override
public int getGirth(World world, BlockPos pos) {
public int getGirth() {
return genome.getGirth();
}
@@ -275,11 +251,6 @@ public class Tree extends Individual implements ITree, IPlantable {
return genome.getActiveAllele(chromosome).getUID().equals(genome.getInactiveAllele(chromosome).getUID());
}
@Override
public EnumSet<EnumPlantType> getPlantTypes() {
return plantTypes;
}
@Override
public void addTooltip(List<String> list) {
@@ -302,8 +273,8 @@ public class Tree extends Individual implements ITree, IPlantable {
String girth = TextFormatting.AQUA + "G: " + String.format("%sx%s", genome.getGirth(), genome.getGirth());
String saplings = TextFormatting.YELLOW + "S: " + genome.getActiveAllele(EnumTreeChromosome.FERTILITY).getName();
String yield = TextFormatting.WHITE + "Y: " + genome.getActiveAllele(EnumTreeChromosome.YIELD).getName();
String combustibility = TextFormatting.DARK_GRAY + "CO: " + genome.getCombustibility();
String carbonization = TextFormatting.GRAY + "CA: " + genome.getCarbonization();
String combustibility = TextFormatting.DARK_GRAY + "CO: " + primary.getWoodProvider().getCombustibility();
String carbonization = TextFormatting.GRAY + "CA: " + secondary.getWoodProvider().getCarbonization();
list.add(String.format("%s, %s", saplings, maturation));
list.add(String.format("%s, %s", height, girth));
list.add(String.format("%s, %s", yield, sappiness));
@@ -11,23 +11,14 @@
package forestry.arboriculture.genetics;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleFruit;
import forestry.api.arboriculture.IAlleleGrowth;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
@@ -38,13 +29,16 @@ import forestry.api.genetics.IFruitFamily;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.genetics.alleles.AlleleFruit;
import forestry.core.config.Config;
import forestry.core.genetics.alleles.AllelePlantType;
import forestry.core.gui.GuiAlyzer;
import forestry.core.gui.TextLayoutHelper;
import forestry.core.gui.widgets.ItemStackWidget;
import forestry.core.gui.widgets.WidgetManager;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Translator;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class TreeAlyzerPlugin implements IAlyzerPlugin {
public static final TreeAlyzerPlugin INSTANCE = new TreeAlyzerPlugin();
@@ -110,12 +104,6 @@ public class TreeAlyzerPlugin implements IAlyzerPlugin {
textLayout.newLineCompressed();
gui.drawChromosomeRow(Translator.translateToLocal("for.gui.effect"), tree, EnumTreeChromosome.EFFECT);
textLayout.newLineCompressed();
IAlleleInteger activeCombustibility = (IAlleleInteger) tree.getGenome().getActiveAllele(EnumTreeChromosome.COMBUSTIBILITY);
IAlleleInteger inactiveCombustibility = (IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.COMBUSTIBILITY);
textLayout.drawLine(Translator.translateToLocal("for.gui.combustibility"), GuiAlyzer.COLUMN_0);
gui.drawLine(Integer.toString(activeCombustibility.getValue()), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.COMBUSTIBILITY, false);
gui.drawLine(Integer.toString(inactiveCombustibility.getValue()), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.COMBUSTIBILITY, true);
textLayout.endPage();
}
@@ -140,20 +128,24 @@ public class TreeAlyzerPlugin implements IAlyzerPlugin {
textLayout.newLine();
textLayout.newLine();
IAlleleInteger activeCarbonization = (IAlleleInteger) tree.getGenome().getActiveAllele(EnumTreeChromosome.CARBONIZATION);
IAlleleInteger inactiveCarbonization = (IAlleleInteger) tree.getGenome().getInactiveAllele(EnumTreeChromosome.CARBONIZATION);
IAlleleTreeSpecies activeSpecies = (IAlleleTreeSpecies) tree.getGenome().getActiveAllele(EnumTreeChromosome.SPECIES);
IAlleleTreeSpecies inActiveSpecies = (IAlleleTreeSpecies) tree.getGenome().getInactiveAllele(EnumTreeChromosome.SPECIES);
int activeCombustibility = activeSpecies.getWoodProvider().getCombustibility();
int inactiveCombustibility = inActiveSpecies.getWoodProvider().getCombustibility();
textLayout.drawLine(Translator.translateToLocal("for.gui.combustibility"), GuiAlyzer.COLUMN_0);
gui.drawLine(Integer.toString(activeCombustibility), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.SPECIES, false);
gui.drawLine(Integer.toString(inactiveCombustibility), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.SPECIES, true);
textLayout.newLineCompressed();
int activeCarbonization = activeSpecies.getWoodProvider().getCarbonization();
int inactiveCarbonization = inActiveSpecies.getWoodProvider().getCarbonization();
textLayout.drawLine(Translator.translateToLocal("for.gui.carbonization"), GuiAlyzer.COLUMN_0);
gui.drawLine(Integer.toString(activeCarbonization.getValue()), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.CARBONIZATION, false);
gui.drawLine(Integer.toString(inactiveCarbonization.getValue()), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.CARBONIZATION, true);
textLayout.newLineCompressed();
textLayout.drawLine(Translator.translateToLocal("for.gui.growth"), GuiAlyzer.COLUMN_0);
gui.drawLine(tree.getGenome().getGrowthProvider().getDescription(), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.GROWTH, false);
gui.drawLine(((IAlleleGrowth) tree.getGenome().getInactiveAllele(EnumTreeChromosome.GROWTH)).getProvider().getDescription(), GuiAlyzer.COLUMN_2, tree,
EnumTreeChromosome.GROWTH, true);
textLayout.newLineCompressed();
gui.drawLine(Integer.toString(activeCarbonization), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.SPECIES, false);
gui.drawLine(Integer.toString(inactiveCarbonization), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.SPECIES, true);
textLayout.newLine();
textLayout.drawLine(Translator.translateToLocal("for.gui.native"), GuiAlyzer.COLUMN_0);
textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_1,
@@ -161,38 +153,14 @@ public class TreeAlyzerPlugin implements IAlyzerPlugin {
textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getSecondary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_2,
speciesDominance1);
textLayout.newLineCompressed();
textLayout.drawLine(Translator.translateToLocal("for.gui.tolerated"), GuiAlyzer.COLUMN_0);
List<EnumPlantType> activeTolerated = new ArrayList<>(tree.getGenome().getPlantTypes());
List<EnumPlantType> inactiveTolerated = Collections.emptyList();
IAllele inactiveAllelePlant = tree.getGenome().getInactiveAllele(EnumTreeChromosome.PLANT);
if (inactiveAllelePlant instanceof AllelePlantType) {
inactiveTolerated = new ArrayList<>(((AllelePlantType) inactiveAllelePlant).getPlantTypes());
}
int max = Math.max(activeTolerated.size(), inactiveTolerated.size());
for (int i = 0; i < max; i++) {
if (i > 0) {
textLayout.newLineCompressed();
}
if (activeTolerated.size() > i) {
gui.drawLine(Translator.translateToLocal("for.gui." + activeTolerated.get(i).toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_1, tree, EnumTreeChromosome.PLANT, false);
}
if (inactiveTolerated.size() > i) {
gui.drawLine(Translator.translateToLocal("for.gui." + inactiveTolerated.get(i).toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_2, tree, EnumTreeChromosome.PLANT, true);
}
}
textLayout.newLineCompressed();
textLayout.newLine();
// FRUITS
textLayout.drawLine(Translator.translateToLocal("for.gui.supports"), GuiAlyzer.COLUMN_0);
List<IFruitFamily> families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
List<IFruitFamily> families1 = new ArrayList<>(tree.getGenome().getSecondary().getSuitableFruit());
max = Math.max(families0.size(), families1.size());
int max = Math.max(families0.size(), families1.size());
for (int i = 0; i < max; i++) {
if (i > 0) {
textLayout.newLineCompressed();
@@ -206,8 +174,7 @@ public class TreeAlyzerPlugin implements IAlyzerPlugin {
}
}
textLayout.newLine();
textLayout.newLine();
int fruitDominance0 = gui.getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant());
@@ -10,22 +10,11 @@
******************************************************************************/
package forestry.arboriculture.genetics;
import java.awt.Color;
import java.awt.*;
import java.util.Arrays;
import java.util.Locale;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.EnumForestryWoodType;
import forestry.api.arboriculture.EnumFruitFamily;
import forestry.api.arboriculture.EnumGermlingType;
@@ -50,7 +39,6 @@ import forestry.api.genetics.IAllele;
import forestry.api.world.ITreeGenData;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.genetics.alleles.AlleleFruit;
import forestry.arboriculture.genetics.alleles.AlleleGrowth;
import forestry.arboriculture.models.ModelProviderFactory;
import forestry.arboriculture.tiles.TileLeaves;
import forestry.arboriculture.worldgen.WorldGenAcacia;
@@ -94,6 +82,15 @@ import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.genetics.alleles.AllelePlantType;
import forestry.core.genetics.alleles.EnumAllele;
import forestry.core.tiles.TileUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSerializable {
Oak(TreeBranchDefinition.QUERCUS, "appleOak", "robur", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), EnumVanillaWoodType.OAK) {
@@ -107,8 +104,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FRUITS, AlleleFruit.fruitApple);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.CARBONIZATION, 5);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 20);
}
@Override
@@ -132,8 +127,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.GIRTH, 2);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.CARBONIZATION, 5);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 20);
}
@Override
@@ -156,7 +149,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
protected void setAlleles(IAllele[] alleles) {
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 19);
}
@Override
@@ -180,7 +172,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.YIELD, EnumAllele.Yield.LOWER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 19);
//Allele.helper.set(alleles, EnumTreeChromosome.EFFECT, Allele.leavesBrimstone);
}
@@ -217,7 +208,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.GIRTH, 2);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 21);
}
@Override
@@ -245,7 +235,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.GIRTH, 2);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 21);
}
@Override
@@ -348,7 +337,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 20);
}
@Override
@@ -372,7 +360,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.AVERAGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FASTER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 19);
}
@Override
@@ -396,7 +383,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FERTILITY, EnumAllele.Saplings.LOW);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.AVERAGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 20);
}
@Override
@@ -470,8 +456,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOWEST);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWEST);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.GIRTH, 4);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.CARBONIZATION, 3);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 18);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FIREPROOF, EnumAllele.Fireproof.TRUE);
}
@@ -496,7 +480,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.FRUITS, AlleleFruit.fruitCocoa);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.FAST);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.CARBONIZATION, 5);
}
@Override
@@ -590,7 +573,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
AlleleHelper.instance.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOWER);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.GIRTH, 3);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 20);
}
@Override
@@ -658,7 +640,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
@Override
protected void setAlleles(IAllele[] alleles) {
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 20);
}
@Override
@@ -681,7 +663,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
@Override
protected void setAlleles(IAllele[] alleles) {
AlleleHelper.instance.set(alleles, EnumTreeChromosome.PLANT, AllelePlantType.plantTypeDesert);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.COMBUSTIBILITY, 20);
}
@Override
@@ -876,7 +857,6 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
@Override
protected void setAlleles(IAllele[] alleles) {
AlleleHelper.instance.set(alleles, EnumTreeChromosome.GROWTH, AlleleGrowth.growthTropical);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.HEIGHT, EnumAllele.Height.LARGE);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.SAPPINESS, EnumAllele.Sappiness.LOW);
AlleleHelper.instance.set(alleles, EnumTreeChromosome.MATURATION, EnumAllele.Maturation.SLOW);
@@ -11,20 +11,12 @@
package forestry.arboriculture.genetics;
import javax.annotation.Nonnull;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleFruit;
import forestry.api.arboriculture.IAlleleGrowth;
import forestry.api.arboriculture.IAlleleLeafEffect;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.IFruitProvider;
import forestry.api.arboriculture.IGrowthProvider;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IAlleleFloat;
@@ -33,7 +25,8 @@ import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.genetics.Genome;
import forestry.core.genetics.alleles.AllelePlantType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class TreeGenome extends Genome implements ITreeGenome {
@@ -51,7 +44,7 @@ public class TreeGenome extends Genome implements ITreeGenome {
return null;
}
IAlleleSpecies species = getSpeciesDirectly(itemStack);
IAlleleSpecies species = getSpeciesDirectly(TreeManager.treeRoot, itemStack);
if (species instanceof IAlleleTreeSpecies) {
return (IAlleleTreeSpecies) species;
}
@@ -75,11 +68,6 @@ public class TreeGenome extends Genome implements ITreeGenome {
return ((IAlleleFruit) getActiveAllele(EnumTreeChromosome.FRUITS)).getProvider();
}
@Override
public IGrowthProvider getGrowthProvider() {
return ((IAlleleGrowth) getActiveAllele(EnumTreeChromosome.GROWTH)).getProvider();
}
@Override
public float getHeight() {
return ((IAlleleFloat) getActiveAllele(EnumTreeChromosome.HEIGHT)).getValue();
@@ -100,11 +88,6 @@ public class TreeGenome extends Genome implements ITreeGenome {
return ((IAlleleFloat) getActiveAllele(EnumTreeChromosome.SAPPINESS)).getValue();
}
@Override
public EnumSet<EnumPlantType> getPlantTypes() {
return ((AllelePlantType) getActiveAllele(EnumTreeChromosome.PLANT)).getPlantTypes();
}
@Override
public int getMaturationTime() {
return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.MATURATION)).getValue();
@@ -115,16 +98,6 @@ public class TreeGenome extends Genome implements ITreeGenome {
return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.GIRTH)).getValue();
}
@Override
public int getCombustibility(){
return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.COMBUSTIBILITY)).getValue();
}
@Override
public int getCarbonization(){
return ((IAlleleInteger) getActiveAllele(EnumTreeChromosome.CARBONIZATION)).getValue();
}
@Override
public IAlleleLeafEffect getEffect() {
return (IAlleleLeafEffect) getActiveAllele(EnumTreeChromosome.EFFECT);
@@ -0,0 +1,109 @@
package forestry.arboriculture.genetics;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenome;
import forestry.arboriculture.tiles.TileSapling;
import forestry.core.tiles.TileUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
public class TreeGrowthHelper {
@Nullable
public static BlockPos canGrow(World world, ITreeGenome genome, BlockPos pos, int expectedGirth, int expectedHeight) {
BlockPos growthPos = hasSufficientSaplingsAroundSapling(genome, world, pos, expectedGirth);
if (growthPos == null) {
return null;
}
if (!hasRoom(world, growthPos, expectedGirth, expectedHeight)) {
return null;
}
return growthPos;
}
private static boolean hasRoom(World world, BlockPos pos, int expectedGirth, int expectedHeight) {
Vec3i area = new Vec3i(expectedGirth, expectedHeight + 1, expectedGirth);
return checkArea(world, pos.up(), area);
}
private static boolean checkArea(World world, BlockPos start, Vec3i area) {
for (int x = 0; x < area.getX(); x++) {
for (int y = 0; y < area.getY(); y++) {
for (int z = 0; z < area.getZ(); z++) {
BlockPos pos = start.add(x, y, z);
IBlockState blockState = world.getBlockState(pos);
if (!blockState.getBlock().isReplaceable(world, pos)) {
return false;
}
}
}
}
return true;
}
/**
* Checks an area for saplings.
* If saplings need to be 2x2, 3x3, etc, it will check all configurations in which pos is included in that area.
* Uses a knownSaplings cache to avoid checking the same saplings multiple times.
*/
@Nullable
private static BlockPos hasSufficientSaplingsAroundSapling(ITreeGenome genome, World world, BlockPos saplingPos, int expectedGirth) {
final int checkSize = (expectedGirth * 2) - 1;
final int offset = expectedGirth - 1;
final Map<BlockPos, Boolean> knownSaplings = new HashMap<>(checkSize * checkSize);
for (int x = -offset; x <= 0; x++) {
for (int z = -offset; z <= 0; z++) {
BlockPos startPos = saplingPos.add(x, 0, z);
if (checkForSaplings(genome, world, startPos, expectedGirth, knownSaplings)) {
return startPos;
}
}
}
return null;
}
private static boolean checkForSaplings(ITreeGenome genome, World world, BlockPos startPos, int girth, Map<BlockPos, Boolean> knownSaplings) {
for (int x = 0; x < girth; x++) {
for (int z = 0; z < girth; z++) {
BlockPos checkPos = startPos.add(x, 0, z);
Boolean knownSapling = knownSaplings.get(checkPos);
if (knownSapling == null) {
knownSapling = isSapling(genome, world, checkPos);
knownSaplings.put(checkPos, knownSapling);
}
if (!knownSapling) {
return false;
}
}
}
return true;
}
private static boolean isSapling(ITreeGenome genome, World world, BlockPos pos) {
if (!world.isBlockLoaded(pos)) {
return false;
}
if (world.isAirBlock(pos)) {
return false;
}
TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class);
if (sapling == null) {
return false;
}
ITree tree = sapling.getTree();
return tree != null && tree.getGenome().getPrimary().getUID().equals(genome.getPrimary().getUID());
}
}
@@ -18,23 +18,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleFruit;
@@ -65,6 +49,19 @@ import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.GeneticsUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.oredict.OreDictionary;
public class TreeRoot extends SpeciesRoot implements ITreeRoot {
@@ -423,7 +420,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot {
}
@Override
public IChromosomeType getKaryotypeKey() {
public IChromosomeType getSpeciesChromosomeType() {
return EnumTreeChromosome.SPECIES;
}
@@ -13,12 +13,6 @@ package forestry.arboriculture.genetics;
import javax.annotation.Nonnull;
import java.util.Locale;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import forestry.api.arboriculture.EnumForestryWoodType;
import forestry.api.arboriculture.IWoodProvider;
import forestry.api.arboriculture.TreeManager;
@@ -26,6 +20,11 @@ import forestry.api.arboriculture.WoodBlockKind;
import forestry.api.core.ITextureManager;
import forestry.core.config.Constants;
import forestry.core.proxy.Proxies;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class WoodProvider implements IWoodProvider {
@@ -61,4 +60,14 @@ public class WoodProvider implements IWoodProvider {
return TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
}
@Override
public int getCombustibility() {
return woodType.getCombustability();
}
@Override
public int getCarbonization() {
return woodType.getCarbonization();
}
}
@@ -12,18 +12,17 @@ package forestry.arboriculture.genetics;
import javax.annotation.Nonnull;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import forestry.api.arboriculture.EnumVanillaWoodType;
import forestry.api.arboriculture.IWoodProvider;
import forestry.api.arboriculture.TreeManager;
import forestry.api.arboriculture.WoodBlockKind;
import forestry.api.core.ITextureManager;
import forestry.core.proxy.Proxies;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
public class WoodProviderVanilla implements IWoodProvider {
@@ -80,5 +79,15 @@ public class WoodProviderVanilla implements IWoodProvider {
public ItemStack getWoodStack() {
return TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
}
@Override
public int getCombustibility() {
return woodType.getCombustability();
}
@Override
public int getCarbonization() {
return woodType.getCarbonization();
}
}
@@ -18,10 +18,13 @@ import forestry.api.arboriculture.IAlleleGrowth;
import forestry.api.arboriculture.IGrowthProvider;
import forestry.api.genetics.AlleleManager;
import forestry.arboriculture.genetics.GrowthProvider;
import forestry.arboriculture.genetics.GrowthProviderTropical;
import forestry.core.config.Constants;
import forestry.core.genetics.alleles.AlleleCategorized;
/**
* @deprecated this is being removed to simplify trees
*/
@Deprecated
public class AlleleGrowth extends AlleleCategorized implements IAlleleGrowth {
public static IAlleleGrowth growthLightLevel;
@@ -32,7 +35,7 @@ public class AlleleGrowth extends AlleleCategorized implements IAlleleGrowth {
List<IAlleleGrowth> growthAlleles = Arrays.asList(
growthLightLevel = new AlleleGrowth("lightlevel", new GrowthProvider()),
growthAcacia = new AlleleGrowth("acacia", new GrowthProvider()),
growthTropical = new AlleleGrowth("tropical", new GrowthProviderTropical())
growthTropical = new AlleleGrowth("tropical", new GrowthProvider())
);
for (IAlleleGrowth alleleGrowth : growthAlleles) {
@@ -10,12 +10,9 @@
******************************************************************************/
package forestry.arboriculture.genetics.pollination;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.arboriculture.ITree;
import forestry.api.genetics.ICheckPollinatable;
import net.minecraftforge.common.EnumPlantType;
public class CheckPollinatableTree implements ICheckPollinatable {
@@ -26,8 +23,8 @@ public class CheckPollinatableTree implements ICheckPollinatable {
}
@Override
public EnumSet<EnumPlantType> getPlantType() {
return tree.getPlantTypes();
public EnumPlantType getPlantType() {
return tree.getGenome().getPrimary().getPlantType();
}
@Override
@@ -40,9 +37,6 @@ public class CheckPollinatableTree implements ICheckPollinatable {
if (tree.getMate() != null) {
return false;
}
if (!(pollen instanceof ITree)) {
return false;
}
return !tree.isGeneticEqual(pollen);
}
@@ -10,6 +10,14 @@
******************************************************************************/
package forestry.arboriculture.items;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.blocks.BlockPile;
import forestry.arboriculture.tiles.TilePile;
import forestry.core.items.ItemBlockForestry;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.Translator;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@@ -17,15 +25,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.ITree;
import forestry.api.genetics.IAlleleSpecies;
import forestry.arboriculture.PluginArboriculture;
import forestry.arboriculture.blocks.BlockPile;
import forestry.arboriculture.tiles.TilePile;
import forestry.core.items.ItemBlockForestry;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.Translator;
public class ItemBlockPile<B extends Block> extends ItemBlockForestry<Block> {
@@ -52,12 +51,11 @@ public class ItemBlockPile<B extends Block> extends ItemBlockForestry<Block> {
if (!itemstack.hasTagCompound()) {
return "Unknown";
}
ITree tree = BlockPile.getTree(itemstack);
if (tree == null) {
IAlleleTreeSpecies species = BlockPile.getTreeSpecies(itemstack);
if (species == null) {
return "Unknown";
}
IAlleleSpecies species = tree.getGenome().getPrimary();
String customTreeKey = "for.trees.custom.pile." + species.getUnlocalizedName().replace("trees.species.", "");
if (Translator.canTranslateToLocal(customTreeKey)) {
return Translator.translateToLocal(customTreeKey);
@@ -10,6 +10,9 @@
******************************************************************************/
package forestry.arboriculture.items;
import java.util.List;
import forestry.core.utils.Translator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.material.Material;
@@ -34,6 +37,14 @@ public class ItemGrafter extends ItemForestryTool implements IToolGrafter {
setEfficiencyOnProperMaterial(4.0f);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
super.addInformation(stack, playerIn, tooltip, advanced);
if (!stack.isItemDamaged()) {
tooltip.add(Translator.translateToLocalFormatted("item.for.uses", stack.getMaxDamage() + 1));
}
}
@Override
public boolean canHarvestBlock(IBlockState state, ItemStack stack) {
Block block = state.getBlock();
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.arboriculture.items;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.arboriculture.EnumGermlingType;
@@ -28,8 +30,12 @@ public class ItemRegistryArboriculture extends ItemRegistry {
OreDictionary.registerOre(OreDictUtil.TREE_SAPLING, sapling.getWildcard());
pollenFertile = registerItem(new ItemGermlingGE(EnumGermlingType.POLLEN), "pollenFertile");
charcoal = registerItem(new ItemCharcoal(), "charcoal");
grafter = registerItem(new ItemGrafter(4), "grafter");
registerOreDict(OreDictUtil.CHARCOAL, new ItemStack(charcoal, 1, OreDictionary.WILDCARD_VALUE));
registerOreDict(OreDictUtil.CHARCOAL, new ItemStack(Items.COAL, 1, 1));
grafter = registerItem(new ItemGrafter(9), "grafter");
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
}
}
@@ -7,11 +7,9 @@ import java.util.Map;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.arboriculture.genetics.Tree;
import forestry.arboriculture.blocks.BlockPile;
import forestry.arboriculture.genetics.TreeDefinition;
import forestry.arboriculture.tiles.TilePile;
import forestry.core.blocks.propertys.UnlistedBlockAccess;
@@ -62,9 +60,9 @@ public class ModelWoodPile extends BlankItemModel{
if(pile == null){
return Collections.emptyList();
}
ITree tree = pile.getTree();
if (tree == null) {
tree = TreeManager.treeRoot.templateAsIndividual(TreeManager.treeRoot.getDefaultTemplate());
IAlleleTreeSpecies treeSpecies = pile.getTreeSpecies();
if (treeSpecies == null) {
treeSpecies = (IAlleleTreeSpecies) TreeManager.treeRoot.getDefaultTemplate()[TreeManager.treeRoot.getSpeciesChromosomeType().ordinal()];
}
if (modelWoodPileBlock == null) {
@@ -77,8 +75,8 @@ public class ModelWoodPile extends BlankItemModel{
return Collections.emptyList();
}
}
IBakedModel model = bakeModel(tree, false);
IBakedModel model = bakeModel(treeSpecies, false);
return model.getQuads(state, side, rand);
}
return Collections.emptyList();
@@ -103,10 +101,9 @@ public class ModelWoodPile extends BlankItemModel{
protected ItemOverrideList createOverrides() {
return new PileItemOverrideList();
}
private IBakedModel bakeModel(ITree tree, boolean isItem) {
private IBakedModel bakeModel(IAlleleTreeSpecies treeSpecies, boolean isItem) {
ImmutableMap.Builder<String, String> textures = ImmutableMap.builder();
IAlleleTreeSpecies treeSpecies = tree.getGenome().getPrimary();
String treeUID = treeSpecies.getUID();
Map<String, IBakedModel> map = isItem ? itemCache : blockCache;
if(!map.containsKey(treeUID)){
@@ -135,14 +132,11 @@ public class ModelWoodPile extends BlankItemModel{
return null;
}
}
ITree tree = null;
if(stack.hasTagCompound()){
tree = new Tree(stack.getTagCompound().getCompoundTag("ContainedTree"));
IAlleleTreeSpecies treeSpecies = BlockPile.getTreeSpecies(stack);
if (treeSpecies == null) {
treeSpecies = (IAlleleTreeSpecies) TreeManager.treeRoot.getDefaultTemplate()[TreeManager.treeRoot.getSpeciesChromosomeType().ordinal()];
}
if (tree == null) {
tree = TreeManager.treeRoot.templateAsIndividual(TreeManager.treeRoot.getDefaultTemplate());
}
return bakeModel(tree, true);
return bakeModel(treeSpecies, true);
}
}
@@ -4,13 +4,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.IWoodProvider;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.multiblock.ICharcoalPileComponent;
@@ -28,6 +23,11 @@ import forestry.core.network.DataOutputStreamForestry;
import forestry.core.proxy.Proxies;
import forestry.core.utils.Log;
import forestry.core.utils.Translator;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class CharcoalPileController extends RectangularMultiblockControllerBase implements ICharcoalPileControllerInternal {
@@ -115,11 +115,12 @@ public class CharcoalPileController extends RectangularMultiblockControllerBase
if(woodBurnTime == 0){
int comps = 0;
int newBurnTime = 0;
for(IMultiblockComponent part : connectedParts){
for (IMultiblockComponent part : connectedParts) {
ICharcoalPileComponent comp = (ICharcoalPileComponent) part;
if(comp.getTree() != null){
if (comp.getTreeSpecies() != null) {
comps++;
newBurnTime+= comp.getTree().getGenome().getCombustibility() * 1000;
IWoodProvider woodProvider = comp.getTreeSpecies().getWoodProvider();
newBurnTime += woodProvider.getCombustibility() * 1000;
}
}
woodBurnTime = newBurnTime / comps;
@@ -12,18 +12,10 @@ package forestry.arboriculture.render;
import javax.annotation.Nonnull;
import static forestry.arboriculture.multiblock.EnumPilePosition.BACK;
import static forestry.arboriculture.multiblock.EnumPilePosition.CORNER_BACK_LEFT;
import static forestry.arboriculture.multiblock.EnumPilePosition.CORNER_BACK_RIGHT;
import static forestry.arboriculture.multiblock.EnumPilePosition.FRONT;
import static forestry.arboriculture.multiblock.EnumPilePosition.CORNER_FRONT_LEFT;
import static forestry.arboriculture.multiblock.EnumPilePosition.CORNER_FRONT_RIGHT;
import static forestry.arboriculture.multiblock.EnumPilePosition.SIDE_LEFT;
import static forestry.arboriculture.multiblock.EnumPilePosition.SIDE_RIGHT;
import static forestry.arboriculture.multiblock.EnumPilePosition.*;
import forestry.api.arboriculture.EnumPileType;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.arboriculture.blocks.BlockPile;
import forestry.arboriculture.multiblock.EnumPilePosition;
@@ -67,11 +59,10 @@ public class CharcoalPileRenderer extends TileEntitySpecialRenderer<TilePile> {
boolean isOnTop = logic.getController().getMaximumCoord().getY() == pile.getPos().getY();
// TODO Add brightness to the textures.
int brightness = state.getPackedLightmapCoords(pile.getWorld(), pile.getPos());
ITree tree = pile.getNextWoodPile();
if (tree == null) {
tree = TreeManager.treeRoot.templateAsIndividual(TreeManager.treeRoot.getDefaultTemplate());
IAlleleTreeSpecies treeSpecies = pile.getNextWoodPile();
if (treeSpecies == null) {
treeSpecies = (IAlleleTreeSpecies) TreeManager.treeRoot.getDefaultTemplate()[TreeManager.treeRoot.getSpeciesChromosomeType().ordinal()];
}
IAlleleTreeSpecies treeSpecies = tree.getGenome().getPrimary();
TextureAtlasSprite dirtSprite;
if(pile.getPileType() == EnumPileType.ASH){
dirtSprite = TextureManager.registerSprite(new ResourceLocation("forestry:blocks/ash"));
@@ -1,18 +1,17 @@
package forestry.arboriculture.render;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleDigging;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.arboriculture.EnumPileType;
import forestry.arboriculture.blocks.BlockPile;
import forestry.arboriculture.tiles.TilePile;
import forestry.core.render.ParticleHelper;
import forestry.core.render.TextureManager;
import forestry.core.tiles.TileUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleDigging;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class PileParticleCallback extends ParticleHelper.DefaultCallback<BlockPile>{
@@ -25,14 +24,14 @@ public class PileParticleCallback extends ParticleHelper.DefaultCallback<BlockPi
EnumPileType type = block.getPileType();
TilePile pile = TileUtil.getTile(world, pos, TilePile.class);
TextureAtlasSprite texture;
if(type == EnumPileType.DIRT){
if (type == EnumPileType.DIRT) {
texture = TextureManager.registerSprite(new ResourceLocation("forestry:blocks/loam"));
}else if(type == EnumPileType.WOOD){
if(pile == null || pile.getTree() == null){
} else if (type == EnumPileType.WOOD) {
if (pile == null || pile.getTreeSpecies() == null) {
super.setTexture(fx, world, pos, state);
return;
}
texture = pile.getTree().getGenome().getPrimary().getWoodProvider().getSprite(false);
texture = pile.getTreeSpecies().getWoodProvider().getSprite(false);
}else{
texture = TextureManager.registerSprite(new ResourceLocation("forestry:blocks/ash"));
}
@@ -15,20 +15,9 @@ import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.IFruitProvider;
@@ -59,6 +48,14 @@ import forestry.core.network.packets.PacketTileStream;
import forestry.core.proxy.Proxies;
import forestry.core.utils.ColourUtil;
import forestry.core.utils.GeneticsUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery, IRipeningPacketReceiver {
@@ -258,13 +255,13 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
/* IPOLLINATABLE */
@Override
public EnumSet<EnumPlantType> getPlantType() {
public EnumPlantType getPlantType() {
ITree tree = getTree();
if (tree == null) {
return EnumSet.noneOf(EnumPlantType.class);
return EnumPlantType.Plains;
}
return tree.getPlantTypes();
return tree.getGenome().getPrimary().getPlantType();
}
@Override
@@ -2,20 +2,9 @@ package forestry.arboriculture.tiles;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
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.arboriculture.EnumPileType;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IAllele;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.genetics.AlleleManager;
import forestry.api.multiblock.ICharcoalPileComponent;
import forestry.api.multiblock.IMultiblockController;
import forestry.arboriculture.PluginArboriculture;
@@ -25,11 +14,18 @@ import forestry.arboriculture.multiblock.EnumPilePosition;
import forestry.arboriculture.multiblock.MultiblockLogicCharcoalPile;
import forestry.core.multiblock.MultiblockTileEntityForestry;
import forestry.core.tiles.TileUtil;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class TilePile extends MultiblockTileEntityForestry<MultiblockLogicCharcoalPile> implements ICharcoalPileComponent<MultiblockLogicCharcoalPile>{
@Nonnull
private ITree containedTree;
private IAlleleTreeSpecies treeSpecies;
@SideOnly(Side.CLIENT)
private BlockPos woodPos;
@@ -53,7 +49,7 @@ public class TilePile extends MultiblockTileEntityForestry<MultiblockLogicCharco
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) {
Block newBlock = newState.getBlock();
return oldState.getBlock() != newState.getBlock() && newState.getBlock() != PluginArboriculture.blocks.piles.get(EnumPileType.ASH);
return oldState.getBlock() != newBlock && newBlock != PluginArboriculture.blocks.piles.get(EnumPileType.ASH);
}
@Override
@@ -131,20 +127,20 @@ public class TilePile extends MultiblockTileEntityForestry<MultiblockLogicCharco
return getBlockType().getDefaultState().withProperty(BlockPile.PILE_POSITION, pileType);
}
private static ITree getTree(String speciesUID) {
IAllele[] treeTemplate = TreeManager.treeRoot.getTemplate(speciesUID);
if (treeTemplate == null) {
return null;
}
return TreeManager.treeRoot.templateAsIndividual(treeTemplate);
}
@Override
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
// legacy
if (data.hasKey("ContainedTree")) {
setTree(new Tree(data.getCompoundTag("ContainedTree")));
Tree containedTree = new Tree(data.getCompoundTag("ContainedTree"));
setTreeSpecies(containedTree.getGenome().getPrimary());
}
if (data.hasKey("TreeSpecies")) {
String treeSpeciesUid = data.getString("TreeSpecies");
IAlleleTreeSpecies treeSpecies = (IAlleleTreeSpecies) AlleleManager.alleleRegistry.getAllele(treeSpeciesUid);
setTreeSpecies(treeSpecies);
}
}
@@ -152,11 +148,8 @@ public class TilePile extends MultiblockTileEntityForestry<MultiblockLogicCharco
@Override
public NBTTagCompound writeToNBT(NBTTagCompound data) {
data = super.writeToNBT(data);
if (containedTree != null) {
NBTTagCompound subcompound = new NBTTagCompound();
containedTree.writeToNBT(subcompound);
data.setTag("ContainedTree", subcompound);
if (treeSpecies != null) {
data.setString("TreeSpecies", treeSpecies.getUID());
}
return data;
}
@@ -164,18 +157,18 @@ public class TilePile extends MultiblockTileEntityForestry<MultiblockLogicCharco
@Override
protected void encodeDescriptionPacket(NBTTagCompound packetData) {
super.encodeDescriptionPacket(packetData);
if (containedTree != null) {
NBTTagCompound subcompound = new NBTTagCompound();
containedTree.writeToNBT(subcompound);
packetData.setTag("ContainedTree", subcompound);
if (treeSpecies != null) {
packetData.setString("TreeSpecies", treeSpecies.getUID());
}
}
@Override
protected void decodeDescriptionPacket(NBTTagCompound packetData) {
super.decodeDescriptionPacket(packetData);
if (packetData.hasKey("ContainedTree")) {
setTree(new Tree(packetData.getCompoundTag("ContainedTree")));
if (packetData.hasKey("TreeSpecies")) {
String treeSpeciesUid = packetData.getString("TreeSpecies");
IAlleleTreeSpecies treeSpecies = (IAlleleTreeSpecies) AlleleManager.alleleRegistry.getAllele(treeSpeciesUid);
setTreeSpecies(treeSpecies);
}
}
@@ -183,17 +176,16 @@ public class TilePile extends MultiblockTileEntityForestry<MultiblockLogicCharco
/* CONTAINED TREE */
@Override
public void setTree(@Nonnull ITree tree) {
this.containedTree = tree;
public void setTreeSpecies(@Nonnull IAlleleTreeSpecies treeSpecies) {
this.treeSpecies = treeSpecies;
if (worldObj != null && worldObj.isRemote) {
worldObj.markBlockRangeForRenderUpdate(getPos(), getPos());
}
}
@Override
@Nonnull
public ITree getTree() {
return this.containedTree;
public IAlleleTreeSpecies getTreeSpecies() {
return this.treeSpecies;
}
@Override
@@ -204,13 +196,13 @@ public class TilePile extends MultiblockTileEntityForestry<MultiblockLogicCharco
@Override
@SideOnly(Side.CLIENT)
public ITree getNextWoodPile(){
public IAlleleTreeSpecies getNextWoodPile() {
if(woodPos == null){
woodPos = getNextWoodPilePos();
}
TilePile pile = TileUtil.getTile(worldObj, woodPos, TilePile.class);
if(pile != null){
return pile.getTree();
if (pile != null) {
return pile.getTreeSpecies();
}
return null;
}
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
import forestry.arboriculture.blocks.BlockSapling;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -61,6 +62,7 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
}
if (genPos != null) {
clearSaplings(world, genPos);
List<BlockPos> branchEnds = new ArrayList<>(generateTrunk(world, rand, wood, genPos));
Collections.sort(branchEnds, TopDownBlockPosComparator.INSTANCE);
generateLeaves(world, rand, leaf, branchEnds, genPos);
@@ -96,6 +98,18 @@ public abstract class WorldGenArboriculture extends WorldGenBase {
@Nullable
public abstract BlockPos getValidGrowthPos(World world, BlockPos pos);
public void clearSaplings(World world, BlockPos genPos) {
int treeGirth = tree.getGirth();
for (int x = 0; x < treeGirth; x++) {
for (int z = 0; z < treeGirth; z++) {
BlockPos saplingPos = genPos.add(x, 0, z);
if (world.getBlockState(saplingPos).getBlock() instanceof BlockSapling) {
world.setBlockToAir(saplingPos);
}
}
}
}
public boolean hasPods() {
return tree.allowsFruitBlocks();
}
@@ -10,18 +10,14 @@
******************************************************************************/
package forestry.arboriculture.worldgen;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Set;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.world.ITreeGenData;
import forestry.core.worldgen.WorldGenHelper;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class WorldGenBalsa extends WorldGenTree {
@@ -31,7 +27,8 @@ public class WorldGenBalsa extends WorldGenTree {
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
BlockPos.MutableBlockPos leafCenter = new BlockPos.MutableBlockPos(startPos.add(0, height, 0));
BlockPos topPos = startPos.add(0, height + 1, 0);
BlockPos.MutableBlockPos leafCenter = new BlockPos.MutableBlockPos(topPos);
float leafRadius = (girth - 1.0f) / 2.0f;
WorldGenHelper.addBlock(world, leafCenter, leaf, WorldGenHelper.EnumReplaceMode.AIR);
@@ -44,7 +41,7 @@ public class WorldGenBalsa extends WorldGenTree {
leafCenter.move(EnumFacing.DOWN);
}
while (leafCenter.getY() > 6) {
while (leafCenter.getY() > topPos.getY() - 6) {
WorldGenHelper.generateCylinderFromPos(world, leaf, leafCenter, leafRadius + girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
leafCenter.move(EnumFacing.DOWN);
}
@@ -47,12 +47,13 @@ public class WorldGenCherry extends WorldGenTree {
@Override
protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List<BlockPos> branchEnds, BlockPos startPos) {
int leafSpawn = height + 1;
int leafSpawn = height + 2;
WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn--, 0), girth, girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn, 0), girth, (float) 1 + girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
WorldGenHelper.generateCylinderFromTreeStartPos(world, leaf, startPos.add(0, leafSpawn, 0), girth, 1 + girth, 1, WorldGenHelper.EnumReplaceMode.SOFT);
for (BlockPos branchEnd : branchEnds) {
WorldGenHelper.generateCircle(world, rand, branchEnd, 4, 3, 2, leaf, 1.0f, WorldGenHelper.EnumReplaceMode.AIR);
WorldGenHelper.generateCircle(world, rand, branchEnd.up(), 3, 3, 1, leaf, 1.0f, WorldGenHelper.EnumReplaceMode.AIR);
WorldGenHelper.generateCircle(world, rand, branchEnd, 4, 3, 1, leaf, 1.0f, WorldGenHelper.EnumReplaceMode.AIR);
}
}
}
@@ -31,11 +31,10 @@ public class WorldGenEbony extends WorldGenTree {
@Nonnull
@Override
public Set<BlockPos> generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) {
int offset = (girth - 1) / 2;
int trunksGenerated = 0;
for (int x = -offset; x < -offset + girth; x++) {
for (int z = -offset; z < -offset + girth; z++) {
for (int x = 0; x < girth; x++) {
for (int z = 0; z < girth; z++) {
if (rand.nextFloat() < 0.6f) {
for (int y = 0; y < height; y++) {
WorldGenHelper.addBlock(world, startPos.add(x, y, z), wood, WorldGenHelper.EnumReplaceMode.ALL);
@@ -68,8 +67,8 @@ public class WorldGenEbony extends WorldGenTree {
h = height / 2 + rand.nextInt(height / 2);
}
int x_off = -girth + rand.nextInt(2 * girth);
int y_off = -girth + rand.nextInt(2 * girth);
int x_off = rand.nextInt(girth);
int y_off = rand.nextInt(girth);
BlockPos center = startPos.add(x_off, h, y_off);
int radius = 1 + rand.nextInt(girth);
@@ -74,7 +74,7 @@ public abstract class WorldGenTree extends WorldGenArboriculture {
public final void preGenerate(World world, Random rand, BlockPos startPos) {
super.preGenerate(world, rand, startPos);
height = determineHeight(world, rand, baseHeight, heightVariation);
girth = tree.getGirth(world, startPos);
girth = tree.getGirth();
}
protected int modifyByHeight(World world, int val, int min, int max) {
@@ -69,5 +69,6 @@ public class BlockRegistryCore extends BlockRegistry {
// register some common oreDict names for our recipes
OreDictionary.registerOre(OreDictUtil.CRAFTING_TABLE_WOOD, Blocks.CRAFTING_TABLE);
OreDictionary.registerOre(OreDictUtil.TRAPDOOR_WOOD, Blocks.TRAPDOOR);
}
}
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.core.config;
import com.google.common.collect.LinkedListMultimap;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -24,13 +22,13 @@ import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import net.minecraftforge.common.config.Property;
import com.google.common.collect.LinkedListMultimap;
import forestry.Forestry;
import forestry.core.fluids.Fluids;
import forestry.core.utils.Log;
import forestry.core.utils.Translator;
import forestry.mail.gui.GuiMailboxInfo;
import net.minecraftforge.common.config.Property;
public class Config {
@@ -54,7 +52,6 @@ public class Config {
public static boolean enableParticleFX = true;
// Genetics
public static boolean clearInvalidChromosomes = false;
public static boolean pollinateVanillaTrees = true;
public static float researchMutationBoostMultiplier = 1.5f;
public static float maxResearchMutationBoostPercent = 5.0f;
@@ -204,7 +201,6 @@ public class Config {
collectorStamps.addAll(Arrays.asList(defaultCollectors));
}
clearInvalidChromosomes = configCommon.getBooleanLocalized("genetics", "clear.invalid.chromosomes", clearInvalidChromosomes);
pollinateVanillaTrees = configCommon.getBooleanLocalized("genetics", "pollinate.vanilla.trees", pollinateVanillaTrees);
researchMutationBoostMultiplier = configCommon.getFloatLocalized("genetics.research.boost", "multiplier", researchMutationBoostMultiplier, 1.0f, 1000.f);
maxResearchMutationBoostPercent = configCommon.getFloatLocalized("genetics.research.boost", "max.percent", maxResearchMutationBoostPercent, 0.0f, 100.0f);
@@ -104,8 +104,10 @@ public abstract class EntityMinecartForestry extends EntityMinecart implements I
@Override
public void killMinecart(DamageSource damageSource) {
super.killMinecart(damageSource);
Block block = getDisplayTile().getBlock();
entityDropItem(new ItemStack(block, 1, block.getMetaFromState(getDisplayTile())), 0.0F);
if (this.worldObj.getGameRules().getBoolean("doEntityDrops")) {
Block block = getDisplayTile().getBlock();
entityDropItem(new ItemStack(block), 0.0F);
}
}
// fix cart contents rendering as black in the End dimension
@@ -11,14 +11,15 @@
package forestry.core.genetics;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Random;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.core.utils.Log;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.nbt.NBTTagCompound;
public class Chromosome implements IChromosome {
@@ -30,7 +31,37 @@ public class Chromosome implements IChromosome {
@Nonnull
private final IAllele secondary;
// / CONSTRUCTOR
@Nonnull
public static Chromosome create(@Nullable String primarySpeciesUid, @Nullable String secondarySpeciesUid, @Nonnull IChromosomeType chromosomeType, @Nonnull NBTTagCompound nbt) {
IAllele primary = AlleleManager.alleleRegistry.getAllele(nbt.getString(UID0_TAG));
IAllele secondary = AlleleManager.alleleRegistry.getAllele(nbt.getString(UID1_TAG));
primary = validateAllele(primarySpeciesUid, chromosomeType, primary);
secondary = validateAllele(secondarySpeciesUid, chromosomeType, secondary);
return new Chromosome(primary, secondary);
}
@Nonnull
private static IAllele validateAllele(@Nullable String speciesUid, @Nonnull IChromosomeType chromosomeType, @Nullable IAllele allele) {
if (!chromosomeType.getAlleleClass().isInstance(allele)) {
ISpeciesRoot speciesRoot = chromosomeType.getSpeciesRoot();
IAllele[] template = null;
if (speciesUid != null) {
template = speciesRoot.getTemplate(speciesUid);
}
if (template == null) {
template = speciesRoot.getDefaultTemplate();
}
return template[chromosomeType.ordinal()];
}
return allele;
}
public Chromosome(@Nonnull IAllele allele) {
primary = secondary = allele;
}
@@ -40,11 +71,6 @@ public class Chromosome implements IChromosome {
this.secondary = secondary;
}
public Chromosome(@Nonnull NBTTagCompound nbt) {
primary = AlleleManager.alleleRegistry.getAllele(nbt.getString(UID0_TAG));
secondary = AlleleManager.alleleRegistry.getAllele(nbt.getString(UID1_TAG));
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setString(UID0_TAG, primary.getUID());
@@ -64,9 +90,6 @@ public class Chromosome implements IChromosome {
@Override
public IAllele getActiveAllele() {
if (primary == null || secondary == null) {
return null;
}
if (primary.isDominant()) {
return primary;
}
@@ -89,38 +112,6 @@ public class Chromosome implements IChromosome {
return secondary;
}
public IAllele getRandomAllele(Random rand) {
if (rand.nextBoolean()) {
return primary;
} else {
return secondary;
}
}
public boolean hasInvalidAlleles(Class<? extends IAllele> chromosomeClass) {
if (primary == null) {
Log.warning("Missing primary allele: {}", this);
return true;
}
if (!chromosomeClass.isInstance(primary)) {
Log.warning("Wrong primary allele for: {}. Should be: {}", this, chromosomeClass.getSimpleName());
return true;
}
if (secondary == null) {
Log.warning("Missing secondary allele: {}", this);
return true;
}
if (!chromosomeClass.isInstance(secondary)) {
Log.warning("Wrong secondary allele for: {}. Should be: {}", this, chromosomeClass.getSimpleName());
return true;
}
return false;
}
/* HELPER FUNCTIONS */
public static IChromosome inheritChromosome(Random rand, IChromosome parent1, IChromosome parent2) {
@@ -10,23 +10,20 @@
******************************************************************************/
package forestry.core.genetics;
import com.google.common.base.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import com.google.common.base.Objects;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.config.Config;
import forestry.core.utils.Log;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public abstract class Genome implements IGenome {
@@ -115,15 +112,12 @@ public abstract class Genome implements IGenome {
* Quickly gets the species without loading the whole genome.
* We need this because the client uses the species for rendering.
*/
public static IAlleleSpecies getSpeciesDirectly(ItemStack itemStack) {
@Nullable
public static IAlleleSpecies getSpeciesDirectly(@Nonnull ISpeciesRoot speciesRoot, @Nonnull ItemStack itemStack) {
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
if (nbtTagCompound == null) {
return null;
}
return getSpeciesDirectly(nbtTagCompound);
}
public static IAlleleSpecies getSpeciesDirectly(@Nonnull NBTTagCompound nbtTagCompound) {
NBTTagCompound genomeNBT = nbtTagCompound.getCompoundTag("Genome");
if (genomeNBT == null) {
@@ -136,7 +130,7 @@ public abstract class Genome implements IGenome {
}
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(0);
Chromosome chromosome = new Chromosome(chromosomeNBT);
Chromosome chromosome = Chromosome.create(null, null, speciesRoot.getSpeciesChromosomeType(), chromosomeNBT);
IAllele activeAllele = chromosome.getActiveAllele();
if (!(activeAllele instanceof IAlleleSpecies)) {
@@ -170,23 +164,21 @@ public abstract class Genome implements IGenome {
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
IChromosome[] chromosomes = new IChromosome[speciesRoot.getDefaultTemplate().length];
String primarySpeciesUid = null;
String secondarySpeciesUid = null;
for (int i = 0; i < chromosomesNBT.tagCount(); i++) {
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i);
byte chromosomeOrdinal = chromosomeNBT.getByte(SLOT_TAG);
if (chromosomeOrdinal >= 0 && chromosomeOrdinal < chromosomes.length) {
Chromosome chromosome = new Chromosome(chromosomeNBT);
IChromosomeType chromosomeType = speciesRoot.getKaryotype()[chromosomeOrdinal];
Chromosome chromosome = Chromosome.create(primarySpeciesUid, secondarySpeciesUid, chromosomeType, chromosomeNBT);
chromosomes[chromosomeOrdinal] = chromosome;
IChromosomeType chromosomeType = speciesRoot.getKaryotype()[chromosomeOrdinal];
if (chromosome.hasInvalidAlleles(chromosomeType.getAlleleClass())) {
if (Config.clearInvalidChromosomes) {
Log.warning("Found Chromosome with invalid Alleles. Config is set to clear invalid chromosomes, replacing with the default.");
IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
return speciesRoot.templateAsChromosomes(defaultTemplate);
} else {
throw new RuntimeException("Found Chromosome with invalid Alleles.\nNBTTagCompound: " + chromosomesNBT + "\nSee config option \"genetics.clear.invalid.chromosomes\".\nMissing: " + chromosomeNBT);
}
if (chromosomeOrdinal == speciesRoot.getSpeciesChromosomeType().ordinal()) {
primarySpeciesUid = chromosome.getPrimaryAllele().getUID();
secondarySpeciesUid = chromosome.getSecondaryAllele().getUID();
}
}
}
@@ -14,19 +14,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
@@ -38,6 +26,16 @@ import forestry.core.items.ItemForestry;
import forestry.core.proxy.Proxies;
import forestry.core.utils.PlayerUtil;
import forestry.core.utils.Translator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
public class ItemResearchNote extends ItemForestry {
@@ -94,7 +92,7 @@ public class ItemResearchNote extends ItemForestry {
String species2 = encoded.getAllele1().getName();
String mutationChanceKey = EnumMutateChance.rateChance(encoded.getBaseChance()).toString().toLowerCase(Locale.ENGLISH);
String mutationChance = Translator.translateToLocal("for.researchNote.chance." + mutationChanceKey);
String speciesResult = encoded.getTemplate()[root.getKaryotypeKey().ordinal()].getName();
String speciesResult = encoded.getTemplate()[root.getSpeciesChromosomeType().ordinal()].getName();
tooltips.add(Translator.translateToLocal("for.researchNote.discovery.0"));
tooltips.add(Translator.translateToLocal("for.researchNote.discovery.1").replace("%SPEC1", species1).replace("%SPEC2", species2));
@@ -147,7 +145,7 @@ public class ItemResearchNote extends ItemForestry {
IAlleleSpecies species0 = encoded.getAllele0();
IAlleleSpecies species1 = encoded.getAllele1();
IAlleleSpecies speciesResult = (IAlleleSpecies) encoded.getTemplate()[root.getKaryotypeKey().ordinal()];
IAlleleSpecies speciesResult = (IAlleleSpecies) encoded.getTemplate()[root.getSpeciesChromosomeType().ordinal()];
tracker.registerSpecies(species0);
tracker.registerSpecies(species1);
@@ -20,14 +20,13 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.item.ItemStack;
public abstract class SpeciesRoot implements ISpeciesRoot {
@@ -82,8 +81,8 @@ public abstract class SpeciesRoot implements ISpeciesRoot {
/* MUTATIONS */
@Override
public Collection<? extends IMutation> getCombinations(IAllele other) {
ArrayList<IMutation> combinations = new ArrayList<>();
public List<IMutation> getCombinations(IAllele other) {
List<IMutation> combinations = new ArrayList<>();
for (IMutation mutation : getMutations(false)) {
if (mutation.isPartner(other)) {
combinations.add(mutation);
@@ -11,20 +11,17 @@
package forestry.core.genetics.alleles;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IAlleleSpeciesBuilder;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
@@ -33,6 +30,9 @@ import forestry.apiculture.items.ItemRegistryApiculture;
import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Translator;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuilder, IAlleleSpecies {
private final String binomial;
@@ -103,7 +103,7 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil
if (complexityOverride != null) {
return complexityOverride;
}
return GeneticsUtil.getResearchComplexity(this, getRoot().getKaryotypeKey());
return GeneticsUtil.getResearchComplexity(this, getRoot().getSpeciesChromosomeType());
}
@Override
@@ -113,20 +113,30 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil
@Override
public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
ItemStack research = null;
if (world.rand.nextFloat() < (float) 10 / bountyLevel) {
Collection<? extends IMutation> combinations = getRoot().getCombinations(this);
if (!combinations.isEmpty()) {
IMutation[] candidates = combinations.toArray(new IMutation[combinations.size()]);
research = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, candidates[world.rand.nextInt(candidates.length)]);
if (world.rand.nextFloat() < bountyLevel / 32.0f) {
List<? extends IMutation> allMutations = getRoot().getCombinations(this);
if (!allMutations.isEmpty()) {
List<IMutation> unresearchedMutations = new ArrayList<>();
IBreedingTracker tracker = individual.getGenome().getSpeciesRoot().getBreedingTracker(world, researcher);
for (IMutation mutation : allMutations) {
if (!tracker.isResearched(mutation)) {
unresearchedMutations.add(mutation);
}
}
IMutation chosenMutation;
if (!unresearchedMutations.isEmpty()) {
chosenMutation = unresearchedMutations.get(world.rand.nextInt(unresearchedMutations.size()));
} else {
chosenMutation = allMutations.get(world.rand.nextInt(allMutations.size()));
}
ItemStack researchNote = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, chosenMutation);
return new ItemStack[]{researchNote};
}
}
if (research != null) {
return new ItemStack[]{research};
} else {
return ItemStackUtil.EMPTY_STACK_ARRAY;
}
return ItemStackUtil.EMPTY_STACK_ARRAY;
}
@Override
@@ -14,13 +14,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.BiomeDictionary;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IAllele;
@@ -29,6 +22,10 @@ import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.IMutationBuilder;
import forestry.api.genetics.IMutationCondition;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.BiomeDictionary;
public abstract class Mutation implements IMutation, IMutationBuilder {
@@ -109,14 +106,14 @@ public abstract class Mutation implements IMutation, IMutationBuilder {
}
@Override
public Mutation requireResource(IBlockState blockState) {
IMutationCondition mutationCondition = new MutationConditionRequiresResource(blockState);
public Mutation requireResource(IBlockState... acceptedBlockStates) {
IMutationCondition mutationCondition = new MutationConditionRequiresResource(acceptedBlockStates);
return addMutationCondition(mutationCondition);
}
@Override
public Mutation requireResource(String oreName) {
IMutationCondition mutationCondition = new MutationConditionRequiresResourceOreDict(oreName);
IMutationCondition mutationCondition = new MutationConditionRequiresResource(oreName);
return addMutationCondition(mutationCondition);
}
@@ -10,38 +10,63 @@
******************************************************************************/
package forestry.core.genetics.mutations;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutationCondition;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Translator;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
public class MutationConditionRequiresResource implements IMutationCondition {
private final IBlockState requiredBlockState;
private final Set<IBlockState> acceptedBlockStates = new HashSet<>();
private final String displayName;
public MutationConditionRequiresResource(IBlockState requiredBlockState) {
this.requiredBlockState = requiredBlockState;
public MutationConditionRequiresResource(String oreDictName) {
this.displayName = oreDictName;
for (ItemStack ore : OreDictionary.getOres(oreDictName)) {
if (ore != null) {
Item oreItem = ore.getItem();
if (oreItem != null) {
Block oreBlock = Block.getBlockFromItem(oreItem);
if (oreBlock != null) {
this.acceptedBlockStates.addAll(oreBlock.getBlockState().getValidStates());
}
}
}
}
}
public MutationConditionRequiresResource(IBlockState... acceptedBlockStates) {
Collections.addAll(this.acceptedBlockStates, acceptedBlockStates);
this.displayName = acceptedBlockStates[0].getBlock().getLocalizedName();
}
@Override
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
IBlockState blockState;
TileEntity tile;
do {
pos = pos.down();
blockState = world.getBlockState(pos);
} while (blockState.getBlock() instanceof IBeeHousing);
tile = world.getTileEntity(pos);
} while (tile instanceof IBeeHousing);
return this.requiredBlockState == blockState ? 1 : 0;
IBlockState blockState = world.getBlockState(pos);
return this.acceptedBlockStates.contains(blockState) ? 1 : 0;
}
@Override
public String getDescription() {
return Translator.translateToLocalFormatted("for.mutation.condition.resource", requiredBlockState.getBlock().getLocalizedName());
return Translator.translateToLocalFormatted("for.mutation.condition.resource", displayName);
}
}
@@ -1,71 +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.core.genetics.mutations;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IMutationCondition;
import forestry.core.utils.Translator;
public class MutationConditionRequiresResourceOreDict implements IMutationCondition {
private final int oreDictId;
private final String displayName;
public MutationConditionRequiresResourceOreDict(String oreDictName) {
this.oreDictId = OreDictionary.getOreID(oreDictName);
List<ItemStack> ores = OreDictionary.getOres(oreDictName);
if (ores != null && !ores.isEmpty()) {
this.displayName = ores.get(0).getDisplayName();
} else {
this.displayName = oreDictName;
}
}
@Override
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
Block block;
int meta;
int i = 1;
do {
BlockPos blockPos = new BlockPos(pos.getX(), pos.getY() - i, pos.getY());
IBlockState blockState = world.getBlockState(blockPos);
block = blockState.getBlock();
meta = block.getMetaFromState(blockState);
i++;
} while (block instanceof IBeeHousing);
int[] oreIds = OreDictionary.getOreIDs(new ItemStack(block, 1, meta));
for (int oreId : oreIds) {
if (oreId == this.oreDictId) {
return 1;
}
}
return 0;
}
@Override
public String getDescription() {
return Translator.translateToLocalFormatted("for.mutation.condition.resource", displayName);
}
}
@@ -23,16 +23,11 @@ import forestry.core.tiles.EscritoireGame;
import forestry.core.tiles.TileEscritoire;
public class ContainerEscritoire extends ContainerTile<TileEscritoire> implements IGuiSelectable {
private final EntityPlayer player;
private long lastUpdate;
public ContainerEscritoire(EntityPlayer player, TileEscritoire tile) {
super(tile, player.inventory, 34, 153);
this.player = player;
// Analyze slot
addSlotToContainer(new SlotFiltered(this.tile, InventoryEscritoire.SLOT_ANALYZE, 97, 67).setPickupWatcher(this.tile).setStackLimit(1));
@@ -54,7 +49,7 @@ public class ContainerEscritoire extends ContainerTile<TileEscritoire> implement
long gameLastUpdate = tile.getGame().getLastUpdate();
if (lastUpdate != gameLastUpdate) {
lastUpdate = gameLastUpdate;
Proxies.net.sendToPlayer(new PacketGuiUpdate(tile), player);
sendPacketToListeners(new PacketGuiUpdate(tile));
}
}
@@ -31,7 +31,7 @@ public class SlotWorking extends SlotForestry {
}
@Override
public boolean getHasStack() {
public boolean canTakeStack(EntityPlayer stack) {
return false;
}
@@ -91,6 +91,7 @@ public class GameTokenWidget extends Widget {
@Override
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
game.choose(index);
Proxies.net.sendToServer(new PacketGuiSelectRequest(index, 0));
}
}
@@ -59,7 +59,6 @@ public class ItemPipette extends ItemForestry implements IToolPipette, IFluidCon
}
contained = new PipetteContents(new FluidStack(liquid, filled));
filled = liquid.amount;
} else {
if (contained.getContents().amount >= limit) {
return 0;
@@ -141,7 +140,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette, IFluidCon
contained.getContents().amount -= drained;
if (contained.getContents().amount <= 0) {
pipette.setTagCompound(null);
pipette.setTagCompound(new NBTTagCompound());
pipette.setItemDamage(0);
} else {
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -6,8 +6,9 @@ import forestry.core.utils.Translator;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
public abstract class ForestryRecipeCategory extends BlankRecipeCategory {
public abstract class ForestryRecipeCategory<T extends IRecipeWrapper> extends BlankRecipeCategory<T> {
@Nonnull
private final IDrawable background;
@Nonnull
@@ -1,72 +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.core.recipes.jei;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidContainerItem;
public class JEIUtils {
public static List<ItemStack> getItemVariations(ItemStack base) {
List<ItemStack> variations = new ArrayList<>();
base.getItem().getSubItems(base.getItem(), null, variations);
Iterator<ItemStack> itr = variations.iterator();
ItemStack stack;
while (itr.hasNext()) {
stack = itr.next();
if (!base.isItemEqual(stack) || !stack.hasTagCompound()) {
itr.remove();
}
}
if (variations.isEmpty()) {
return Collections.singletonList(base);
}
return variations;
}
public static FluidStack getFluidStack(ItemStack stack) {
if (stack != null) {
FluidStack fluidStack = null;
if (stack.getItem() instanceof IFluidContainerItem) {
fluidStack = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
}
if (fluidStack == null) {
fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
}
if (fluidStack == null && Block.getBlockFromItem(stack.getItem()) instanceof IFluidBlock) {
Fluid fluid = ((IFluidBlock) Block.getBlockFromItem(stack.getItem())).getFluid();
if (fluid != null) {
fluidStack = new FluidStack(fluid, Fluid.BUCKET_VOLUME);
}
}
return fluidStack;
}
return null;
}
public static boolean areFluidsSameType(FluidStack fluidStack1, FluidStack fluidStack2) {
if (fluidStack1 == null || fluidStack2 == null) {
return false;
}
return fluidStack1.getFluid() == fluidStack2.getFluid();
}
}
@@ -17,6 +17,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
import forestry.api.genetics.IAllele;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -72,10 +73,10 @@ public class EscritoireGameBoard implements INbtWritable, IStreamable {
tokenCount = getTokenCount(genome);
for (int i = 0; i < tokenCount / 2; i++) {
IIndividual token = root.templateAsIndividual(root.getRandomTemplate(rand));
ItemStack pair = root.getMemberStack(token, root.getIconType());
gameTokens.add(new EscritoireGameToken(pair));
gameTokens.add(new EscritoireGameToken(pair));
IAllele[] randomTemplate = root.getRandomTemplate(rand);
String speciesUid = randomTemplate[root.getSpeciesChromosomeType().ordinal()].getUID();
gameTokens.add(new EscritoireGameToken(speciesUid));
gameTokens.add(new EscritoireGameToken(speciesUid));
}
Collections.shuffle(gameTokens);
return true;
@@ -14,17 +14,19 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.core.INbtWritable;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
import forestry.core.utils.ColourUtil;
import forestry.core.utils.Translator;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class EscritoireGameToken implements INbtWritable, IStreamable {
@@ -41,6 +43,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
private static final String[] OVERLAY_FAILED = new String[]{"errors/errored"};
private static final String[] OVERLAY_SELECTED = new String[]{"errors/unknown"};
@Nullable
private IIndividual tokenIndividual;
@Nullable
private ItemStack tokenStack;
@Nonnull
@@ -51,8 +55,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
// required for IStreamable serialization
}
public EscritoireGameToken(@Nullable ItemStack tokenStack) {
this.tokenStack = tokenStack;
public EscritoireGameToken(@Nullable String speciesUid) {
setTokenSpecies(speciesUid);
}
public EscritoireGameToken(@Nonnull NBTTagCompound nbttagcompound) {
@@ -61,8 +65,29 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
state = State.values()[stateOrdinal];
}
// legacy
if (nbttagcompound.hasKey("tokenStack")) {
tokenStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("tokenStack"));
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(tokenStack);
tokenIndividual = speciesRoot.getMember(tokenStack);
}
if (nbttagcompound.hasKey("tokenSpecies")) {
String speciesUid = nbttagcompound.getString("tokenSpecies");
setTokenSpecies(speciesUid);
}
}
private void setTokenSpecies(String speciesUid) {
IAllele allele = AlleleManager.alleleRegistry.getAllele(speciesUid);
if (allele instanceof IAlleleSpecies) {
IAlleleSpecies species = (IAlleleSpecies) allele;
ISpeciesRoot root = species.getRoot();
IAllele[] template = root.getTemplate(speciesUid);
if (template != null) {
this.tokenIndividual = root.templateAsIndividual(template);
this.tokenStack = root.getMemberStack(this.tokenIndividual, root.getIconType());
}
}
}
@@ -108,12 +133,11 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
}
public int getTokenColour() {
if (tokenStack == null || !isVisible()) {
if (tokenIndividual == null || !isVisible()) {
return 0xffffff;
}
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(tokenStack);
int iconColor = individual.getGenome().getPrimary().getSpriteColour(0);
int iconColor = tokenIndividual.getGenome().getPrimary().getSpriteColour(0);
if (state == State.MATCHED) {
return ColourUtil.multiplyRGBComponents(iconColor, 0.7f);
@@ -146,10 +170,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("state", state.ordinal());
if (tokenStack != null) {
NBTTagCompound stackcompound = new NBTTagCompound();
tokenStack.writeToNBT(stackcompound);
nbttagcompound.setTag("tokenStack", stackcompound);
if (tokenIndividual != null) {
nbttagcompound.setString("tokenSpecies", tokenIndividual.getGenome().getPrimary().getUID());
}
return nbttagcompound;
}
@@ -158,12 +180,20 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
data.writeEnum(state, State.VALUES);
data.writeItemStack(tokenStack);
if (tokenIndividual != null) {
data.writeBoolean(true);
data.writeUTF(tokenIndividual.getGenome().getPrimary().getUID());
} else {
data.writeBoolean(false);
}
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
state = data.readEnum(State.VALUES);
tokenStack = data.readItemStack();
if (data.readBoolean()) {
String speciesUid = data.readUTF();
setTokenSpecies(speciesUid);
}
}
}
@@ -14,11 +14,17 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyReceiver;
import forestry.core.network.packets.PacketFXSignal;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileEngine;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockOldLog;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.BlockStaticLiquid;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
@@ -31,16 +37,8 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import forestry.core.network.packets.PacketFXSignal;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.TileEngine;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyReceiver;
public abstract class BlockUtil {
private static final int slabWoodId = OreDictionary.getOreID("slabWood");
@@ -343,4 +341,17 @@ public abstract class BlockUtil {
}
return false;
}
@Nullable
public static <T extends Comparable<T>> IProperty<T> getProperty(Block block, String propertyName, Class<T> valueClass) {
for (IProperty<?> property : block.getDefaultState().getPropertyNames()) {
if (property.getName().equals(propertyName)) {
if (property.getValueClass().isAssignableFrom(valueClass)) {
//noinspection unchecked
return (IProperty<T>) property;
}
}
}
return null;
}
}
@@ -423,9 +423,15 @@ public abstract class ItemStackUtil {
}
public static ItemStack copyWithRandomSize(ItemStack template, int max, Random rand) {
int size = rand.nextInt(max);
int size = max <= 0 ? 0 : rand.nextInt(max);
ItemStack created = template.copy();
created.stackSize = size <= 0 ? 1 : size > created.getMaxStackSize() ? created.getMaxStackSize() : size;
if (size <= 0) {
created.stackSize = 1;
} else if (size > created.getMaxStackSize()) {
created.stackSize = created.getMaxStackSize();
} else {
created.stackSize = size;
}
return created;
}
@@ -34,7 +34,9 @@ public class OreDictUtil {
public static final String FENCE_GATE_WOOD = "fenceGateWood";
public static final String STAIR_WOOD = "stairWood";
public static final String DOOR_WOOD = "doorWood";
public static final String TRAPDOOR_WOOD = "trapdoorWood";
public static final String TREE_LEAVES = "treeLeaves";
public static final String CHARCOAL = "itemCharcoal";
public static final String EMPTIED_LETTER_ORE_DICT = "emptiedLetter";
@@ -270,6 +270,7 @@ public class PluginFactory extends BlankForestryPlugin {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.WHEAT_SEEDS)}, seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.PUMPKIN_SEEDS)}, seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.MELON_SEEDS)}, seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.BEETROOT_SEEDS)}, seedOil);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{PluginCore.items.phosphor.getItemStack(2), new ItemStack(Blocks.COBBLESTONE)}, new FluidStack(FluidRegistry.LAVA, 1600));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Blocks.CACTUS)}, new FluidStack(FluidRegistry.WATER, 500));
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.SNOWBALL), PluginCore.items.craftingMaterial.getIceShard(4)}, Fluids.ICE.getFluid(4000));
@@ -29,6 +29,10 @@ public class FermenterRecipe implements IFermenterRecipe {
if (resource == null) {
throw new NullPointerException("Fermenter Resource cannot be null!");
}
if (resource.getItem() == null) {
throw new NullPointerException("Fermenter Resource item cannot be null!");
}
if (output == null) {
throw new NullPointerException("Fermenter Output cannot be null!");
@@ -92,7 +92,7 @@ public class FactoryJeiPlugin extends BlankModPlugin {
registry.addRecipes(CarpenterRecipeMaker.getCarpenterRecipes());
registry.addRecipes(CentrifugeRecipeMaker.getCentrifugeRecipe());
registry.addRecipes(FabricatorRecipeMaker.getFabricatorRecipes());
registry.addRecipes(FermenterRecipeMaker.getFermenterRecipes());
registry.addRecipes(FermenterRecipeMaker.getFermenterRecipes(jeiHelpers.getStackHelper()));
registry.addRecipes(MoistenerRecipeMaker.getMoistenerRecipes());
registry.addRecipes(RainmakerRecipeMaker.getRecipes());
registry.addRecipes(SqueezerRecipeMaker.getSqueezerRecipes());
@@ -6,19 +6,17 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import forestry.factory.gui.ContainerWorktable;
import forestry.factory.inventory.InventoryCraftingForestry;
import forestry.factory.recipes.MemorizedRecipe;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import mezz.jei.gui.ingredients.IGuiIngredient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
class WorktableRecipeTransferHandler implements IRecipeTransferHandler {
@Override
@@ -23,7 +23,7 @@ import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeWrapper;
public class FermenterRecipeCategory extends ForestryRecipeCategory {
public class FermenterRecipeCategory extends ForestryRecipeCategory<FermenterRecipeWrapper> {
private static final int resourceSlot = 0;
private static final int fuelSlot = 1;
@@ -62,7 +62,7 @@ public class FermenterRecipeCategory extends ForestryRecipeCategory {
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull FermenterRecipeWrapper recipeWrapper) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
@@ -72,18 +72,15 @@ public class FermenterRecipeCategory extends ForestryRecipeCategory {
guiFluidStacks.init(inputTank, true, 1, 1, 16, 58, 3000, false, tankOverlay);
guiFluidStacks.init(outputTank, false, 91, 1, 16, 58, 3000, false, tankOverlay);
FermenterRecipeWrapper wrapper = (FermenterRecipeWrapper) recipeWrapper;
guiItemStacks.set(resourceSlot, wrapper.getFermentable());
guiItemStacks.set(resourceSlot, recipeWrapper.getFermentable());
List<ItemStack> fuels = new ArrayList<>();
for (FermenterFuel fuel : FuelManager.fermenterFuel.values()) {
fuels.add(fuel.item);
}
guiItemStacks.set(fuelSlot, fuels);
guiFluidStacks.set(inputTank, wrapper.getFluidInputs());
guiFluidStacks.set(outputTank, wrapper.getFluidOutputs());
guiFluidStacks.set(inputTank, recipeWrapper.getFluidInputs());
guiFluidStacks.set(outputTank, recipeWrapper.getFluidOutputs());
}
}
@@ -8,22 +8,29 @@ import net.minecraft.item.ItemStack;
import forestry.api.recipes.IFermenterRecipe;
import forestry.api.recipes.IVariableFermentable;
import forestry.api.recipes.RecipeManagers;
import forestry.core.recipes.jei.JEIUtils;
import forestry.core.utils.Log;
import forestry.factory.recipes.jei.FactoryJeiPlugin;
import mezz.jei.api.recipe.IStackHelper;
public class FermenterRecipeMaker {
private FermenterRecipeMaker() {
}
public static List<FermenterRecipeWrapper> getFermenterRecipes() {
public static List<FermenterRecipeWrapper> getFermenterRecipes(IStackHelper stackHelper) {
List<FermenterRecipeWrapper> recipes = new ArrayList<>();
for (IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) {
if (recipe.getResource() != null && recipe.getResource().getItem() instanceof IVariableFermentable) {
for (ItemStack stack : JEIUtils.getItemVariations(recipe.getResource())) {
recipes.add(new FermenterRecipeWrapper(recipe, stack));
if (recipe.getResource() != null) {
if (recipe.getResource().getItem() instanceof IVariableFermentable) {
for (ItemStack stack : stackHelper.getSubtypes(recipe.getResource())) {
recipes.add(new FermenterRecipeWrapper(recipe, stack));
}
} else {
recipes.add(new FermenterRecipeWrapper(recipe, recipe.getResource()));
}
} else {
recipes.add(new FermenterRecipeWrapper(recipe, recipe.getResource()));
Log.error("Null resource for recipe");
}
}
return recipes;
@@ -42,6 +42,7 @@ import forestry.core.circuits.CircuitLayout;
import forestry.core.config.Constants;
import forestry.core.items.EnumElectronTube;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.OreDictUtil;
import forestry.farming.blocks.BlockMushroom;
import forestry.farming.blocks.BlockRegistryFarming;
import forestry.farming.blocks.EnumFarmBlockType;
@@ -207,7 +208,7 @@ public class PluginFarming extends BlankForestryPlugin {
"TDT",
'#', basic,
'T', "gearTin",
'D', Blocks.TRAPDOOR);
'D', OreDictUtil.TRAPDOOR_WOOD);
RecipeUtil.addRecipe(valve,
" # ",
@@ -27,6 +27,7 @@ import forestry.core.fluids.Fluids;
import forestry.core.items.EnumElectronTube;
import forestry.core.network.IPacketRegistry;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.OreDictUtil;
import forestry.greenhouse.blocks.BlockGreenhouseType;
import forestry.greenhouse.blocks.BlockRegistryGreenhouse;
import forestry.greenhouse.logics.GreenhouseLogicGreenhouseDoor;
@@ -91,7 +92,7 @@ public class PluginGreenhouse extends BlankForestryPlugin {
"TXT",
"#H#",
'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN),
'H', Blocks.TRAPDOOR,
'H', OreDictUtil.TRAPDOOR_WOOD,
'#', "gearTin",
'T', PluginCore.items.tubes.get(EnumElectronTube.BRONZE, 1));
@@ -100,7 +101,7 @@ public class PluginGreenhouse extends BlankForestryPlugin {
"#H#",
"TXT",
'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN),
'H', Blocks.TRAPDOOR,
'H', OreDictUtil.TRAPDOOR_WOOD,
'#', "gearTin",
'T', PluginCore.items.tubes.get(EnumElectronTube.BRONZE, 1));
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.lepidopterology.genetics;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAlleleFloat;
import forestry.api.genetics.IAlleleFlowers;
@@ -29,6 +27,8 @@ import forestry.api.lepidopterology.IButterflyGenome;
import forestry.core.genetics.Genome;
import forestry.core.genetics.alleles.AlleleBoolean;
import forestry.core.genetics.alleles.AlleleTolerance;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ButterflyGenome extends Genome implements IButterflyGenome {
@@ -46,8 +46,8 @@ public class ButterflyGenome extends Genome implements IButterflyGenome {
if (!ButterflyManager.butterflyRoot.isMember(itemStack)) {
return null;
}
IAlleleSpecies species = getSpeciesDirectly(itemStack);
IAlleleSpecies species = getSpeciesDirectly(ButterflyManager.butterflyRoot, itemStack);
if (species instanceof IAlleleButterflySpecies) {
return (IAlleleButterflySpecies) species;
}
@@ -12,21 +12,11 @@ package forestry.lepidopterology.genetics;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlyzerPlugin;
@@ -50,6 +40,14 @@ import forestry.core.utils.EntityUtil;
import forestry.lepidopterology.PluginLepidopterology;
import forestry.lepidopterology.entities.EntityButterfly;
import forestry.lepidopterology.tiles.TileCocoon;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
@@ -266,7 +264,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
}
/* MUTATIONS */
private static final ArrayList<IButterflyMutation> butterflyMutations = new ArrayList<>();
private static final List<IButterflyMutation> butterflyMutations = new ArrayList<>();
@Override
public void registerMutation(IMutation mutation) {
@@ -284,7 +282,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
}
@Override
public Collection<IButterflyMutation> getMutations(boolean shuffle) {
public List<IButterflyMutation> getMutations(boolean shuffle) {
if (shuffle) {
Collections.shuffle(butterflyMutations);
}
@@ -315,7 +313,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
}
@Override
public IChromosomeType getKaryotypeKey() {
public IChromosomeType getSpeciesChromosomeType() {
return EnumButterflyChromosome.SPECIES;
}
@@ -33,7 +33,7 @@ import forestry.lepidopterology.genetics.alleles.AlleleButterflyCocoon;
public enum MothDefinition implements IButterflyDefinition {
Brimstone(ButterflyBranchDefinition.Opisthograptis, "brimstone", "luteolata", new Color(0xffea40), true, 1.0f),
LatticedHeath(ButterflyBranchDefinition.Chiasmia, "latticeHeath", "clathrata", new Color(0xf2f0be), true, 0.5f) {
LatticedHeath(ButterflyBranchDefinition.Chiasmia, "latticedHeath", "clathrata", new Color(0xf2f0be), true, 0.5f) {
@Override
protected void setAlleles(IAllele[] alleles) {
AlleleHelper.instance.set(alleles, EnumButterflyChromosome.SIZE, EnumAllele.Size.SMALLEST);
@@ -20,6 +20,8 @@ public class ForestryPluginUids {
public static final String BUILDCRAFT_STATEMENTS = "forestry.buildcraft.statements";
public static final String BUILDCRAFT_TRANSPORT = "forestry.buildcraft.transport";
public static final String CHISEL = "forestry.chisel";
public static final String ENDER_IO = "forestry.ender.io";
public static final String EXTRA_UTILITIES = "forestry.extra.utilities";
public static final String NATURA = "forestry.natura";
public static final String INDUSTRIALCRAFT2 = "forestry.industrialcraft2";
}
@@ -14,14 +14,18 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.Farmables;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.BackpackManager;
import forestry.core.PluginCore;
@@ -31,6 +35,8 @@ import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Log;
import forestry.core.utils.ModUtil;
import forestry.farming.logic.FarmableBasicAgricraft;
import forestry.farming.logic.FarmableGE;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
@@ -43,8 +49,6 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
private static Block saplings;
private static Block colorizedSaplings;
private static Item food;
private static Item misc;
private static ItemStack persimmon;
private static int amount;
@Override
@@ -61,12 +65,9 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
public void doInit() {
super.doInit();
saplings = GameRegistry.findBlock(BoP, "saplings");
colorizedSaplings = GameRegistry.findBlock(BoP, "colorizedSaplings");
food = GameRegistry.findItem(BoP, "food");
if (food != null) {
persimmon = new ItemStack(food, 1, 8);
}
saplings = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(BoP, "saplings"));
colorizedSaplings = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(BoP, "colorizedSaplings"));
food = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, "food"));
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.APICULTURE)) {
addFlowers();
@@ -98,21 +99,21 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
}
for (String key : saplingItemKeys) {
Item saplingItem = GameRegistry.findItem(BoP, key);
Item saplingItem = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, key));
String saplingName = ItemStackUtil.getItemNameFromRegistryAsString(saplingItem);
if (saplingName != null) {
FMLInterModComms.sendMessage(Constants.MOD_ID, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName));
}
}
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && saplings != null && persimmon != null) {
//TODO BoP for 1.9: Add farmables
//TODO BoP for 1.9: Add farmables
// if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && saplings != null && persimmon != null) {
// Farmables.farmables.put("farmArboreal", new FarmableGenericSapling(saplings, 15, persimmon));
}
// }
Block boPTurnip = GameRegistry.findBlock(BoP, "turnip");
Block boPTurnip = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(BoP, "turnip"));
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && boPTurnip != null) {
Item boPTurnipSeeds = GameRegistry.findItem(BoP, "turnipSeeds");
Item boPTurnipSeeds = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, "turnipSeeds"));
ItemStack boPTurnipSeedStack = new ItemStack(boPTurnipSeeds, 1, 0);
if (boPTurnipSeeds != null) {
//TODO BoP for 1.9: Add farmable saplings
@@ -130,11 +131,11 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
private static void addFermenterRecipes() {
int saplingYield = ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling");
if (saplings != null) {
if (saplings != Blocks.AIR) {
RecipeUtil.addFermenterRecipes(new ItemStack(saplings, 1, OreDictionary.WILDCARD_VALUE), saplingYield, Fluids.BIOMASS);
}
if (colorizedSaplings != null) {
if (colorizedSaplings != Blocks.AIR) {
RecipeUtil.addFermenterRecipes(new ItemStack(colorizedSaplings, 1, OreDictionary.WILDCARD_VALUE), saplingYield, Fluids.BIOMASS);
}
}
@@ -142,20 +143,18 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
private static void addSqueezerRecipes() {
ItemStack mulch = new ItemStack(PluginCore.items.mulch);
misc = GameRegistry.findItem(BoP, "misc");
if (misc != null) {
ItemStack pinecone = new ItemStack(misc, 1, 13);
if (pinecone != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{pinecone}, Fluids.SEED_OIL.getFluid(3 * amount));
}
Item pinecone = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, "pinecone"));
if (pinecone != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(pinecone)}, Fluids.SEED_OIL.getFluid(3 * amount));
}
if (food != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(food)}, Fluids.JUICE.getFluid(50), mulch, 5);
}
Item persimmon = ForgeRegistries.ITEMS.getValue(new ResourceLocation(BoP, "persimmon"));
if (persimmon != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{persimmon}, Fluids.JUICE.getFluid(200), mulch, 20);
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(persimmon)}, Fluids.JUICE.getFluid(200), mulch, 20);
}
}
@@ -234,7 +233,7 @@ public class PluginBiomesOPlenty extends BlankForestryPlugin {
private static void addBlocksToBackpack(String backpackUid, String... blockNames) {
for (String blockName : blockNames) {
Block block = GameRegistry.findBlock(BoP, blockName);
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(BoP, blockName));
if (block != null) {
ItemStack blockStack = new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE);
BackpackManager.backpackInterface.getBackpack(backpackUid).addValidItem(blockStack);
@@ -0,0 +1,70 @@
package forestry.plugins.compat;
import forestry.api.core.ForestryAPI;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.core.utils.ModUtil;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.event.FMLInterModComms;
@ForestryPlugin(pluginID = ForestryPluginUids.ENDER_IO, name = "EnderIO", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.plugin.enderIO.description")
public class PluginEnderIO extends BlankForestryPlugin {
private static final String EnderIO = "EnderIO";
private static final String FLUID_FUEL_ADD = "fluidFuel:add";
private static final String FLUID_COOLANT_ADD = "fluidCoolant:add";
private static final String KEY_FLUID_NAME = "fluidName";
private static final String KEY_POWER_PER_CYCLE = "powerPerCycle";
private static final String KEY_TOTAL_BURN_TIME = "totalBurnTime";
private static final String KEY_COOLING_PER_MB = "coolingPerMb";
private static final float WATER_COOLING_PER_MB = 0.0023f;
@Override
public boolean isAvailable() {
return ModUtil.isModLoaded(EnderIO);
}
@Override
public String getFailMessage() {
return "EnderIO not found";
}
@Override
public void doInit() {
Fluid ethanol = Fluids.BIO_ETHANOL.getFluid();
if (ethanol != null) {
int ethanolBurnTime = Math.round(Constants.ENGINE_CYCLE_DURATION_ETHANOL * ForestryAPI.activeMode.getFloatSetting("fuel.ethanol.combustion"));
addFuel(ethanol, 40, ethanolBurnTime);
}
Fluid crushedIce = Fluids.ICE.getFluid();
if (crushedIce != null) {
addCoolant(crushedIce, Constants.ICE_COOLING_MULTIPLIER);
}
}
private static void addFuel(Fluid fluid, int powerPerCycle, int totalBurnTime) {
NBTTagCompound fuelTag = new NBTTagCompound();
fuelTag.setString(KEY_FLUID_NAME, fluid.getName());
fuelTag.setInteger(KEY_POWER_PER_CYCLE, powerPerCycle);
fuelTag.setInteger(KEY_TOTAL_BURN_TIME, totalBurnTime);
FMLInterModComms.sendMessage(EnderIO, FLUID_FUEL_ADD, fuelTag);
}
private static void addCoolant(Fluid fluid, float coolingMultiplier) {
float coolingPerMb = coolingMultiplier * WATER_COOLING_PER_MB;
NBTTagCompound coolantTag = new NBTTagCompound();
coolantTag.setString(KEY_FLUID_NAME, fluid.getName());
coolantTag.setFloat(KEY_COOLING_PER_MB, coolingPerMb);
FMLInterModComms.sendMessage(EnderIO, FLUID_COOLANT_ADD, coolantTag);
}
}
@@ -0,0 +1,89 @@
/*******************************************************************************
* 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.plugins.compat;
import java.util.Collections;
import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.Farmables;
import forestry.core.PluginCore;
import forestry.core.circuits.Circuit;
import forestry.core.config.Config;
import forestry.core.config.Constants;
import forestry.core.items.EnumElectronTube;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.Log;
import forestry.core.utils.ModUtil;
import forestry.farming.circuits.CircuitFarmLogic;
import forestry.farming.logic.FarmLogicEnder;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
@ForestryPlugin(pluginID = ForestryPluginUids.EXTRA_UTILITIES, name = "ExtraUtilities", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.plugin.extrautilities.description")
public class PluginExtraUtilities extends BlankForestryPlugin {
private static final String ExU = "ExtraUtils2";
@Override
public boolean isAvailable() {
return ModUtil.isModLoaded(ExU);
}
@Override
public String getFailMessage() {
return "ExtraUtilities not found";
}
@Override
public void doInit() {
super.doInit();
if (Config.isExUtilEnderLilyEnabled()) {
Block enderLillyBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("extrautils2", "EnderLilly"));
Item enderLillyItem = Item.getItemFromBlock(enderLillyBlock);
if (enderLillyBlock == Blocks.AIR) {
Log.error("Could not find ender lilly block.");
} else if (enderLillyItem == null) {
Log.error("Could not find ender lilly item.");
} else {
IProperty<Integer> growthProperty = BlockUtil.getProperty(enderLillyBlock, "growth", Integer.class);
if (growthProperty == null) {
Log.error("Could not find the growth property of ender lily.");
} else {
int harvestAge = Collections.max(growthProperty.getAllowedValues());
int replantAge = enderLillyBlock.getDefaultState().getValue(growthProperty);
Farmables.farmables.put("farmEnder", new FarmableAgingCrop(new ItemStack(enderLillyItem), enderLillyBlock, growthProperty, harvestAge, replantAge));
Circuit.farmEnderManaged = new CircuitFarmLogic("managedEnder", new FarmLogicEnder());
}
}
}
}
@Override
public void registerRecipes() {
super.registerRecipes();
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && Circuit.farmEnderManaged != null) {
ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");
ChipsetManager.solderManager.addRecipe(layoutManaged, PluginCore.items.tubes.get(EnumElectronTube.ENDER, 1), Circuit.farmEnderManaged);
}
}
}
Loaded 100 of 105 files, more files were not shown because too many files have changed in this diff. Show more