Compare commits

...
89 Commits
Author SHA1 Message Date
mezz 98e506cc4a Close #1269 Buff Peat balance vs Charcoal 2016-08-03 03:15:48 -07:00
mezz ecfb11c096 Encapsulate fields of fuels in the API 2016-08-03 02:52:18 -07:00
mezz 6b59736ffe Fix #1369 Add button click noise to various buttons 2016-08-03 02:36:28 -07:00
mezz a3a1f7720e Fix #1371 IC2 Rubber farm does not harvest rubber properly 2016-08-03 02:21:27 -07:00
bdew 89cfbfca9c Allow overriding climate when checking for mutations (#1373)
* Allow overriding climate when checking for mutations
2016-08-02 14:22:05 -07:00
mezz e0676030d6 Update Forge 2016-08-01 18:17:28 -07:00
mezz 0c76e22b8a Fix #1368 Update Tesla API 2016-08-01 18:16:51 -07:00
mezz 1a8f1751d9 Fix #1366 Alveary in the Nether does not have Hellish temperature 2016-07-31 17:24:18 -07:00
Nedelosk b95bb8315f Fix #1363 [MC 1.10.2] Crash on camouflaging greenhouse bricks 2016-07-24 12:49:17 +02:00
mezz 2cc2540bdc Fix #1362 Crash on Startup when disabling Lepidopterology module 2016-07-23 03:43:42 -07:00
Nedelosk 84af238d82 Fix #1298 Bio Generator has incorrect hitbox 2016-07-23 01:50:11 +02:00
Nedelosk 89960db2bd Fix #1251 Sprinkler's and cocoons's bounding box is not visable 2016-07-23 01:32:16 +02:00
Nedelosk c5f53bda3e Fix #1288 Broken Cocoon texture when colliding with player 2016-07-23 01:08:42 +02:00
Nedelosk 2e1b62e58d Fix #1223 Suvirvalist's Pickaxe 2016-07-23 00:50:49 +02:00
Nedelosk 982aefa165 Add a way to add custom crate content models 2016-07-22 23:14:14 +02:00
Nedelosk 2cccf95775 Fix #1360 1.10 Some items crash rendering when NBT data is missing 2016-07-22 22:34:09 +02:00
mezz 1969ed8b09 Close #1358 Change "Portable Alyzer" to "Portable Analyzer" 2016-07-21 23:44:03 -07:00
mezz c3fc490fac Fix #1355 Crash from Boggy bees 2016-07-21 22:53:58 -07:00
mezz 59687329fb Replace IBackpackFilter with Predicate<ItemStack> 2016-07-20 15:24:05 -07:00
mezz 94f751d78a Improve backpack API and add backpack config blacklists 2016-07-20 02:25:32 -07:00
mezz f6feca096f Remove unused icons from TextureManager 2016-07-19 17:41:50 -07:00
mezz 649f38efb8 Fix Escritoire renderer leaking the world object by keeping a reference 2016-07-19 16:03:30 -07:00
mezz e4e221b9fd Fix butterfly items rendering too low 2016-07-19 16:03:08 -07:00
Nedelosk d7f063eec8 Update EntityButterfly.java 2016-07-17 12:40:47 +02:00
mezz aa988a3be7 Make honeyed slice more appetizing looking 2016-07-15 17:10:40 -07:00
mezz 18f2a027bc Remove unused bucket icons 2016-07-13 22:24:33 -07:00
mezz 7ca34e52d6 Update icons that use cans or capsules 2016-07-13 22:23:26 -07:00
mezz 7f83b5b909 Change portable alyzer icon to 16x 2016-07-13 22:09:44 -07:00
mezz 641f763d05 Add tooltips and JEI descriptions for CircuitBoard, SolderingIron, Tubes 2016-07-13 21:35:27 -07:00
mezz 0df85063a1 Remove "requires discovery" and limits from electron tubes 2016-07-13 21:34:37 -07:00
mezz 550b0dc3f5 Add zombie villager textures 2016-07-13 21:34:37 -07:00
Nedelosk 96a7b688c0 Fix the jar 2016-07-13 19:34:56 +02:00
Nedelosk 8f6c2baba6 Update README.md 2016-07-13 19:20:30 +02:00
mezz 523a8da908 Fix #1348 support for IC2 in 1.10.2 2016-07-10 18:43:58 -07:00
mezz cd10500a17 Fix crash when there is snow in the way of the farm 2016-07-10 18:34:31 -07:00
mezz 6d9211ada1 Remove block access restrictions 2016-07-06 02:00:02 -07:00
mezz 003ca9273d Fix beekeeper vaillager's collar color 2016-07-05 22:13:58 -07:00
mezz 28f65f13a5 Fix worktable bug that could delete container items 2016-07-05 21:57:23 -07:00
mezz 21ee0947d7 Fix isOp permissions check 2016-07-05 21:01:54 -07:00
mezz 1e11992de2 Fix #1333 Stop wild hive bees from attacking passive animals 2016-07-03 23:05:46 -07:00
mezz d690a38fa2 Fix #1340 Rare NPE from BeekeepingLogic.queenWorkTick 2016-07-03 22:16:12 -07:00
mezz 46eb29cf28 Fix #1342 Crash when giving multifarm control a redstone signal 2016-07-03 20:59:26 -07:00
mezz fb01d3ffaa Update IC2 2016-07-03 12:38:47 -07:00
mezz e676a73a7c Fix doors not showing correctly in TheOneProbe 2016-07-01 22:41:29 -07:00
mezz 6e348dbc5d Add support for Tesla power 2016-06-30 16:54:57 -07:00
mezz 39114ec429 Tidy up capabilities 2016-06-30 16:26:36 -07:00
mezz 3b82fe3bd0 Update to Minecraft 1.10.2 2016-06-30 16:22:15 -07:00
mezz 2667334252 Increase chances of getting a research note on the escritoire 2016-06-28 13:56:28 -07:00
mezz be39e2c3c3 Only list mutations for the primary species in the handheld Alyzer 2016-06-28 13:51:15 -07:00
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
mezz 9f5f5e7812 Fix network sync of item floating over Escritoire 2016-06-19 23:03:02 -07:00
mezz 8617c4a79f Properly center the item floating over the escritoire 2016-06-19 22:18:31 -07:00
mezz e9809238de Fix #1325 Null Pointer Exception from broken mailbox 2016-06-18 16:14:13 -07:00
mezz c0a22f4a28 Split mutationCustom into mutationBuilder and Mutation
Remove EntityBee
Update MutationConditionRequiresResource to use blockState
2016-06-17 15:20:19 -07:00
mezz 41c6fb15b3 Make escritoire convert vanilla saplings for analysis 2016-06-17 15:17:43 -07:00
mezz b5d65e83f0 Render floating sapling over Escritoire when in use 2016-06-17 15:17:43 -07:00
330 changed files with 3714 additions and 3949 deletions

No files matched your search

+1 -1
View File
@@ -9,7 +9,7 @@ Forestry is a modification for the game Minecraft and known primarily for its fa
[Wiki](http://forestry.sengir.net/)
[Latest Builds for 1.9](http://jenkins.ic2.player.to/job/Forestry_5/)
[Latest Builds for 1.10 / 1.10.2](http://jenkins.ic2.player.to/job/Forestry_5/)
[IRC #forestry on esper.net](http://webchat.esper.net/?nick=ForestryGithub...&channels=forestry&prompt=1)
+6 -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
@@ -56,6 +55,9 @@ sourceSets {
}
repositories {
maven {
url 'http://maven.epoxide.xyz'
}
maven {
url "http://dvs1.progwml6.com/files/maven"
}
@@ -66,7 +68,9 @@ repositories {
}
dependencies {
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}"
deobfCompile "net.darkhax.tesla:Tesla:${tesla_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"
}
+7 -6
View File
@@ -1,10 +1,11 @@
mcversion=1.9.4
forgeversion=12.17.0.1957
mcversion=1.10.2
forgeversion=12.18.1.2044
mcp_mappings=snapshot_20160525
jei_version=3.6.4.+
ic2_version=2.5.5-ex19
tesla_version=1.10.2-1.2.1.41
jei_version=3.7.3.221
ic2_version=2.6.15-ex110
version_major=5
version_minor=0
version_patch=17
version_minor=2
version_patch=7
+1 -1
Submodule lang updated: 9be86d3c99...0d52088d32.
+5 -10
View File
@@ -12,6 +12,7 @@ package forestry;
import java.io.File;
import forestry.plugins.compat.PluginIC2;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Mod;
@@ -49,16 +50,10 @@ 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,);"
+ "after:" + PluginIC2.modId + ";")
public class Forestry {
@Mod.Instance(Constants.MOD_ID)
@@ -50,12 +50,4 @@ public interface IAlleleBeeSpecies extends IAlleleSpecies {
@SideOnly(Side.CLIENT)
void registerModels(Item item, IModelManager manager);
/**
* @deprecated since Forestry 3.6.
* @return Path of the texture to use for entity rendering.
*/
@Deprecated
String getEntityTexture();
}
@@ -5,6 +5,9 @@
******************************************************************************/
package forestry.api.apiculture;
import javax.annotation.Nonnull;
import forestry.api.core.IClimateProvider;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
@@ -16,7 +19,7 @@ import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorLogicSource;
import forestry.api.genetics.IHousing;
public interface IBeeHousing extends IHousing, IErrorLogicSource {
public interface IBeeHousing extends IHousing, IErrorLogicSource, IClimateProvider {
/**
* Used by BeeManager.beeRoot.createBeeHousingModifier(IBeeHousing housing)
@@ -32,14 +35,11 @@ public interface IBeeHousing extends IHousing, IErrorLogicSource {
*/
Iterable<IBeeListener> getBeeListeners();
@Nonnull
IBeeHousingInventory getBeeInventory();
IBeekeepingLogic getBeekeepingLogic();
EnumTemperature getTemperature();
EnumHumidity getHumidity();
int getBlockLightValue();
boolean canBlockSeeTheSky();
@@ -47,8 +47,6 @@ public interface IBeeHousing extends IHousing, IErrorLogicSource {
/** Must not be named "getWorld" to avoid SpecialSource issue https://github.com/md-5/SpecialSource/issues/12 */
World getWorldObj();
Biome getBiome();
GameProfile getOwner();
/**
@@ -5,8 +5,9 @@
******************************************************************************/
package forestry.api.apiculture;
import forestry.api.genetics.IMutationCustom;
public interface IBeeMutationCustom extends IBeeMutation, IMutationCustom {
import forestry.api.genetics.IMutationBuilder;
public interface IBeeMutationBuilder extends IMutationBuilder {
@Override
IBeeMutation build();
}
@@ -11,7 +11,7 @@ public interface IBeeMutationFactory {
/**
* Creates a new bee mutation.
* Automatically registered with BeeManager.beeRoot.registerMutation()
* See IBeeMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
* See IBeeMutationBuilder and IMutationBuilder for adding additional properties to the returned mutation.
*
* @param parentBee0 A parent bee for this mutation
* @param parentBee1 A parent bee for this mutation
@@ -19,5 +19,5 @@ public interface IBeeMutationFactory {
* @param chance The chance that breeding the two parent bees will result in this mutation
* @return a new bee mutation.
*/
IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance);
IBeeMutationBuilder createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance);
}
@@ -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);
}
@@ -3,7 +3,7 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion = "4.8.0", owner = "ForestryAPI|core", provides = "ForestryAPI|apiculture")
@API(apiVersion = "5.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|apiculture")
package forestry.api.apiculture;
import net.minecraftforge.fml.common.API;
@@ -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();
}
@@ -5,8 +5,9 @@
******************************************************************************/
package forestry.api.arboriculture;
import forestry.api.genetics.IMutationCustom;
public interface ITreeMutationCustom extends ITreeMutation, IMutationCustom {
import forestry.api.genetics.IMutationBuilder;
public interface ITreeMutationBuilder extends IMutationBuilder {
@Override
ITreeMutation build();
}
@@ -11,7 +11,7 @@ public interface ITreeMutationFactory {
/**
* Creates a new tree mutation.
* Automatically registered with TreeManager.treeRoot.registerMutation()
* See ITreeMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
* See ITreeMutationBuilder and IMutationBuilder for adding additional properties to the returned mutation.
*
* @param parentTree0 A parent tree for this mutation
* @param parentTree1 A parent tree for this mutation
@@ -19,5 +19,5 @@ public interface ITreeMutationFactory {
* @param chance The chance that breeding the two parent trees will result in this mutation
* @return a new tree mutation.
*/
ITreeMutationCustom createMutation(IAlleleTreeSpecies parentTree0, IAlleleTreeSpecies parentTree1, IAllele[] result, int chance);
ITreeMutationBuilder createMutation(IAlleleTreeSpecies parentTree0, IAlleleTreeSpecies parentTree1, IAllele[] result, int chance);
}
@@ -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,10 +10,6 @@ import java.util.List;
public interface ICircuit {
String getUID();
boolean requiresDiscovery();
int getLimit();
String getUnlocalizedName();
boolean isCircuitable(Object tile);
@@ -13,5 +13,7 @@ public interface IClimateManager {
float getTemperature(World world, BlockPos pos);
float getHumidity(World world, BlockPos pos);
IClimateProvider getDefaultClimate(World world, BlockPos pos);
}
@@ -0,0 +1,11 @@
package forestry.api.core;
import net.minecraft.world.biome.Biome;
public interface IClimateProvider {
Biome getBiome();
EnumTemperature getTemperature();
EnumHumidity getHumidity();
}
@@ -9,6 +9,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
@@ -38,7 +39,7 @@ public interface IModelBaker {
void addModel(@Nonnull AxisAlignedBB renderBounds, @Nonnull TextureAtlasSprite texture, int colorIndex);
void addBakedModel(@Nonnull IBakedModel model);
void addBakedModel(@Nullable IBlockState state, @Nonnull IBakedModel model);
void addFace(@Nonnull EnumFacing facing, @Nonnull TextureAtlasSprite sprite);
@@ -8,22 +8,10 @@ package forestry.api.fuels;
import net.minecraftforge.fluids.Fluid;
public class EngineBronzeFuel {
/**
* Item that is valid fuel for a biogas engine.
*/
public final Fluid liquid;
/**
* Power produced by this fuel per work cycle of the engine.
*/
public final int powerPerCycle;
/**
* How many work cycles a single "stack" of this type lasts.
*/
public final int burnDuration;
/**
* By how much the normal heat dissipation rate of 1 is multiplied when using this fuel type.
*/
public final int dissipationMultiplier;
private final Fluid liquid;
private final int powerPerCycle;
private final int burnDuration;
private final int dissipationMultiplier;
public EngineBronzeFuel(Fluid liquid, int powerPerCycle, int burnDuration, int dissipationMultiplier) {
this.liquid = liquid;
@@ -31,4 +19,32 @@ public class EngineBronzeFuel {
this.burnDuration = burnDuration;
this.dissipationMultiplier = dissipationMultiplier;
}
/**
* Item that is valid fuel for a biogas engine.
*/
public Fluid getLiquid() {
return liquid;
}
/**
* Power produced by this fuel per work cycle of the engine.
*/
public int getPowerPerCycle() {
return powerPerCycle;
}
/**
* How many work cycles a single "stack" of this type lasts.
*/
public int getBurnDuration() {
return burnDuration;
}
/**
* By how much the normal heat dissipation rate of 1 is multiplied when using this fuel type.
*/
public int getDissipationMultiplier() {
return dissipationMultiplier;
}
}
@@ -9,18 +9,9 @@ import net.minecraft.item.ItemStack;
public class EngineCopperFuel {
/**
* Item that is valid fuel for a peat-fired engine.
*/
public final ItemStack fuel;
/**
* Power produced by this fuel per work cycle.
*/
public final int powerPerCycle;
/**
* Amount of work cycles this item lasts before being consumed.
*/
public final int burnDuration;
private final ItemStack fuel;
private final int powerPerCycle;
private final int burnDuration;
public EngineCopperFuel(ItemStack fuel, int powerPerCycle, int burnDuration) {
this.fuel = fuel;
@@ -28,4 +19,24 @@ public class EngineCopperFuel {
this.burnDuration = burnDuration;
}
/**
* Item that is valid fuel for a peat-fired engine.
*/
public ItemStack getFuel() {
return fuel;
}
/**
* Power produced by this fuel per work cycle.
*/
public int getPowerPerCycle() {
return powerPerCycle;
}
/**
* Amount of work cycles this item lasts before being consumed.
*/
public int getBurnDuration() {
return burnDuration;
}
}
@@ -8,22 +8,34 @@ package forestry.api.fuels;
import net.minecraft.item.ItemStack;
public class FermenterFuel {
/**
* Item that is a valid fuel for the fermenter (i.e. fertilizer).
*/
public final ItemStack item;
/**
* How much is fermeted per work cycle, i.e. how much biomass is produced per cycle.
*/
public final int fermentPerCycle;
/**
* Amount of work cycles a single item of this fuel lasts before expiring.
*/
public final int burnDuration;
private final ItemStack item;
private final int fermentPerCycle;
private final int burnDuration;
public FermenterFuel(ItemStack item, int fermentPerCycle, int burnDuration) {
this.item = item;
this.fermentPerCycle = fermentPerCycle;
this.burnDuration = burnDuration;
}
/**
* Item that is a valid fuel for the fermenter (i.e. fertilizer).
*/
public ItemStack getItem() {
return item;
}
/**
* How much is fermeted per work cycle, i.e. how much biomass is produced per cycle.
*/
public int getFermentPerCycle() {
return fermentPerCycle;
}
/**
* Amount of work cycles a single item of this fuel lasts before expiring.
*/
public int getBurnDuration() {
return burnDuration;
}
}
@@ -9,18 +9,9 @@ import net.minecraftforge.fluids.FluidStack;
public class GeneratorFuel {
/**
* LiquidStack representing the fuel type and amount consumed per triggered cycle.
*/
public final FluidStack fuelConsumed;
/**
* EU emitted per tick while this fuel is being consumed in the generator (i.e. biofuel = 32, biomass = 8).
*/
public final int eu;
/**
* Rate at which the fuel is consumed. 1 - Every tick 2 - Every second tick 3 - Every third tick etc.
*/
public final int rate;
private final FluidStack fuelConsumed;
private final int eu;
private final int rate;
public GeneratorFuel(FluidStack fuelConsumed, int eu, int rate) {
this.fuelConsumed = fuelConsumed;
@@ -28,4 +19,24 @@ public class GeneratorFuel {
this.rate = rate;
}
/**
* LiquidStack representing the fuel type and amount consumed per triggered cycle.
*/
public FluidStack getFuelConsumed() {
return fuelConsumed;
}
/**
* EU emitted per tick while this fuel is being consumed in the generator (i.e. biofuel = 32, biomass = 8).
*/
public int getEu() {
return eu;
}
/**
* Rate at which the fuel is consumed. 1 - Every tick 2 - Every second tick 3 - Every third tick etc.
*/
public int getRate() {
return rate;
}
}
@@ -8,22 +8,10 @@ package forestry.api.fuels;
import net.minecraft.item.ItemStack;
public class MoistenerFuel {
/**
* The item to use
*/
public final ItemStack item;
/**
* The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch)
*/
public final ItemStack product;
/**
* How much this item contributes to the final product of the moistener (i.e. mycelium)
*/
public final int moistenerValue;
/**
* What stage this product represents. Resources with lower stage value will be consumed first.
*/
public final int stage;
private final ItemStack item;
private final ItemStack product;
private final int moistenerValue;
private final int stage;
public MoistenerFuel(ItemStack item, ItemStack product, int stage, int moistenerValue) {
this.item = item;
@@ -31,4 +19,32 @@ public class MoistenerFuel {
this.stage = stage;
this.moistenerValue = moistenerValue;
}
/**
* The item to use
*/
public ItemStack getItem() {
return item;
}
/**
* The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch)
*/
public ItemStack getProduct() {
return product;
}
/**
* How much this item contributes to the final product of the moistener (i.e. mycelium)
*/
public int getMoistenerValue() {
return moistenerValue;
}
/**
* What stage this product represents. Resources with lower stage value will be consumed first.
*/
public int getStage() {
return stage;
}
}
@@ -3,7 +3,7 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion = "2.0.1", owner = "ForestryAPI|core", provides = "ForestryAPI|fuels")
@API(apiVersion = "3.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|fuels")
package forestry.api.fuels;
import net.minecraftforge.fml.common.API;
@@ -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,48 +5,48 @@
******************************************************************************/
package forestry.api.genetics;
import net.minecraft.block.Block;
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 IMutationCustom extends IMutation {
public interface IMutationBuilder {
IMutation build();
/** Prevent this mutation from being shown in the analyzers */
IMutationCustom setIsSecret();
IMutationBuilder setIsSecret();
/** Require a specific temperature for this mutation to occur */
IMutationCustom restrictTemperature(EnumTemperature temperature);
IMutationBuilder restrictTemperature(EnumTemperature temperature);
IMutationCustom restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
IMutationBuilder restrictTemperature(EnumTemperature minTemperature, EnumTemperature maxTemperature);
/** Require a specific humidity for this mutation to occur */
IMutationCustom restrictHumidity(EnumHumidity humidity);
IMutationBuilder restrictHumidity(EnumHumidity humidity);
IMutationCustom restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
IMutationBuilder restrictHumidity(EnumHumidity minHumidity, EnumHumidity maxHumidity);
/**
* Restrict this mutation to certain types of biomes.
* @param types The types of biomes this mutation can occur.
*/
IMutationCustom restrictBiomeType(BiomeDictionary.Type... types);
IMutationBuilder restrictBiomeType(BiomeDictionary.Type... types);
/** Restrict the days of the year that this mutation can occur */
IMutationCustom restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
IMutationBuilder restrictDateRange(int startMonth, int startDay, int endMonth, int endDay);
/** Restrict the time of day that this mutation can occur */
IMutationCustom requireDay();
IMutationBuilder requireDay();
IMutationCustom requireNight();
IMutationBuilder requireNight();
/** Require a specific resource to be under the location of the mutation */
IMutationCustom requireResource(Block block, int meta);
IMutationBuilder requireResource(IBlockState... acceptedBlockStates);
IMutationCustom requireResource(String oreDictName);
IMutationBuilder requireResource(String oreDictName);
/** Require some other custom mutation condition */
IMutationCustom addMutationCondition(IMutationCondition mutationCondition);
IMutationBuilder addMutationCondition(IMutationCondition mutationCondition);
}
@@ -5,6 +5,7 @@
******************************************************************************/
package forestry.api.genetics;
import forestry.api.core.IClimateProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -15,7 +16,7 @@ public interface IMutationCondition {
* Most will return 1 if the condition is met and 0 otherwise,
* but the float offers flexibility for more advanced conditions.
*/
float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1);
float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1, IClimateProvider climate);
/**
* A localized description of the mutation condition. (i.e. "A temperature of HOT is required.")
@@ -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.
@@ -5,8 +5,9 @@
******************************************************************************/
package forestry.api.lepidopterology;
import forestry.api.genetics.IMutationCustom;
public interface IButterflyMutationCustom extends IButterflyMutation, IMutationCustom {
import forestry.api.genetics.IMutationBuilder;
public interface IButterflyMutationBuilder extends IMutationBuilder {
@Override
IButterflyMutation build();
}
@@ -11,7 +11,7 @@ public interface IButterflyMutationFactory {
/**
* Creates a new butterfly mutation.
* Automatically registered with ButterflyManager.butterflyRoot.registerMutation()
* See IButterflyMutationCustom and IMutationCustom for adding additional properties to the returned mutation.
* See IButterflyMutationBuilder and IMutationBuilder for adding additional properties to the returned mutation.
*
* @param parentButterfly0 A parent butterfly for this mutation
* @param parentButterfly1 A parent butterfly for this mutation
@@ -19,5 +19,5 @@ public interface IButterflyMutationFactory {
* @param chance The chance that breeding the two parent butterfly's will result in this mutation
* @return a new butterfly mutation.
*/
IButterflyMutationCustom createMutation(IAlleleButterflySpecies parentButterfly0, IAlleleButterflySpecies parentButterfly1, IAllele[] result, int chance);
IButterflyMutationBuilder createMutation(IAlleleButterflySpecies parentButterfly0, IAlleleButterflySpecies parentButterfly1, IAllele[] result, int chance);
}
@@ -5,10 +5,11 @@
******************************************************************************/
package forestry.api.lepidopterology;
import forestry.api.core.IClimateProvider;
import forestry.api.genetics.IHousing;
import forestry.api.genetics.IIndividual;
public interface IButterflyNursery extends IHousing {
public interface IButterflyNursery extends IHousing, IClimateProvider {
IButterfly getCaterpillar();
@@ -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
@@ -17,9 +17,5 @@ public interface IMailAddress extends INbtWritable {
boolean isValid();
boolean isPlayer();
boolean isTrader();
GameProfile getPlayerProfile();
}
@@ -5,6 +5,7 @@
******************************************************************************/
package forestry.api.mail;
import javax.annotation.Nonnull;
import java.util.Map;
import net.minecraft.item.ItemStack;
@@ -18,9 +19,10 @@ public interface IPostRegistry {
IPostOffice getPostOffice(World world);
/* MAIL ADDRESSES */
IMailAddress getMailAddress(GameProfile gameProfile);
IMailAddress getMailAddress(String traderName);
@Nonnull
IMailAddress getMailAddress(@Nonnull GameProfile gameProfile);
IMailAddress getMailAddress(@Nonnull String traderName);
/* LETTERS */
boolean isLetter(ItemStack itemstack);
@@ -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();
}
@@ -5,43 +5,42 @@
******************************************************************************/
package forestry.api.storage;
import java.util.List;
import javax.annotation.Nonnull;
import java.util.function.Predicate;
import net.minecraft.item.ItemStack;
public interface IBackpackDefinition extends Predicate<ItemStack> {
/**
* To make your own backpack, create a backpack definition and register it with
* {@link IBackpackInterface#registerBackpackDefinition(String, IBackpackDefinition)}.
*/
public interface IBackpackDefinition {
/**
* @return Human-readable name of the backpack.
*/
@Nonnull
String getName(ItemStack backpack);
/**
* @return Primary colour for the backpack icon.
* @return Primary color for the backpack icon.
*/
int getPrimaryColour();
/**
* @return Secondary colour for backpack icon.
* @return Secondary color for backpack icon, normally white.
*/
int getSecondaryColour();
/**
* Adds an item as valid for this backpack.
* Filters items that can be put into a backpack.
*
* @param validItem
* For Backpack Implementers: you can create a new filter with
* {@link IBackpackInterface#createBackpackFilter()} or
* {@link IBackpackInterface#createNaturalistBackpackFilter(String)}
* or implement your own.
*
* @return the backpack's item filter.
*/
void addValidItem(ItemStack validItem);
void addValidItems(List<ItemStack> validItems);
void addValidOreDictName(String oreDictName);
/**
* Returns true if the ItemStack is a valid item for this backpack type.
*/
@Override
boolean test(ItemStack itemstack);
@Nonnull
Predicate<ItemStack> getFilter();
}
@@ -0,0 +1,45 @@
package forestry.api.storage;
import java.util.function.Predicate;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
/**
* A configurable backpack filter. Useful for implementers of {@link IBackpackDefinition}.
* Get a new instance from {@link IBackpackInterface#createBackpackFilter()}.
*/
public interface IBackpackFilterConfigurable extends Predicate<ItemStack> {
/**
* Adds an item as valid for this backpack to pick up.
*/
void acceptItem(ItemStack validItem);
/**
* Adds an item as invalid for this backpack, used to make exceptions to oreDictionary matches.
*
* @see #acceptOreDictName(String)
*/
void rejectItem(ItemStack invalidItem);
/**
* Adds an ore dictionary name as valid for this backpack.
* The backpack will pick up any item that has this oreDictName.
*
* @see OreDictionary
*/
void acceptOreDictName(String oreDictName);
/**
* Removes an ore dictionary name as valid for this backpack.
* The backpack will not pick up any item that has this oreDictName.
*
* @see OreDictionary
*/
void rejectOreDictName(String oreDictName);
/**
* Clear all the rules from this filter.
*/
void clear();
}
@@ -7,32 +7,83 @@ package forestry.api.storage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.function.Predicate;
import forestry.api.genetics.ISpeciesRoot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.IForgeRegistryEntry;
import net.minecraftforge.oredict.OreDictionary;
/**
* The Backpack Interface allows you to add items to Forestry backpacks or create your own backpacks.
* <p>
* To create your own backpack, create an {@link IBackpackDefinition}.
* Backpack definitions have a filter, which you can create here with
* {@link #createBackpackFilter()}
* or {@link #createNaturalistBackpackFilter(String)}
* or create your own.
* <p>
* After you've registered your backpack definition, create the item with
* {@link #createBackpack(String, EnumBackpackType)}
* or {@link #createNaturalistBackpack(String, ISpeciesRoot)}
* and then register the returned item with {@link GameRegistry#register(IForgeRegistryEntry)} like any other item.
*/
public interface IBackpackInterface {
/**
* Get a backpack with a given uid so you can add items to it or get information about it.
* returns null if there is no backpack for the given uid.
* Add an accepted item to a Forestry backpack.
*
* @param backpackUid The unique ID of the Forestry backpack. See {@link BackpackManager} for valid UIDs.
* @param itemStack The itemStack that the backpack should accept.
* {@link OreDictionary#WILDCARD_VALUE} can be used for meta value.
*/
void addItemToForestryBackpack(@Nonnull String backpackUid, @Nonnull ItemStack itemStack);
/**
* Register a backpack definition with a given uid.
*/
void registerBackpackDefinition(@Nonnull String backpackUid, @Nonnull IBackpackDefinition definition);
/**
* Get a backpack definition with a given uid.
*/
@Nullable
IBackpackDefinition getBackpack(@Nonnull String uid);
IBackpackDefinition getBackpackDefinition(@Nonnull String backpackUid);
/**
* Register a backpack with a given uid
*/
void registerBackpack(@Nonnull String uid, @Nonnull IBackpackDefinition definition);
/**
* Adds a backpack with the given definition and type, returning the item.
* Creates a backpack with the given UID and type, returning the item.
* The backpack's definition must first be registered with {@link #registerBackpackDefinition(String, IBackpackDefinition)}.
*
* @param definition
* Definition of backpack behaviour.
* @param type
* Type of backpack.
* @param backpackUid The unique ID of the backpack.
* @param type Type of backpack.
* @return Created backpack item.
*/
@Nonnull
Item createBackpack(@Nonnull IBackpackDefinition definition, @Nonnull EnumBackpackType type);
Item createBackpack(@Nonnull String backpackUid, @Nonnull EnumBackpackType type);
/**
* Create a backpack that can hold items from a specific {@link ISpeciesRoot}.
* The backpack's definition must first be registered with {@link #registerBackpackDefinition(String, IBackpackDefinition)}.
*
* @param backpackUid The unique ID of the backpack.
* @param speciesRoot The species root.
* @return Created backpack item.
*/
Item createNaturalistBackpack(@Nonnull String backpackUid, @Nonnull ISpeciesRoot speciesRoot);
/**
* Makes a new configurable backpack filter. Useful for implementing {@link IBackpackDefinition}.
*/
IBackpackFilterConfigurable createBackpackFilter();
/**
* Makes a new naturalist backpack filter. Only accepts items from a specific {@link ISpeciesRoot}.
* Useful for implementing {@link IBackpackDefinition} for naturalist's backpacks.
*
* @param speciesRootUid The species root's unique ID. See {@link ISpeciesRoot#getUID()}.
* @return a new backpack filter for the specified species root
* @see #createNaturalistBackpack(String, ISpeciesRoot)
*/
Predicate<ItemStack> createNaturalistBackpackFilter(String speciesRootUid);
}
@@ -3,7 +3,7 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@API(apiVersion = "3.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|storage")
@API(apiVersion = "5.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|storage")
package forestry.api.storage;
import net.minecraftforge.fml.common.API;
@@ -18,7 +18,7 @@ import forestry.api.arboriculture.ITreeGenome;
public interface ITreeGenData {
int getGirth(World world, BlockPos pos);
int getGirth();
float getHeightModifier();
@@ -11,6 +11,7 @@
package forestry.apiculture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -233,18 +234,20 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
if (beeType == EnumBeeType.PRINCESS) {
tickBreed();
} else if (beeType == EnumBeeType.QUEEN) {
queenWorkTick(queen);
queenWorkTick(queen, queenStack);
}
}
@Override
public void clearCachedValues() {
hasFlowersCache.clear();
queenCanWorkCache.clear();
canWork();
if (!housing.getWorldObj().isRemote) {
hasFlowersCache.clear();
queenCanWorkCache.clear();
canWork();
}
}
private void queenWorkTick(IBee queen) {
private void queenWorkTick(@Nullable IBee queen, @Nonnull ItemStack queenStack) {
if (queen == null) {
beeProgress = 0;
beeProgressMax = 0;
@@ -270,7 +273,8 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
// Write the changed queen back into the item stack.
NBTTagCompound nbttagcompound = new NBTTagCompound();
queen.writeToNBT(nbttagcompound);
housing.getBeeInventory().getQueen().setTagCompound(nbttagcompound);
queenStack.setTagCompound(nbttagcompound);
housing.getBeeInventory().setQueen(queenStack);
}
beeProgress = queen.getHealth();
@@ -16,7 +16,6 @@ import net.minecraft.util.EnumFacing;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.core.access.IAccessHandler;
import forestry.core.inventory.InventoryAdapterRestricted;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.SlotUtil;
@@ -27,8 +26,8 @@ public class InventoryBeeHousing extends InventoryAdapterRestricted implements I
public static final int SLOT_PRODUCT_1 = 2;
public static final int SLOT_PRODUCT_COUNT = 7;
public InventoryBeeHousing(int size, IAccessHandler accessHandler) {
super(size, "Items", accessHandler);
public InventoryBeeHousing(int size) {
super(size, "Items");
}
@Override
@@ -10,8 +10,6 @@
******************************************************************************/
package forestry.apiculture;
import com.google.common.collect.ImmutableMap;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -19,34 +17,7 @@ import java.util.Objects;
import java.util.Random;
import java.util.Set;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
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 com.google.common.collect.ImmutableMap;
import forestry.Forestry;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
@@ -119,6 +90,32 @@ import forestry.food.items.ItemRegistryFood;
import forestry.plugins.BlankForestryPlugin;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.ForestryPluginUids;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
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;
@ForestryPlugin(pluginID = ForestryPluginUids.APICULTURE, name = "Apiculture", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.apiculture.description")
public class PluginApiculture extends BlankForestryPlugin {
@@ -266,7 +263,7 @@ public class PluginApiculture extends BlankForestryPlugin {
VillagerRegistry villagerRegistry = VillagerRegistry.instance();
villagerRegistry.registerVillageCreationHandler(villageHandler);
villagerApiarist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_APIARIST, Constants.TEXTURE_SKIN_BEEKPEEPER);
villagerApiarist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_APIARIST, Constants.TEXTURE_SKIN_BEEKPEEPER, Constants.TEXTURE_SKIN_ZOMBIE_BEEKPEEPER);
villagerRegistry.register(villagerApiarist);
ItemStack wildcardPrincess = new ItemStack(items.beePrincessGE, 1);
@@ -12,10 +12,11 @@ package forestry.apiculture.blocks;
import forestry.api.core.Tabs;
import forestry.core.blocks.BlockBase;
import net.minecraft.block.material.Material;
public class BlockApiculture extends BlockBase<BlockTypeApiculture> {
public BlockApiculture(BlockTypeApiculture type) {
super(type);
super(type, Material.WOOD);
setCreativeTab(Tabs.tabApiculture);
setHarvestLevel("axe", 0);
}
@@ -12,6 +12,7 @@ package forestry.apiculture.blocks;
import java.util.Map;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import forestry.api.core.Tabs;
@@ -36,7 +37,7 @@ public class BlockRegistryApiculture extends BlockRegistry {
beeHouse = new BlockApiculture(BlockTypeApiculture.BEE_HOUSE);
registerBlock(beeHouse, new ItemBlockForestry(beeHouse), "bee_house");
beeChest = new BlockBase<>(BlockTypeApicultureTesr.APIARIST_CHEST);
beeChest = new BlockBase<>(BlockTypeApicultureTesr.APIARIST_CHEST, Material.WOOD);
registerBlock(beeChest, new ItemBlockForestry(beeChest), "bee_chest");
beeChest.setCreativeTab(Tabs.tabApiculture);
beeChest.setHarvestLevel("axe", 0);
@@ -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
@@ -1,94 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.entities;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.core.config.Constants;
import forestry.core.render.ForestryResource;
public class EntityBee extends EntityCreature implements IAnimals {
private static final String DEFAULT_TEXTURE = Constants.TEXTURE_PATH_ENTITIES + "/bees/honeyBee.png";
private IBee contained;
private IAlleleBeeSpecies species;
private EnumBeeType type = EnumBeeType.DRONE;
private String beeTexture = DEFAULT_TEXTURE;
private long lastUpdate;
public EntityBee(World world) {
super(world);
}
private void resetAppearance() {
beeTexture = species.getEntityTexture();
}
public EntityBee setIndividual(IBee bee) {
if (bee != null) {
contained = bee;
} else {
contained = BeeManager.beeRoot.templateAsIndividual(BeeManager.beeRoot.getDefaultTemplate());
}
//isImmuneToFire = contained.getGenome().getFireResist();
setSpecies(contained.getGenome().getPrimary());
//dataWatcher.updateObject(DATAWATCHER_ID_SPECIES, species.getUID());
//dataWatcher.updateObject(DATAWATCHER_ID_SCALE, (int)(contained.getSize() * 100));
return this;
}
public IBee getBee() {
return contained;
}
public EntityBee setType(EnumBeeType type) {
this.type = type;
return this;
}
public EnumBeeType getType() {
return type;
}
public EntityBee setSpecies(IAlleleBeeSpecies species) {
this.species = species;
resetAppearance();
lastUpdate = worldObj.getTotalWorldTime();
return this;
}
@SideOnly(Side.CLIENT)
private ResourceLocation textureResource;
private long lastTextureUpdate;
@SideOnly(Side.CLIENT)
public ResourceLocation getTexture() {
if (textureResource == null || lastTextureUpdate != lastUpdate) {
textureResource = new ForestryResource(beeTexture);
}
return textureResource;
}
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.entities;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -36,9 +37,12 @@ import forestry.core.config.Config;
import forestry.core.inventory.IInventoryAdapter;
public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implements IApiary {
@Nonnull
private static final IBeeModifier beeModifier = new ApiaryBeeModifier();
@Nonnull
private final IBeeListener beeListener = new ApiaryBeeListener(this);
private final InventoryApiary inventory = new InventoryApiary(getAccessHandler());
@Nonnull
private final InventoryApiary inventory = new InventoryApiary();
@SuppressWarnings("unused")
public EntityMinecartApiary(World world) {
@@ -64,6 +68,7 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement
return inventory;
}
@Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
@@ -10,17 +10,12 @@
******************************************************************************/
package forestry.apiculture.entities;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.Random;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import com.google.common.base.Optional;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
@@ -36,10 +31,24 @@ import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IForestryPacketServer;
import forestry.core.network.IStreamableGui;
import forestry.core.owner.GameProfileDataSerializer;
import forestry.core.owner.IOwnedTile;
import forestry.core.owner.IOwnerHandler;
import forestry.core.owner.OwnerHandler;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.IClimatised;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContainerForestry implements IBeeHousing, IOwnedTile, IGuiBeeHousingInventory, IClimatised, IStreamableGui {
private static final DataParameter<Optional<GameProfile>> OWNER = EntityDataManager.createKey(EntityMinecart.class, GameProfileDataSerializer.INSTANCE);
public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContainerForestry implements IBeeHousing, IGuiBeeHousingInventory, IClimatised, IStreamableGui {
private static final Random random = new Random();
private static final int beeFXInterval = 4;
private static final int pollenFXInterval = 50;
@@ -49,6 +58,23 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
private final IBeekeepingLogic beeLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
private final IErrorLogic errorLogic = ForestryAPI.errorStateRegistry.createErrorLogic();
private final OwnerHandler ownerHandler = new OwnerHandler() {
@Override
public void setOwner(@Nonnull GameProfile owner) {
super.setOwner(owner);
dataManager.set(OWNER, Optional.of(owner));
}
@Override
public GameProfile getOwner() {
Optional<GameProfile> gameProfileOptional = dataManager.get(OWNER);
if (gameProfileOptional.isPresent()) {
return gameProfileOptional.get();
} else {
return null;
}
}
};
// CLIENT
private int breedingProgressPercent = 0;
@@ -63,6 +89,18 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
super(world, posX, posY, posZ);
}
@Override
protected void entityInit() {
super.entityInit();
this.dataManager.register(OWNER, Optional.absent());
}
/* IOwnedTile */
@Override
public IOwnerHandler getOwnerHandler() {
return ownerHandler;
}
/* IBeeHousing */
@Override
public IBeekeepingLogic getBeekeepingLogic() {
@@ -111,7 +149,7 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
@Override
public GameProfile getOwner() {
return getAccessHandler().getOwner();
return getOwnerHandler().getOwner();
}
@Override
@@ -174,11 +212,13 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) {
super.readEntityFromNBT(nbtTagCompound);
beeLogic.readFromNBT(nbtTagCompound);
ownerHandler.readFromNBT(nbtTagCompound);
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) {
super.writeEntityToNBT(nbtTagCompound);
beeLogic.writeToNBT(nbtTagCompound);
ownerHandler.writeToNBT(nbtTagCompound);
}
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.entities;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.List;
@@ -33,7 +34,7 @@ import forestry.core.inventory.IInventoryAdapter;
public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
private static final IBeeModifier beeModifier = new BeehouseBeeModifier();
private static final IBeeListener beeListener = new DefaultBeeListener();
private final InventoryBeeHousing beeInventory = new InventoryBeeHousing(9, getAccessHandler());
private final InventoryBeeHousing beeInventory = new InventoryBeeHousing(9);
@SuppressWarnings("unused")
public EntityMinecartBeehouse(World world) {
@@ -72,6 +73,7 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
return Collections.singleton(beeListener);
}
@Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return beeInventory;
@@ -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;
}
}
@@ -29,7 +29,7 @@ import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IAlleleBeeSpeciesBuilder;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeMutationBuilder;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IAllele;
@@ -1035,7 +1035,7 @@ public enum BeeDefinition implements IBeeDefinition {
BeeManager.beeRoot.registerTemplate(template);
}
protected final IBeeMutationCustom registerMutation(BeeDefinition parent1, BeeDefinition parent2, int chance) {
protected final IBeeMutationBuilder registerMutation(BeeDefinition parent1, BeeDefinition parent2, int chance) {
return BeeManager.beeMutationFactory.createMutation(parent1.species, parent2.species, getTemplate(), chance);
}
@@ -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;
}
@@ -18,17 +18,23 @@ import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeeMutationBuilder;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.genetics.IAllele;
import forestry.core.genetics.mutations.Mutation;
public class BeeMutation extends Mutation implements IBeeMutationCustom {
public class BeeMutation extends Mutation implements IBeeMutation, IBeeMutationBuilder {
public BeeMutation(IAlleleBeeSpecies bee0, IAlleleBeeSpecies bee1, IAllele[] result, int chance) {
super(bee0, bee1, result, chance);
}
@Override
public IBeeMutation build() {
return this;
}
@Override
public IBeeRoot getRoot() {
return BeeManager.beeRoot;
@@ -39,7 +45,7 @@ public class BeeMutation extends Mutation implements IBeeMutationCustom {
World world = housing.getWorldObj();
BlockPos housingPos = housing.getCoordinates();
float processedChance = super.getChance(world, housingPos, allele0, allele1, genome0, genome1);
float processedChance = super.getChance(world, housingPos, allele0, allele1, genome0, genome1, housing);
if (processedChance <= 0) {
return 0;
}
@@ -12,16 +12,16 @@ package forestry.apiculture.genetics;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeMutationBuilder;
import forestry.api.apiculture.IBeeMutationFactory;
import forestry.api.genetics.IAllele;
public class BeeMutationFactory implements IBeeMutationFactory {
@Override
public IBeeMutationCustom createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance) {
IBeeMutationCustom mutation = new BeeMutation(parentBee0, parentBee1, result, chance);
BeeManager.beeRoot.registerMutation(mutation);
return mutation;
public IBeeMutationBuilder createMutation(IAlleleBeeSpecies parentBee0, IAlleleBeeSpecies parentBee1, IAllele[] result, int chance) {
BeeMutation beeMutation = new BeeMutation(parentBee0, parentBee1, result, chance);
BeeManager.beeRoot.registerMutation(beeMutation);
return beeMutation;
}
}
@@ -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);
}
}
@@ -195,9 +195,4 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
public int getSpriteColour(int renderPass) {
return beeSpriteColourProvider.getSpriteColour(renderPass);
}
@Override
public String getEntityTexture() {
return null;
}
}
@@ -1,9 +1,15 @@
package forestry.apiculture.genetics.alleles;
import java.util.List;
import java.util.Random;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
import forestry.core.utils.VectUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockMushroom;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.init.Blocks;
@@ -11,12 +17,6 @@ import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
public class AlleleEffectFungification extends AlleleEffectThrottled {
@@ -24,7 +24,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
private static final int ENTITY_THROTTLE = 6;
public AlleleEffectFungification() {
super("mycophilic", true, 10, false, false);
super("mycophilic", true, 20, false, false);
}
@Override
@@ -57,50 +57,51 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
World world = housing.getWorldObj();
BlockPos housingCoordinates = housing.getCoordinates();
Vec3i area = getModifiedArea(genome, housing);
int blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX());
int blockY = getRandomOffset(world.rand, housingCoordinates.getY(), area.getY());
int blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ());
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
BlockPos pos = new BlockPos(blockX, blockY, blockZ);
Block block = world.getBlockState(pos).getBlock();
if (isSuitableForMycelium(world, block, pos)) {
world.setBlockState(pos, Blocks.MYCELIUM.getDefaultState());
break;
} else if (isSuitableForGrowth(block)) {
doMushroomGrowth(block, world, pos);
break;
}
blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX());
blockY = getRandomOffset(world.rand, housingCoordinates.getY(), area.getY());
blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ());
}
Vec3i halfArea = new Vec3i(area.getX() / 2, area.getY() / 2, area.getZ() / 2);
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
BlockPos pos = VectUtil.getRandomPositionInArea(world.rand, area).subtract(halfArea).add(housingCoordinates);
IBlockState blockState = world.getBlockState(pos);
if (convertToMycelium(world, blockState, pos)) {
return;
} else if (growGiantMushroom(world, blockState, pos)) {
return;
}
}
}
private static void doEntityEffect(IBeeGenome genome, IBeeHousing housing) {
List<EntityCow> cows = getEntitiesInRange(genome, housing, EntityCow.class);
for (EntityCow cow : cows) {
convertCowToMooshroom(cow);
if (convertCowToMooshroom(cow)) {
return;
}
}
}
private static int getRandomOffset(Random random, int centrePos, int offset) {
return centrePos + random.nextInt(offset) - offset / 2;
}
private static boolean isSuitableForMycelium(World world, Block block, BlockPos pos) {
return block == Blocks.GRASS || block == Blocks.DIRT && world.canBlockSeeSky(pos);
private static boolean convertToMycelium(World world, IBlockState blockState, BlockPos pos) {
Block block = blockState.getBlock();
if (block == Blocks.GRASS || block == Blocks.DIRT && world.canBlockSeeSky(pos)) {
world.setBlockState(pos, Blocks.MYCELIUM.getDefaultState());
return true;
}
return false;
}
private static boolean isSuitableForGrowth(Block block) {
return block == Blocks.RED_MUSHROOM || block == Blocks.BROWN_MUSHROOM;
private static boolean growGiantMushroom(World world, IBlockState blockState, BlockPos pos) {
Block block = blockState.getBlock();
if (block instanceof BlockMushroom) {
BlockMushroom mushroom = (BlockMushroom) block;
mushroom.generateBigMushroom(world, pos, blockState, world.rand);
return true;
}
return false;
}
private static void convertCowToMooshroom(EntityCow cow) {
private static boolean convertCowToMooshroom(EntityCow cow) {
if (cow instanceof EntityMooshroom) {
return;
return false;
}
World worldObj = cow.worldObj;
cow.setDead();
@@ -110,14 +111,6 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
mooshroom.renderYawOffset = cow.renderYawOffset;
worldObj.spawnEntityInWorld(mooshroom);
worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, cow.posX, cow.posY + cow.height / 2.0F, cow.posZ, 0.0D, 0.0D, 0.0D);
}
private static void doMushroomGrowth(Block block, World world, BlockPos pos) {
WorldGenBigMushroom giantMushroomGenerator;
giantMushroomGenerator = new WorldGenBigMushroom(block);
world.setBlockToAir(pos);
giantMushroomGenerator.generate(world, world.rand, pos);
return true;
}
}
@@ -22,15 +22,14 @@ import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.api.apiculture.IHiveFrame;
import forestry.apiculture.InventoryBeeHousing;
import forestry.core.access.IAccessHandler;
import forestry.core.utils.SlotUtil;
public class InventoryApiary extends InventoryBeeHousing implements IApiaryInventory {
public static final int SLOT_FRAMES_1 = 9;
public static final int SLOT_FRAMES_COUNT = 3;
public InventoryApiary(IAccessHandler accessHandler) {
super(12, accessHandler);
public InventoryApiary() {
super(12);
}
@Override
@@ -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()));
}
}
@@ -66,7 +66,8 @@ public class ItemMinecartBeehouse extends ItemMinecart implements IItemModelRegi
} else {
entityMinecart = new EntityMinecartApiary(worldIn, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F);
}
entityMinecart.setOwner(playerIn.getGameProfile());
entityMinecart.getOwnerHandler().setOwner(playerIn.getGameProfile());
if (stack.hasDisplayName()) {
entityMinecart.setCustomNameTag(stack.getDisplayName());
@@ -15,22 +15,13 @@ import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.block.Block;
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.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.core.BiomeHelper;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
@@ -39,7 +30,6 @@ import forestry.api.multiblock.IAlvearyComponent;
import forestry.api.multiblock.IMultiblockComponent;
import forestry.apiculture.AlvearyBeeModifier;
import forestry.apiculture.InventoryBeeHousing;
import forestry.core.access.EnumAccess;
import forestry.core.inventory.FakeInventoryAdapter;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.IMultiblockControllerInternal;
@@ -50,9 +40,17 @@ import forestry.core.network.DataOutputStreamForestry;
import forestry.core.proxy.Proxies;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.Translator;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public class AlvearyController extends RectangularMultiblockControllerBase implements IAlvearyControllerInternal, IClimateControlled {
@Nonnull
private final InventoryBeeHousing inventory;
private final IBeekeepingLogic beekeepingLogic;
@@ -71,12 +69,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
public AlvearyController(World world) {
super(world, AlvearyMultiblockSizeLimits.instance);
this.inventory = new InventoryBeeHousing(9, getAccessHandler());
this.inventory = new InventoryBeeHousing(9);
this.beekeepingLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
this.beeModifiers.add(new AlvearyBeeModifier());
}
@Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
@@ -340,20 +339,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
return new Vec3d(coord.getX() + 0.5, coord.getY() + 1.5, coord.getZ() + 0.5);
}
@Override
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
if (oldAccess == EnumAccess.SHARED || newAccess == EnumAccess.SHARED) {
// pipes connected to this need to update
for (IMultiblockComponent part : connectedParts) {
if (part instanceof TileEntity) {
TileEntity tile = (TileEntity) part;
worldObj.notifyBlockOfStateChange(tile.getPos(), tile.getBlockType());
}
}
markDirty();
}
}
@Override
public float getExactTemperature() {
BlockPos coords = getReferenceCoord();
@@ -369,8 +354,11 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public EnumTemperature getTemperature() {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(this);
if (beeModifier.isHellish() && tempChange >= 0) {
return EnumTemperature.HELLISH;
Biome biome = getBiome();
if (beeModifier.isHellish() || BiomeHelper.isBiomeHellish(biome)) {
if (tempChange >= 0) {
return EnumTemperature.HELLISH;
}
}
return EnumTemperature.getFromValue(getExactTemperature());
@@ -383,7 +371,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public GameProfile getOwner() {
return getAccessHandler().getOwner();
return getOwnerHandler().getOwner();
}
@Override
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.multiblock;
import javax.annotation.Nonnull;
import java.util.Collections;
import net.minecraft.util.math.BlockPos;
@@ -45,6 +46,7 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
return Collections.emptyList();
}
@Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return FakeBeeHousingInventory.instance;
@@ -11,13 +11,13 @@
package forestry.apiculture.multiblock;
import forestry.api.multiblock.IAlvearyController;
import forestry.core.access.IRestrictedAccess;
import forestry.core.owner.IOwnedTile;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.IMultiblockControllerInternal;
import forestry.core.network.IStreamableGui;
import forestry.core.tiles.IClimatised;
public interface IAlvearyControllerInternal extends IAlvearyController, IMultiblockControllerInternal, IClimatised, IRestrictedAccess, IStreamableGui {
public interface IAlvearyControllerInternal extends IAlvearyController, IMultiblockControllerInternal, IClimatised, IOwnedTile, IStreamableGui {
IInventoryAdapter getInternalInventory();
int getHealthScaled(int i);
@@ -10,9 +10,12 @@
******************************************************************************/
package forestry.apiculture.multiblock;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.List;
import forestry.core.owner.IOwnedTile;
import forestry.core.owner.IOwnerHandler;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
@@ -33,9 +36,6 @@ import forestry.api.multiblock.IMultiblockController;
import forestry.apiculture.blocks.BlockAlvearyType;
import forestry.apiculture.gui.ContainerAlveary;
import forestry.apiculture.gui.GuiAlveary;
import forestry.core.access.EnumAccess;
import forestry.core.access.IAccessHandler;
import forestry.core.access.IRestrictedAccess;
import forestry.core.config.Config;
import forestry.core.gui.IHintSource;
import forestry.core.inventory.IInventoryAdapter;
@@ -46,7 +46,7 @@ import forestry.core.network.IStreamableGui;
import forestry.core.tiles.IClimatised;
import forestry.core.tiles.ITitled;
public abstract class TileAlveary extends MultiblockTileEntityForestry<MultiblockLogicAlveary> implements IBeeHousing, IAlvearyComponent, IRestrictedAccess, IStreamableGui, ITitled, IClimatised, IHintSource {
public abstract class TileAlveary extends MultiblockTileEntityForestry<MultiblockLogicAlveary> implements IBeeHousing, IAlvearyComponent, IOwnedTile, IStreamableGui, ITitled, IClimatised, IHintSource {
private final String unlocalizedTitle;
protected TileAlveary() {
@@ -99,6 +99,7 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry<Multibloc
return getMultiblockLogic().getController().getBeeListeners();
}
@Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return getMultiblockLogic().getController().getBeeInventory();
@@ -141,13 +142,8 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry<Multibloc
}
@Override
public IAccessHandler getAccessHandler() {
return getMultiblockLogic().getController().getAccessHandler();
}
@Override
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
getMultiblockLogic().getController().onSwitchAccess(oldAccess, newAccess);
public IOwnerHandler getOwnerHandler() {
return getMultiblockLogic().getController().getOwnerHandler();
}
@Override
@@ -11,6 +11,7 @@
package forestry.apiculture.multiblock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
@@ -23,6 +24,7 @@ import forestry.core.tiles.IActivatable;
import forestry.energy.EnergyManager;
import cofh.api.energy.IEnergyReceiver;
import net.minecraftforge.common.capabilities.Capability;
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyReceiver, IActivatable, IAlvearyComponent.Climatiser {
@@ -143,4 +145,18 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
return energyManager.canConnectEnergy(from);
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return energyManager.hasCapability(capability) || super.hasCapability(capability, facing);
}
@Nonnull
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
T energyCapability = energyManager.getCapability(capability);
if (energyCapability != null) {
return energyCapability;
}
return super.getCapability(capability, facing);
}
}
@@ -1,44 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;
import forestry.apiculture.entities.EntityBee;
import forestry.core.proxy.Proxies;
public class RenderBeeEntity extends RenderLiving {
private final ModelBee beeModel;
public RenderBeeEntity() {
super(Proxies.common.getClientInstance().getRenderManager(), new ModelBee(), 0.15f);
beeModel = (ModelBee) mainModel;
}
private void renderBee(EntityBee entity, double posX, double posY, double posZ, float par8, float par9) {
beeModel.setType(entity.getType());
this.doRender(entity, posX, posY, posZ, par8, par9);
}
@Override
public void doRender(EntityLiving entity, double x, double y, double z, float entityYaw, float partialTicks) {
renderBee((EntityBee) entity, x, y, z, entityYaw, partialTicks);
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return ((EntityBee) entity).getTexture();
}
}
@@ -1,10 +1,13 @@
package forestry.apiculture.tiles;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.IBeeHousingInventory;
public class FakeBeeHousingInventory implements IBeeHousingInventory {
@Nonnull
public static final FakeBeeHousingInventory instance = new FakeBeeHousingInventory();
private FakeBeeHousingInventory() {
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.tiles;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -30,15 +31,19 @@ import forestry.apiculture.inventory.IApiaryInventory;
import forestry.apiculture.inventory.InventoryApiary;
public class TileApiary extends TileBeeHousingBase implements IApiary {
@Nonnull
private final IBeeModifier beeModifier = new ApiaryBeeModifier();
@Nonnull
private final IBeeListener beeListener = new ApiaryBeeListener(this);
private final InventoryApiary inventory = new InventoryApiary(getAccessHandler());
@Nonnull
private final InventoryApiary inventory = new InventoryApiary();
public TileApiary() {
super("apiary");
setInternalInventory(inventory);
}
@Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture.tiles;
import javax.annotation.Nonnull;
import java.util.Collections;
import net.minecraft.entity.player.EntityPlayer;
@@ -24,20 +25,24 @@ import forestry.apiculture.gui.ContainerBeeHousing;
import forestry.apiculture.gui.GuiBeeHousing;
public class TileBeeHouse extends TileBeeHousingBase {
@Nonnull
private static final IBeeModifier beeModifier = new BeehouseBeeModifier();
@Nonnull
private final IBeeListener beeListener;
@Nonnull
private final InventoryBeeHousing beeInventory;
public TileBeeHouse() {
super("bee.house");
this.beeListener = new DefaultBeeListener();
beeInventory = new InventoryBeeHousing(12, getAccessHandler());
beeInventory = new InventoryBeeHousing(12);
beeInventory.disableAutomation();
setInternalInventory(beeInventory);
}
@Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return beeInventory;
@@ -13,13 +13,7 @@ package forestry.apiculture.tiles;
import javax.annotation.Nonnull;
import java.io.IOException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingLogic;
@@ -30,11 +24,19 @@ import forestry.apiculture.gui.IGuiBeeHousingInventory;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamableGui;
import forestry.core.owner.IOwnedTile;
import forestry.core.owner.IOwnerHandler;
import forestry.core.owner.OwnerHandler;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.IClimatised;
import forestry.core.tiles.TileBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing, IClimatised, IGuiBeeHousingInventory, IStreamableGui {
public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing, IOwnedTile, IClimatised, IGuiBeeHousingInventory, IStreamableGui {
private final OwnerHandler ownerHandler = new OwnerHandler();
private final IBeekeepingLogic beeLogic;
private Biome cachedBiome;
@@ -57,6 +59,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound = super.writeToNBT(nbttagcompound);
beeLogic.writeToNBT(nbttagcompound);
ownerHandler.writeToNBT(nbttagcompound);
return nbttagcompound;
}
@@ -64,6 +67,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
beeLogic.readFromNBT(nbttagcompound);
ownerHandler.readFromNBT(nbttagcompound);
}
@Nonnull
@@ -71,6 +75,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
public NBTTagCompound getUpdateTag() {
NBTTagCompound updateTag = super.getUpdateTag();
beeLogic.writeToNBT(updateTag);
ownerHandler.writeToNBT(updateTag);
return updateTag;
}
@@ -78,6 +83,12 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
public void handleUpdateTag(@Nonnull NBTTagCompound tag) {
super.handleUpdateTag(tag);
beeLogic.readFromNBT(tag);
ownerHandler.readFromNBT(tag);
}
@Override
public IOwnerHandler getOwnerHandler() {
return ownerHandler;
}
/* ICLIMATISED */
@@ -171,7 +182,7 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
@Override
public GameProfile getOwner() {
return getAccessHandler().getOwner();
return getOwnerHandler().getOwner();
}
@Override
@@ -15,26 +15,8 @@ import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import com.google.common.base.Predicate;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
@@ -62,9 +44,41 @@ import forestry.core.tiles.IActivatable;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
public class TileHive extends TileEntity implements ITickable, IHiveTile, IActivatable, IBeeHousing {
private static final DamageSource damageSourceBeeHive = new DamageSourceForestry("bee.hive");
private static final Predicate<EntityLivingBase> BEE_TARGET_PREDICATE = new Predicate<EntityLivingBase>() {
@Override
public boolean apply(@Nullable EntityLivingBase input) {
if (input != null && input.isEntityAlive() && !input.isInvisible()) {
if (input instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) input;
return !player.isSpectator() && !player.isCreative();
} else if (input instanceof IMob) {
return true;
}
}
return false;
}
};
@Nonnull
private final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
@@ -113,7 +127,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
if (calmTime == 0) {
if (canWork) {
AxisAlignedBB boundingBox = AlleleEffect.getBounding(getContainedBee().getGenome(), this);
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox);
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, boundingBox, BEE_TARGET_PREDICATE);
if (!entities.isEmpty()) {
Collections.shuffle(entities);
EntityLivingBase entity = entities.get(0);
@@ -293,6 +307,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
return Collections.emptyList();
}
@Nonnull
@Override
public IBeeHousingInventory getBeeInventory() {
return inventory;
@@ -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 {
@@ -193,7 +198,7 @@ public class PluginArboriculture extends BlankForestryPlugin {
blocks.treeChest.init();
if (Config.enableVillagers) {
villagerArborist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_ARBORIST, Constants.TEXTURE_SKIN_LUMBERJACK);
villagerArborist = new VillagerRegistry.VillagerProfession(Constants.ID_VILLAGER_ARBORIST, Constants.TEXTURE_SKIN_LUMBERJACK, Constants.TEXTURE_SKIN_ZOMBIE_LUMBERJACK);
VillagerRegistry.instance().register(villagerArborist);
VillagerRegistry.VillagerCareer arboristCareer = new VillagerRegistry.VillagerCareer(villagerArborist, "arborist");
@@ -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) {
@@ -101,7 +101,6 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
}
@Override
@SideOnly(Side.CLIENT)
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
return new ItemStack(getItem());
}
@@ -12,10 +12,12 @@ package forestry.arboriculture.blocks;
import forestry.api.core.Tabs;
import forestry.core.blocks.BlockBase;
import net.minecraft.block.material.Material;
public class BlockArboriculture extends BlockBase<BlockTypeArboricultureTesr> {
public BlockArboriculture(BlockTypeArboricultureTesr type) {
super(type);
super(type, Material.WOOD);
setCreativeTab(Tabs.tabArboriculture);
setHarvestLevel("axe", 0);
}
}
@@ -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){
if (stack != null) {
return new Tree(stack.getTagCompound().getCompoundTag("ContainedTree"));
public static IAlleleTreeSpecies getTreeSpecies(ItemStack stack) {
if (stack != null && stack.hasTagCompound()) {
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;
@@ -39,7 +28,7 @@ import forestry.api.arboriculture.ILeafSpriteProvider;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenerator;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.ITreeMutationCustom;
import forestry.api.arboriculture.ITreeMutationBuilder;
import forestry.api.arboriculture.IWoodProvider;
import forestry.api.arboriculture.IWoodType;
import forestry.api.arboriculture.TreeManager;
@@ -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);
@@ -1030,7 +1010,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
return false;
}
tileLeaves.setOwner(owner);
tileLeaves.getOwnerHandler().setOwner(owner);
tileLeaves.setTree(new Tree(genome));
world.markBlockRangeForRenderUpdate(pos, pos);
@@ -1056,7 +1036,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe
TreeManager.treeRoot.registerTemplate(template);
}
protected final ITreeMutationCustom registerMutation(TreeDefinition parent1, TreeDefinition parent2, int chance) {
protected final ITreeMutationBuilder registerMutation(TreeDefinition parent1, TreeDefinition parent2, int chance) {
return TreeManager.treeMutationFactory.createMutation(parent1.species, parent2.species, getTemplate(), chance);
}
@@ -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());
}
}
@@ -10,23 +10,31 @@
******************************************************************************/
package forestry.arboriculture.genetics;
import forestry.api.core.ForestryAPI;
import forestry.core.DefaultClimateProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.ITreeMutationCustom;
import forestry.api.arboriculture.ITreeMutation;
import forestry.api.arboriculture.ITreeMutationBuilder;
import forestry.api.arboriculture.ITreeRoot;
import forestry.api.arboriculture.TreeManager;
import forestry.api.genetics.IAllele;
import forestry.core.genetics.mutations.Mutation;
public class TreeMutation extends Mutation implements ITreeMutationCustom {
public class TreeMutation extends Mutation implements ITreeMutation, ITreeMutationBuilder {
public TreeMutation(IAlleleTreeSpecies allele0, IAlleleTreeSpecies allele1, IAllele[] template, int chance) {
super(allele0, allele1, template, chance);
}
@Override
public ITreeMutation build() {
return this;
}
@Override
public ITreeRoot getRoot() {
return TreeManager.treeRoot;
@@ -34,7 +42,7 @@ public class TreeMutation extends Mutation implements ITreeMutationCustom {
@Override
public float getChance(World world, BlockPos pos, IAlleleTreeSpecies allele0, IAlleleTreeSpecies allele1, ITreeGenome genome0, ITreeGenome genome1) {
float processedChance = super.getChance(world, pos, allele0, allele1, genome0, genome1);
float processedChance = super.getChance(world, pos, allele0, allele1, genome0, genome1, ForestryAPI.climateManager.getDefaultClimate(world, pos));
if (processedChance <= 0) {
return 0;
}
Loaded 100 of 330 files, more files were not shown because too many files have changed in this diff. Show more