Skip to content

Commit

Permalink
Fix #1681 Worldgen leaves are not decaying
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed May 8, 2017
1 parent f7cc35d commit 828dd63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/main/java/forestry/arboriculture/LeafDecayHelper.java
Expand Up @@ -2,6 +2,7 @@

import java.util.Random;

import forestry.arboriculture.blocks.BlockAbstractLeaves;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.state.IBlockState;
Expand All @@ -23,12 +24,19 @@ public class LeafDecayHelper {
leafDecayValues = new byte[ARRAY_SIZE][ARRAY_SIZE][ARRAY_SIZE];
}

public static void leafDecay(BlockLeaves leaves, World world, BlockPos pos) {
public static void leafDecay(BlockAbstractLeaves leaves, World world, BlockPos pos) {
if (world.isRemote) {
return;
}
IBlockState state = world.getBlockState(pos);

// Fix a bug where Forestry leaves were not decayable.
// The non-decayable Forestry leaves are all BlockDecorativeLeaves.
if (!state.getValue(BlockLeaves.DECAYABLE)) {
state = state.withProperty(BlockLeaves.DECAYABLE, true);
world.setBlockState(pos, state);
}

if (state.getValue(BlockLeaves.CHECK_DECAY) && state.getValue(BlockLeaves.DECAYABLE)) {
byte radius = 4;
int arrayOffset = ARRAY_SIZE / 2;
Expand Down
Expand Up @@ -32,6 +32,7 @@
import forestry.core.items.ItemBlockForestry;
import forestry.core.utils.OreDictUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
Expand Down Expand Up @@ -246,11 +247,12 @@ public BlockRegistryArboriculture() {
registerBlock(leaves, new ItemBlockLeaves(leaves), "leaves.default." + leaves.getBlockNumber());
registerOreDictWildcard(OreDictUtil.TREE_LEAVES, leaves);

for (IBlockState state : leaves.getBlockState().getValidStates()) {
TreeDefinition treeDefinition = leaves.getTreeDefinition(state);
PropertyTreeType treeType = leaves.getVariant();
for (TreeDefinition treeDefinition : treeType.getAllowedValues()) {
Preconditions.checkNotNull(treeDefinition);
String speciesUid = treeDefinition.getUID();
speciesToLeavesDefault.put(speciesUid, state);
IBlockState blockState = leaves.getDefaultState().withProperty(treeType, treeDefinition);
speciesToLeavesDefault.put(speciesUid, blockState);
}
}

Expand Down

0 comments on commit 828dd63

Please sign in to comment.