Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions src/main/java/twilightforest/block/BlockTFMagicLogSpecial.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockMushroom;
import net.minecraft.block.IGrowable;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
Expand Down Expand Up @@ -139,29 +141,38 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
private void doTreeOfTimeEffect(World world, int x, int y, int z, Random rand) {
int numticks = 8 * 3 * this.tickRate(world);

int successes = 0;

for (int i = 0; i < numticks; i++) {
// find a nearby block
int dx = rand.nextInt(32) - 16;
int dy = rand.nextInt(32) - 16;
int dz = rand.nextInt(32) - 16;

Block thereID = world.getBlock(x + dx, y + dy, z + dz);
int targetBlockX = x + dx;
int targetBlockY = y + dy;
int targetBlockZ = z + dz;

if (thereID != Blocks.air && thereID.getTickRandomly()) {
world.scheduleBlockUpdate(x + dx, y + dy, z + dz, thereID, 20);
thereID.updateTick(world, x + dx, y + dy, z + dz, rand);
// prevent chunk loads
if (!world.blockExists(targetBlockX, targetBlockY, targetBlockZ)) {
continue;
}

// System.out.println("tree of time ticked a block at " + (x + dx) + ", " + (y + dy) + ", " + (z +
// dz) + " and the block was " + Blocks.blocksList[thereID] );
Block targetBlock = world.getBlock(targetBlockX, targetBlockY, targetBlockZ);

successes++;
// plants only fools
if (!(targetBlock instanceof IGrowable)) {
continue;
}
}

// System.out.println("Tree of time had " + successes + " successes out of " + numticks + "
// attempts");
// except mushrooms
if (targetBlock instanceof BlockMushroom) {
continue;
}

if (targetBlock.getTickRandomly()) {
world.scheduleBlockUpdate(targetBlockX, targetBlockY, targetBlockZ, targetBlock, 20);
targetBlock.updateTick(world, targetBlockX, targetBlockY, targetBlockZ, rand);
}
}
}

/**
Expand Down