diff --git a/dependencies.gradle b/dependencies.gradle index 7be431f1a..e5ba0a755 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,6 +1,7 @@ // Add your dependencies here dependencies { + api("com.github.GTNewHorizons:GTNHLib:0.9.41:dev") api('curse.maven:cofh-lib-220333:2388748') compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta68a:api') devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.70-GTNH:dev') diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index ce76fb2c5..4679e736a 100644 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -57,7 +57,8 @@ import forestry.plugins.PluginManager; name = Constants.MOD, version = Constants.VERSION, guiFactory = "forestry.core.config.ForestryGuiConfigFactory", - dependencies = "required-after:Forge@[10.13.4.1566,);" + "after:Buildcraft|Core@[6.1.7,);" + dependencies = "required-after:Forge@[10.13.4.1566,);" + "required-after:gtnhlib@[0.9.41,);" + + "after:Buildcraft|Core@[6.1.7,);" + "after:ExtrabiomesXL;" + "after:BiomesOPlenty;" + "after:IC2@[2.0.140,);" diff --git a/src/main/java/forestry/arboriculture/LeafDecayHelper.java b/src/main/java/forestry/arboriculture/LeafDecayHelper.java deleted file mode 100644 index 50621f9b4..000000000 --- a/src/main/java/forestry/arboriculture/LeafDecayHelper.java +++ /dev/null @@ -1,145 +0,0 @@ -package forestry.arboriculture; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockLeaves; -import net.minecraft.world.World; - -/** Based on vanilla leaf decay, but accepts leaves that are connected further from a trunk */ -public abstract class LeafDecayHelper { - - private static final short SUSTAINS_LEAVES = 0; - private static final short NOT_SUSTAINS_LEAVES = -1; - private static final short IS_LEAVES = -2; - private static int[] leafDecayValues; - - public static void leafDecay(BlockLeaves leaves, World world, int x, int y, int z) { - if (world.isRemote) { - return; - } - - int leafMeta = world.getBlockMetadata(x, y, z); - - if ((leafMeta & 8) != 0 && (leafMeta & 4) == 0) { - byte radius = 4; - byte yArrayMult = 32; - int xArrayMult = yArrayMult * yArrayMult; - int arrayOffset = yArrayMult / 2; - - if (leafDecayValues == null) { - leafDecayValues = new int[yArrayMult * yArrayMult * yArrayMult]; - } - - int radius1 = radius + 1; - if (world.checkChunksExist(x - radius1, y - radius1, z - radius1, x + radius1, y + radius1, z + radius1)) { - for (int xOffset = -radius; xOffset <= radius; ++xOffset) { - for (int yOffset = -radius; yOffset <= radius; ++yOffset) { - for (int zOffset = -radius; zOffset <= radius; ++zOffset) { - Block block = world.getBlock(x + xOffset, y + yOffset, z + zOffset); - - if (!block.canSustainLeaves(world, x + xOffset, y + yOffset, z + zOffset)) { - if (block.isLeaves(world, x + xOffset, y + yOffset, z + zOffset)) { - leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset] = IS_LEAVES; - } else { - leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset] = NOT_SUSTAINS_LEAVES; - } - } else { - leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset] = SUSTAINS_LEAVES; - } - } - } - } - - for (int sustainedValue = 1; sustainedValue <= 8; ++sustainedValue) { - for (int xOffset = -radius; xOffset <= radius; ++xOffset) { - for (int yOffset = -radius; yOffset <= radius; ++yOffset) { - for (int zOffset = -radius; zOffset <= radius; ++zOffset) { - if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset] == sustainedValue - 1) { - if (leafDecayValues[(xOffset + arrayOffset - 1) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset] == IS_LEAVES) { - leafDecayValues[(xOffset + arrayOffset - 1) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset] = sustainedValue; - } - - if (leafDecayValues[(xOffset + arrayOffset + 1) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset] == IS_LEAVES) { - leafDecayValues[(xOffset + arrayOffset + 1) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset] = sustainedValue; - } - - if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset - 1) * yArrayMult - + zOffset - + arrayOffset] == IS_LEAVES) { - leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset - 1) * yArrayMult - + zOffset - + arrayOffset] = sustainedValue; - } - - if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset + 1) * yArrayMult - + zOffset - + arrayOffset] == IS_LEAVES) { - leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset + 1) * yArrayMult - + zOffset - + arrayOffset] = sustainedValue; - } - - if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + (zOffset + arrayOffset - 1)] == IS_LEAVES) { - leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + (zOffset + arrayOffset - 1)] = sustainedValue; - } - - if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset - + 1] == IS_LEAVES) { - leafDecayValues[(xOffset + arrayOffset) * xArrayMult - + (yOffset + arrayOffset) * yArrayMult - + zOffset - + arrayOffset - + 1] = sustainedValue; - } - } - } - } - } - } - } - - int sustainValue = leafDecayValues[(arrayOffset * xArrayMult) + (arrayOffset * yArrayMult) + arrayOffset]; - - if (sustainValue >= 0) { - world.setBlockMetadataWithNotify(x, y, z, leafMeta & -9, 4); // stop trying to decay - } else { - leaves.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - world.setBlockToAir(x, y, z); - } - } - } -} diff --git a/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java b/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java index 7d6af0b70..3c324ed02 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockForestryLeaves.java @@ -34,6 +34,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import com.gtnewhorizon.gtnhlib.blocks.util.BFSLeafDecay; import com.mojang.authlib.GameProfile; import cpw.mods.fml.relauncher.Side; @@ -48,7 +49,6 @@ 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.genetics.TreeDefinition; import forestry.arboriculture.items.ItemBlockLeaves; import forestry.arboriculture.render.TextureLeaves; @@ -230,7 +230,12 @@ public class BlockForestryLeaves extends BlockNewLeaf implements ITileEntityProv return; } - LeafDecayHelper.leafDecay(this, world, x, y, z); + if (!world.isRemote) { + final int meta = world.getBlockMetadata(x, y, z); + if ((meta & 8) != 0 && (meta & 4) == 0) { + BFSLeafDecay.handleDecayChecked(this, world, x, y, z, meta, 4); + } + } // check leaves tile again because they can decay in super.updateTick if (tileLeaves.isInvalid()) {