Fix #972 tree growing logs with default properties instead using genome

This commit is contained in:
mezz committed 2015-11-19 01:37:29 -08:00
1 parent aeaf113b11
commit 67a7185261
3 files changed
+28 -12

No files matched your search

@@ -49,11 +49,9 @@ import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IFruitFamily;
import forestry.api.genetics.IMutation;
import forestry.arboriculture.genetics.alleles.AlleleFruit;
import forestry.arboriculture.tiles.TileLeaves;
import forestry.core.config.Config;
import forestry.core.genetics.Chromosome;
import forestry.core.genetics.Individual;
import forestry.core.tiles.TileUtil;
import forestry.core.utils.StringUtil;
public class Tree extends Individual implements ITree, IPlantable {
@@ -223,21 +221,29 @@ public class Tree extends Individual implements ITree, IPlantable {
@Override
public void setLeaves(World world, GameProfile owner, int x, int y, int z) {
genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, false);
TileLeaves leaves = TileUtil.getTile(world, x, y, z, TileLeaves.class);
if (leaves != null) {
leaves.setTree(this);
try {
genome.getPrimary().getGenerator().setLeaves(genome, world, owner, x, y, z, false);
} catch (Throwable ignored) {
genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, false);
}
}
@Override
public void setLeavesDecorative(World world, GameProfile owner, int x, int y, int z) {
genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, true);
try {
genome.getPrimary().getGenerator().setLeaves(genome, world, owner, x, y, z, true);
} catch (Throwable ignored) {
genome.getPrimary().getGenerator().setLeaves(world, owner, x, y, z, true);
}
}
@Override
public void setLogBlock(World world, int x, int y, int z, ForgeDirection facing) {
genome.getPrimary().getGenerator().setLogBlock(world, x, y, z, facing);
try {
genome.getPrimary().getGenerator().setLogBlock(genome, world, x, y, z, facing);
} catch (Throwable ignored) {
genome.getPrimary().getGenerator().setLogBlock(world, x, y, z, facing);
}
}
@Override
@@ -994,7 +994,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
protected abstract void registerMutations();
@Override
public void setLogBlock(World world, int x, int y, int z, ForgeDirection facing) {
public void setLogBlock(ITreeGenome genome, World world, int x, int y, int z, ForgeDirection facing) {
if (woodType == null) {
Block vanillaWoodBlock = Block.getBlockFromItem(vanillaWood.getItem());
int vanillaWoodMeta = vanillaWood.getItemDamage();
@@ -1022,7 +1022,12 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
}
@Override
public void setLeaves(World world, GameProfile owner, int x, int y, int z, boolean decorative) {
public void setLogBlock(World world, int x, int y, int z, ForgeDirection facing) {
setLogBlock(genome, world, x, y, z, facing);
}
@Override
public void setLeaves(ITreeGenome genome, World world, GameProfile owner, int x, int y, int z, boolean decorative) {
boolean placed = world.setBlock(x, y, z, PluginArboriculture.blocks.leaves, 0, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
if (!placed) {
return;
@@ -1044,11 +1049,16 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
if (decorative) {
tileLeaves.setDecorative();
}
tileLeaves.setTree(getIndividual());
tileLeaves.setTree(new Tree(genome));
world.markBlockForUpdate(x, y, z);
}
@Override
public void setLeaves(World world, GameProfile owner, int x, int y, int z, boolean decorative) {
setLeaves(genome, world, owner, x, y, z, decorative);
}
public static void initTrees() {
for (TreeDefinition tree : values()) {
tree.init();