Skip to content

Commit

Permalink
Fix log orientation for trees
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed May 20, 2016
1 parent 62368d4 commit ee63729
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions src/main/java/forestry/arboriculture/genetics/TreeDefinition.java
Expand Up @@ -16,6 +16,9 @@

import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.block.BlockNewLog;
import net.minecraft.block.BlockOldLog;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -94,7 +97,7 @@
import forestry.core.tiles.TileUtil;

public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSerializable {
Oak(TreeBranchDefinition.QUERCUS, "appleOak", "robur", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 0, new ItemStack(Blocks.LOG, 1, 0)) {
Oak(TreeBranchDefinition.QUERCUS, "appleOak", "robur", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 0, Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK)) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenOak(tree);
Expand All @@ -117,7 +120,7 @@ protected void registerMutations() {
// vanilla
}
},
DarkOak(TreeBranchDefinition.QUERCUS, "darkOak", "velutina", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 5, new ItemStack(Blocks.LOG2, 1, 1)) {
DarkOak(TreeBranchDefinition.QUERCUS, "darkOak", "velutina", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 5, Blocks.LOG2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.DARK_OAK)) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenDarkOak(tree);
Expand All @@ -140,7 +143,7 @@ protected void registerMutations() {
// vanilla
}
},
Birch(TreeBranchDefinition.BETULA, "silverBirch", "pendula", false, EnumLeafType.DECIDUOUS, new Color(8431445), new Color(0xb0c648), 2, new ItemStack(Blocks.LOG, 1, 2)) {
Birch(TreeBranchDefinition.BETULA, "silverBirch", "pendula", false, EnumLeafType.DECIDUOUS, new Color(8431445), new Color(0xb0c648), 2, Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.BIRCH)) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenBirch(tree);
Expand Down Expand Up @@ -345,7 +348,7 @@ protected void registerMutations() {
registerMutation(Spruce, Larch, 5);
}
},
Spruce(TreeBranchDefinition.PICEA, "redSpruce", "abies", false, EnumLeafType.CONIFERS, new Color(6396257), new Color(0x539d12), 1, new ItemStack(Blocks.LOG, 1, 1)) {
Spruce(TreeBranchDefinition.PICEA, "redSpruce", "abies", false, EnumLeafType.CONIFERS, new Color(6396257), new Color(0x539d12), 1, Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.SPRUCE)) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenSpruce(tree);
Expand Down Expand Up @@ -465,7 +468,7 @@ protected void registerMutations() {
// only available by rare villager trade
}
},
Jungle(TreeBranchDefinition.TROPICAL, "jungle", "tectona", false, EnumLeafType.JUNGLE, new Color(4764952), new Color(0x658917), 3, new ItemStack(Blocks.LOG, 1, 3)) {
Jungle(TreeBranchDefinition.TROPICAL, "jungle", "tectona", false, EnumLeafType.JUNGLE, new Color(4764952), new Color(0x658917), 3, Blocks.LOG.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE)) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenJungle(tree);
Expand Down Expand Up @@ -627,7 +630,7 @@ protected void registerMutations() {
registerMutation(Kapok, Ebony, 10);
}
},
AcaciaVanilla(TreeBranchDefinition.ACACIA, "acacia", "aneura", true, EnumLeafType.DECIDUOUS, new Color(0x616101), new Color(0xb3b302), 4, new ItemStack(Blocks.LOG2, 1, 0)) {
AcaciaVanilla(TreeBranchDefinition.ACACIA, "acacia", "aneura", true, EnumLeafType.DECIDUOUS, new Color(0x616101), new Color(0xb3b302), 4, Blocks.LOG2.getDefaultState().withProperty(BlockNewLog.VARIANT, BlockPlanks.EnumType.ACACIA)) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenAcaciaVanilla(tree);
Expand Down Expand Up @@ -955,13 +958,13 @@ protected void registerMutations() {
private final IAlleleTreeSpecies species;

private final EnumWoodType woodType; // for forestry trees
private final ItemStack vanillaWood; // for vanilla trees
private final IBlockState vanillaWood; // for vanilla trees

private IAllele[] template;
private ITreeGenome genome;

// vanilla tree constructor
TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, int vanillaMeta, ItemStack vanillaWood) {
TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, int vanillaMeta, IBlockState vanillaWood) {
String uid = "forestry.tree" + this;
String unlocalizedDescription = "for.description.tree" + this;
String unlocalizedName = "for.trees.species." + speciesName;
Expand Down Expand Up @@ -1009,28 +1012,16 @@ protected void registerMutations() {
@SuppressWarnings("incomplete-switch")
@Override
public void setLogBlock(ITreeGenome genome, World world, BlockPos pos, EnumFacing facing) {
IBlockState logBlock;
if (woodType == null) {
Block vanillaWoodBlock = Block.getBlockFromItem(vanillaWood.getItem());
int vanillaWoodMeta = vanillaWood.getItemDamage();
switch (facing) {
case NORTH:
case SOUTH:
vanillaWoodMeta |= 2 << 2;
break;
case EAST:
case WEST:
vanillaWoodMeta |= 1 << 2;
break;
}

world.setBlockState(pos, vanillaWoodBlock.getStateFromMeta(vanillaWoodMeta), Constants.FLAG_BLOCK_SYNCH);
logBlock = vanillaWood;
} else {
AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF);
boolean fireproof = fireproofAllele.getValue();
IBlockState logBlock = TreeManager.woodAccess.getLogBlock(woodType, fireproof);
logBlock.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.fromFacingAxis(facing.getAxis()));
world.setBlockState(pos, logBlock);
logBlock = TreeManager.woodAccess.getLogBlock(woodType, fireproof);
}
BlockLog.EnumAxis axis = BlockLog.EnumAxis.fromFacingAxis(facing.getAxis());
world.setBlockState(pos, logBlock.withProperty(BlockLog.LOG_AXIS, axis));
}

@Override
Expand Down

0 comments on commit ee63729

Please sign in to comment.