diff --git a/src/main/java/taintedmagic/common/blocks/BlockWarpwoodLog.java b/src/main/java/taintedmagic/common/blocks/BlockWarpwoodLog.java index 1e57ef1..312dad8 100644 --- a/src/main/java/taintedmagic/common/blocks/BlockWarpwoodLog.java +++ b/src/main/java/taintedmagic/common/blocks/BlockWarpwoodLog.java @@ -1,19 +1,26 @@ package taintedmagic.common.blocks; +import java.util.ArrayList; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockRotatedPillar; import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import taintedmagic.common.TaintedMagic; +import thaumcraft.client.fx.ParticleEngine; +import thaumcraft.client.fx.particles.FXWisp; +import thaumcraft.common.config.ConfigItems; public class BlockWarpwoodLog extends BlockRotatedPillar { - private IIcon side; - private IIcon top; + IIcon top, side, knot; public BlockWarpwoodLog () { @@ -25,22 +32,69 @@ public class BlockWarpwoodLog extends BlockRotatedPillar } @SideOnly (Side.CLIENT) - protected IIcon getTopIcon (int i) + protected IIcon getTopIcon (int meta) { - return this.top; + return top; } @SideOnly (Side.CLIENT) - protected IIcon getSideIcon (int i) + protected IIcon getSideIcon (int meta) { - return this.side; + return meta == 2 ? knot : side; } @SideOnly (Side.CLIENT) public void registerBlockIcons (IIconRegister ir) { - this.side = ir.registerIcon("taintedmagic:BlockWarpwoodLog_side"); - this.top = ir.registerIcon("taintedmagic:BlockWarpwoodLog_top"); + side = ir.registerIcon("taintedmagic:BlockWarpwoodLog_side"); + top = ir.registerIcon("taintedmagic:BlockWarpwoodLog_top"); + knot = ir.registerIcon("taintedmagic:BlockWarpwoodLog_knot"); + } + + @Override + public float getBlockHardness (World world, int x, int y, int z) + { + if (world.getBlockMetadata(x, y, z) == 2) return 25.0F; + return super.getBlockHardness(world, x, y, z); + } + + @Override + public ArrayList getDrops (World world, int x, int y, int z, int meta, int fortune) + { + ArrayList drops = new ArrayList(); + + if (meta == 2) drops.add(new ItemStack(ConfigItems.itemResource, world.rand.nextInt(5) + 1, 17)); + else drops.add(new ItemStack(this, 1, 0)); + + return drops; + } + + public boolean addDestroyEffects (World world, int x, int y, int z, int meta, EffectRenderer ef) + { + if (meta == 2) + { + if (world.isRemote) particles(world, x, y, z); + world.playSound(x + 0.5D, y + 0.5D, z + 0.5D, "thaumcraft:craftfail", 1.0F, 1.0F, false); + } + return super.addDestroyEffects(world, x, y, z, meta, ef); + } + + @SideOnly (Side.CLIENT) + private void particles (World world, int x, int y, int z) + { + for (int i = 0; i < 15; i++) + { + FXWisp fx = new FXWisp(world, x + 0.5D + (Math.random() - Math.random()) * 0.5D, + y + 0.5D + (Math.random() - Math.random()) * 0.5D, z + 0.5D + (Math.random() - Math.random()) * 0.5D, + 0.25F + (float) Math.random() * 0.25F, 5); + + fx.setGravity(0.01F); + + ParticleEngine.instance.addEffect(world, fx); + + fx.motionX = (fx.posX - x - 0.5D) * 0.025D; + fx.motionZ = (fx.posZ - z - 0.5D) * 0.025D; + } } public boolean canSustainLeaves (IBlockAccess world, int x, int y, int z) diff --git a/src/main/java/taintedmagic/common/world/WorldGenWarpwoodTree.java b/src/main/java/taintedmagic/common/world/WorldGenWarpwoodTree.java index 8363580..ea2c773 100644 --- a/src/main/java/taintedmagic/common/world/WorldGenWarpwoodTree.java +++ b/src/main/java/taintedmagic/common/world/WorldGenWarpwoodTree.java @@ -101,88 +101,80 @@ public class WorldGenWarpwoodTree extends WorldGenAbstractTree double d4 = (double) (k2 - cty); double d5 = (double) (zz - z); double dist = d3 * d3 + d4 * d4 + d5 * d5; + if (dist < (double) (10 + random.nextInt(8)) && world.getBlock(xx, k2, zz).canBeReplacedByLeaves(world, xx, k2, zz)) - { this.setBlockAndNotifyAdequately(world, xx, k2, zz, this.leaves, 1); - } } } } - int chance = (int) ((double) height * 1.5D); + int chance = height; boolean lastblock = false; - for (k2 = 0; k2 < height; ++k2) + for (k2 = 0; k2 < height; k2++) { Block block2 = world.getBlock(x, y + k2, z); - if (block2.isAir(world, x, y + k2, z) || block2.isLeaves(world, x, y + k2, z) - || block2.isReplaceable(world, x, y + k2, z)) + + if (!block2.isAir(world, x, y + k2, z) && !block2.isLeaves(world, x, y + k2, z) + && !block2.isReplaceable(world, x, y + k2, z)) + continue; + + if (k2 > 0 && !lastblock && random.nextInt(chance) == 0) { - this.setBlockAndNotifyAdequately(world, x, y + k2, z, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x - 1, y + k2, z, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x + 1, y + k2, z, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x, y + k2, z - 1, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x, y + k2, z + 1, this.trunk, 1); + setBlockAndNotifyAdequately(world, x, y + k2, z, this.trunk, 2); + lastblock = true; } + else + { + setBlockAndNotifyAdequately(world, x, y + k2, z, this.trunk, 0); + lastblock = false; + chance--; + } + setBlockAndNotifyAdequately(world, x - 1, y + k2, z, this.trunk, 0); + setBlockAndNotifyAdequately(world, x + 1, y + k2, z, this.trunk, 0); + setBlockAndNotifyAdequately(world, x, y + k2, z - 1, this.trunk, 0); + setBlockAndNotifyAdequately(world, x, y + k2, z + 1, this.trunk, 0); } - this.setBlockAndNotifyAdequately(world, x, y + k2, z, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x - 1, y, z - 1, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x + 1, y, z + 1, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x - 1, y, z + 1, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x + 1, y, z - 1, this.trunk, 1); - if (random.nextInt(3) != 0) - { - this.setBlockAndNotifyAdequately(world, x - 1, y + 1, z - 1, this.trunk, 1); - } + this.setBlockAndNotifyAdequately(world, x, y + k2, z, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x - 1, y, z - 1, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x + 1, y, z + 1, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x - 1, y, z + 1, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x + 1, y, z - 1, this.trunk, 0); - if (random.nextInt(3) != 0) - { - this.setBlockAndNotifyAdequately(world, x + 1, y + 1, z + 1, this.trunk, 1); - } + if (random.nextInt(3) != 0) this.setBlockAndNotifyAdequately(world, x - 1, y + 1, z - 1, this.trunk, 0); - if (random.nextInt(3) != 0) - { - this.setBlockAndNotifyAdequately(world, x - 1, y + 1, z + 1, this.trunk, 1); - } + if (random.nextInt(3) != 0) this.setBlockAndNotifyAdequately(world, x + 1, y + 1, z + 1, this.trunk, 0); - if (random.nextInt(3) != 0) - { - this.setBlockAndNotifyAdequately(world, x + 1, y + 1, z - 1, this.trunk, 1); - } + if (random.nextInt(3) != 0) this.setBlockAndNotifyAdequately(world, x - 1, y + 1, z + 1, this.trunk, 0); + + if (random.nextInt(3) != 0) this.setBlockAndNotifyAdequately(world, x + 1, y + 1, z - 1, this.trunk, 0); this.setBlockAndNotifyAdequately(world, x - 2, y, z, this.trunk, 5); this.setBlockAndNotifyAdequately(world, x + 2, y, z, this.trunk, 5); this.setBlockAndNotifyAdequately(world, x, y, z - 2, this.trunk, 9); this.setBlockAndNotifyAdequately(world, x, y, z + 2, this.trunk, 9); - this.setBlockAndNotifyAdequately(world, x - 2, y - 1, z, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x + 2, y - 1, z, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x, y - 1, z - 2, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x, y - 1, z + 2, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x - 1, y + (height - 4), z - 1, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x + 1, y + (height - 4), z + 1, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x - 1, y + (height - 4), z + 1, this.trunk, 1); - this.setBlockAndNotifyAdequately(world, x + 1, y + (height - 4), z - 1, this.trunk, 1); - if (random.nextInt(3) == 0) - { - this.setBlockAndNotifyAdequately(world, x - 1, y + (height - 5), z - 1, this.trunk, 1); - } + this.setBlockAndNotifyAdequately(world, x - 2, y - 1, z, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x + 2, y - 1, z, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x, y - 1, z - 2, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x, y - 1, z + 2, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x - 1, y + (height - 4), z - 1, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x + 1, y + (height - 4), z + 1, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x - 1, y + (height - 4), z + 1, this.trunk, 0); + this.setBlockAndNotifyAdequately(world, x + 1, y + (height - 4), z - 1, this.trunk, 0); if (random.nextInt(3) == 0) - { - this.setBlockAndNotifyAdequately(world, x + 1, y + (height - 5), z + 1, this.trunk, 1); - } + this.setBlockAndNotifyAdequately(world, x - 1, y + (height - 5), z - 1, this.trunk, 0); if (random.nextInt(3) == 0) - { - this.setBlockAndNotifyAdequately(world, x - 1, y + (height - 5), z + 1, this.trunk, 1); - } + this.setBlockAndNotifyAdequately(world, x + 1, y + (height - 5), z + 1, this.trunk, 0); if (random.nextInt(3) == 0) - { - this.setBlockAndNotifyAdequately(world, x + 1, y + (height - 5), z - 1, this.trunk, 1); - } + this.setBlockAndNotifyAdequately(world, x - 1, y + (height - 5), z + 1, this.trunk, 0); + + if (random.nextInt(3) == 0) + this.setBlockAndNotifyAdequately(world, x + 1, y + (height - 5), z - 1, this.trunk, 0); this.setBlockAndNotifyAdequately(world, x - 2, y + (height - 4), z, this.trunk, 5); this.setBlockAndNotifyAdequately(world, x + 2, y + (height - 4), z, this.trunk, 5);