public class SoulTreeGen extends WorldGenAbstractTree implements IWorldGenerator{
public static boolean bonemealingAllowed;
private final int minTreeHeight;
private final boolean vinesGrow;
private final int metaWood;
private final int metaLeaves;
private static final String __OBFID = "CL_00000438";
public SoulTreeGen(boolean SS)
{
this(SS, 4, 0, 0, false);
}
public SoulTreeGen(boolean doBlockNotify, int treeHeight, int wood, int leaves, boolean vines)
{
super(doBlockNotify);
this.minTreeHeight = treeHeight;
this.metaWood = wood;
this.metaLeaves = leaves;
this.vinesGrow = vines;
}
public boolean generate(World world, Random random, int posX, int posZ, int posY)
{
int l =random.nextInt(3) + this.minTreeHeight;
boolean flag = true;
if (posZ >= 1 && posZ + l + 1 <= 256)
{
byte b0;
int k1;
Block block;
/**
* Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length
*/
private void growVines(World world, int x, int starty, int z, int vine_length)
{
this.setBlockAndNotifyAdequately(world, x, starty, z, Blocks.vine, vine_length);
int i1 = 4;
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
int x = random.nextInt(16);
int z = random.nextInt(16);
public class SoulSapling extends BlockBush implements IGrowable{
public static boolean bonemealingAllowed;
public SoulSapling(Material p_i45394_1_) {
super();
}
@Override
public boolean func_149851_a(World arg0, int arg1, int arg2, int arg3,
boolean arg4) {
return false;
}
@Override
public boolean func_149852_a(World arg0, Random arg1, int arg2, int arg3,
int arg4) {
return false;
}
@Override
public void func_149853_b(World arg0, Random arg1, int arg2, int arg3,
int arg4) {
{
this.func_149878_d(arg0, arg2, arg3, arg4, arg1);
}
}
public static final String[] field_149882_a = new String[] {"SoulTree"};
private static final String __OBFID = "CL_00000305";
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World world, int posX, int posZ, int posY, Random random)
{
if (!world.isRemote)
{
super.updateTick(world, posX, posZ, posY, random);
public void func_149878_d(World world, int posX, int posZ, int posY, Random random)
{
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, random, posX, posZ, posY)) return;
int l = world.getBlockMetadata(posX, posZ, posY) & 7;
Object object = random.nextInt(10) == 0 ? new SoulTreeGen(true) : new SoulTreeGen(true);
int i1 = 0;
int j1 = 0;
boolean flag = false;
switch (l)
{
case 0:
default:
break;
case 1:
if (!flag)
{
j1 = 0;
i1 = 0;
object = new SoulTreeGen(true);
}
break;
case 2:
object = new SoulTreeGen(true);
break;
case 3:
label93:
public boolean func_149880_a(World world, int posX, int posZ, int posY, int random)
{
return world.getBlock(posX, posZ, posY) == this && (world.getBlockMetadata(posX, posZ, posY) & 7) == random;
}
/**
* Determines the damage on the item the block drops. Used in cloth and wood.
*/
public int damageDropped(int dmg)
{
return MathHelper.clamp_int(dmg & 7, 0, 5);
}
}
Rollback Post to RevisionRollBack
Sarcasm doesn´t mean what you think it means, It means what you don´t think it means, so it means what you don´t think it means, simple!
When you right click on an IGrowable block with Bone Meal (ItemDye#applyBonemeal), it calls the following IGrowable methods in order (each of the first two methods must return true for the next to be called):
func_149851_a (both sides) - Return true if the block can be affected by Bone Meal
func_149852_a (server only) - Return true if the block should grow with this click (vanilla saplings determine this with a random chance)
func_149853_b (server only) - Grow the block
Your func_149851_a and func_149852_a methods both return false, so func_149853_b is never called.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
When you right click on an IGrowable block with Bone Meal (ItemDye#applyBonemeal), it calls the following IGrowable methods in order (each of the first two methods must return true for the next to be called):
func_149851_a (both sides) - Return true if the block can be affected by Bone Meal
func_149852_a (server only) - Return true if the block should grow with this click (vanilla saplings determine this with a random chance)
func_149853_b (server only) - Grow the block
Your func_149851_a and func_149852_a methods both return false, so func_149853_b is never called.
Tnx for the reply ill try it now!
Rollback Post to RevisionRollBack
Sarcasm doesn´t mean what you think it means, It means what you don´t think it means, so it means what you don´t think it means, simple!
When you right click on an IGrowable block with Bone Meal (ItemDye#applyBonemeal), it calls the following IGrowable methods in order (each of the first two methods must return true for the next to be called):
func_149851_a (both sides) - Return true if the block can be affected by Bone Meal
func_149852_a (server only) - Return true if the block should grow with this click (vanilla saplings determine this with a random chance)
func_149853_b (server only) - Grow the block
Your func_149851_a and func_149852_a methods both return false, so func_149853_b is never called.
ok so that did worked for bonemeal effect, but now when i Rclick with bonemeal on sapling, it disappears, and grass block turns into dirt block. LoL
Rollback Post to RevisionRollBack
Sarcasm doesn´t mean what you think it means, It means what you don´t think it means, so it means what you don´t think it means, simple!
So i created a new tree type and new sapling type.
The Tree grows from sapling, but sapling wont grow when right clicking with bonemeal
TreeGen:
package com.aosp.world;
import java.util.Random;
import com.aosp.Blocks.VBlocks;
import com.aosp.BlocksClass.SoulSapling;
import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSapling;
import net.minecraft.init.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
import net.minecraftforge.common.util.ForgeDirection;
public class SoulTreeGen extends WorldGenAbstractTree implements IWorldGenerator{
public static boolean bonemealingAllowed;
private final int minTreeHeight;
private final boolean vinesGrow;
private final int metaWood;
private final int metaLeaves;
private static final String __OBFID = "CL_00000438";
public SoulTreeGen(boolean SS)
{
this(SS, 4, 0, 0, false);
}
public SoulTreeGen(boolean doBlockNotify, int treeHeight, int wood, int leaves, boolean vines)
{
super(doBlockNotify);
this.minTreeHeight = treeHeight;
this.metaWood = wood;
this.metaLeaves = leaves;
this.vinesGrow = vines;
}
public boolean generate(World world, Random random, int posX, int posZ, int posY)
{
int l =random.nextInt(3) + this.minTreeHeight;
boolean flag = true;
if (posZ >= 1 && posZ + l + 1 <= 256)
{
byte b0;
int k1;
Block block;
for (int i1 = posZ; i1 <= posZ + 1 + l; ++i1)
{
b0 = 1;
if (i1 == posZ)
{
b0 = 0;
}
if (i1 >= posZ + 1 + l - 2)
{
b0 = 2;
}
for (int j1 = posX - b0; j1 <= posX + b0 && flag; ++j1)
{
for (k1 = posY - b0; k1 <= posY + b0 && flag; ++k1)
{
if (i1 >= 0 && i1 < 256)
{
block = world.getBlock(j1, i1, k1);
if (!this.isReplaceable(world, j1, i1, k1))
{
flag = false;
}
}
else
{
flag = false;
}
}
}
}
if (!flag)
{
return false;
}
else
{
Block block2 = world.getBlock(posX, posZ - 1, posY);
boolean isSoil = block2.canSustainPlant(world, posX, posZ - 1, posY, ForgeDirection.UP, (SoulSapling)VBlocks.SoulSapling);
if (isSoil && posZ < 256 - l - 1)
{
block2.onPlantGrow(world, posX, posZ - 1, posY, posX, posZ, posY);
b0 = 3;
byte b1 = 0;
int l1;
int i2;
int j2;
int i3;
for (k1 = posZ - b0 + l; k1 <= posZ + l; ++k1)
{
i3 = k1 - (posZ + l);
l1 = b1 + 1 - i3 / 2;
for (i2 = posX - l1; i2 <= posX + l1; ++i2)
{
j2 = i2 - posX;
for (int k2 = posY - l1; k2 <= posY + l1; ++k2)
{
int l2 = k2 - posY;
if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || random.nextInt(2) != 0 && i3 != 0)
{
Block block1 = world.getBlock(i2, k1, k2);
if (block1.isAir(world, i2, k1, k2) || block1.isLeaves(world, i2, k1, k2))
{
this.setBlockAndNotifyAdequately(world, i2, k1, k2, VBlocks.SoulTreeLeaves, this.metaLeaves);
}
}
}
}
}
for (k1 = 0; k1 < l; ++k1)
{
block = world.getBlock(posX, posZ + k1, posY);
if (block.isAir(world, posX, posZ + k1, posY) || block.isLeaves(world, posX, posZ + k1, posY))
{
this.setBlockAndNotifyAdequately(world, posX, posZ + k1, posY, VBlocks.SoulTree_Log, this.metaWood);
if (this.vinesGrow && k1 > 0)
{
if (random.nextInt(3) > 0 && world.isAirBlock(posX - 1, posZ + k1, posY))
{
this.setBlockAndNotifyAdequately(world, posX - 1, posZ + k1, posY, Blocks.vine, 8);
}
if (random.nextInt(3) > 0 && world.isAirBlock(posX + 1, posZ + k1, posY))
{
this.setBlockAndNotifyAdequately(world, posX + 1, posZ + k1, posY, Blocks.vine, 2);
}
if (random.nextInt(3) > 0 && world.isAirBlock(posX, posZ + k1, posY - 1))
{
this.setBlockAndNotifyAdequately(world, posX, posZ + k1, posY - 1, Blocks.vine, 1);
}
if (random.nextInt(3) > 0 && world.isAirBlock(posX, posZ + k1, posY + 1))
{
this.setBlockAndNotifyAdequately(world, posX, posZ + k1, posY + 1, Blocks.vine, 4);
}
}
}
}
if (this.vinesGrow)
{
for (k1 = posZ - 3 + l; k1 <= posZ + l; ++k1)
{
i3 = k1 - (posZ + l);
l1 = 2 - i3 / 2;
for (i2 = posX - l1; i2 <= posX + l1; ++i2)
{
for (j2 = posY - l1; j2 <= posY + l1; ++j2)
{
if (world.getBlock(i2, k1, j2).isLeaves(world, i2, k1, j2))
{
if (random.nextInt(4) == 0 && world.getBlock(i2 - 1, k1, j2).isAir(world, i2 - 1, k1, j2))
{
this.growVines(world, i2 - 1, k1, j2, 8);
}
if (random.nextInt(4) == 0 && world.getBlock(i2 + 1, k1, j2).isAir(world, i2 + 1, k1, j2))
{
this.growVines(world, i2 + 1, k1, j2, 2);
}
if (random.nextInt(4) == 0 && world.getBlock(i2, k1, j2 - 1).isAir(world, i2, k1, j2 - 1))
{
this.growVines(world, i2, k1, j2 - 1, 1);
}
if (random.nextInt(4) == 0 && world.getBlock(i2, k1, j2 + 1).isAir(world, i2, k1, j2 + 1))
{
this.growVines(world, i2, k1, j2 + 1, 4);
}
}
}
}
}
if (random.nextInt(5) == 0 && l > 5)
{
for (k1 = 0; k1 < 2; ++k1)
{
for (i3 = 0; i3 < 4; ++i3)
{
if (random.nextInt(4 - k1) == 0)
{
l1 = random.nextInt(3);
this.setBlockAndNotifyAdequately(world, posX + Direction.offsetX[Direction.rotateOpposite[i3]], posZ + l - 5 + k1, posY + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, l1 << 2 | i3);
}
}
}
}
}
return true;
}
else
{
return false;
}
}
}
else
{
return false;
}
}
/**
* Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length
*/
private void growVines(World world, int x, int starty, int z, int vine_length)
{
this.setBlockAndNotifyAdequately(world, x, starty, z, Blocks.vine, vine_length);
int i1 = 4;
while (true)
{
--starty;
if (!world.getBlock(x, starty, z).isAir(world, x, starty, z) || i1 <= 0)
{
return;
}
this.setBlockAndNotifyAdequately(world, x, starty, z, Blocks.vine, vine_length);
--i1;
}
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
int x = random.nextInt(16);
int z = random.nextInt(16);
this.generate(world, random, x, world.getHeightValue(x, z), z);
}
}
SaplingClass
package com.aosp.BlocksClass;
import java.util.List;
import java.util.Random;
import com.aosp.Blocks.VBlocks;
import com.aosp.lib.RefStrings;
import com.aosp.world.SoulTreeGen;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigTree;
import net.minecraft.world.gen.feature.WorldGenCanopyTree;
import net.minecraft.world.gen.feature.WorldGenForest;
import net.minecraft.world.gen.feature.WorldGenMegaJungle;
import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
import net.minecraft.world.gen.feature.WorldGenSavannaTree;
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.event.entity.player.BonemealEvent;
public class SoulSapling extends BlockBush implements IGrowable{
public static boolean bonemealingAllowed;
public SoulSapling(Material p_i45394_1_) {
super();
}
@Override
public boolean func_149851_a(World arg0, int arg1, int arg2, int arg3,
boolean arg4) {
return false;
}
@Override
public boolean func_149852_a(World arg0, Random arg1, int arg2, int arg3,
int arg4) {
return false;
}
@Override
public void func_149853_b(World arg0, Random arg1, int arg2, int arg3,
int arg4) {
{
this.func_149878_d(arg0, arg2, arg3, arg4, arg1);
}
}
public static final String[] field_149882_a = new String[] {"SoulTree"};
private static final String __OBFID = "CL_00000305";
protected SoulSapling()
{
float f = 0.4F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World world, int posX, int posZ, int posY, Random random)
{
if (!world.isRemote)
{
super.updateTick(world, posX, posZ, posY, random);
if (world.getBlockLightValue(posX, posZ + 1, posY) >= 9 && random.nextInt(7) == 0)
{
this.func_149878_d(world, posX, posZ, posY, random);
}
}
}
public void func_149878_d(World world, int posX, int posZ, int posY, Random random)
{
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, random, posX, posZ, posY)) return;
int l = world.getBlockMetadata(posX, posZ, posY) & 7;
Object object = random.nextInt(10) == 0 ? new SoulTreeGen(true) : new SoulTreeGen(true);
int i1 = 0;
int j1 = 0;
boolean flag = false;
switch (l)
{
case 0:
default:
break;
case 1:
if (!flag)
{
j1 = 0;
i1 = 0;
object = new SoulTreeGen(true);
}
break;
case 2:
object = new SoulTreeGen(true);
break;
case 3:
label93:
for (i1 = 0; i1 >= -1; --i1)
{
for (j1 = 0; j1 >= -1; --j1)
{
if (this.func_149880_a(world, posX + i1, posZ, posY + j1, 3) && this.func_149880_a(world, posX + i1 + 1, posZ, posY + j1, 3) && this.func_149880_a(world, posX + i1, posZ, posY + j1 + 1, 3) && this.func_149880_a(world, posX + i1 + 1, posZ, posY + j1 + 1, 3))
{
object = new SoulTreeGen(true);
flag = true;
break label93;
}
}
}
if (!flag)
{
return;
}
}
Block block = Blocks.air;
if (flag)
{
world.setBlock(posX + i1, posZ, posY + j1, block, 0, 4);
world.setBlock(posX + i1 + 1, posZ, posY + j1, block, 0, 4);
world.setBlock(posX + i1, posZ, posY + j1 + 1, block, 0, 4);
world.setBlock(posX + i1 + 1, posZ, posY + j1 + 1, block, 0, 4);
}
else
{
world.setBlock(posX, posZ, posY, block, 0, 4);
}
if (!((WorldGenerator)object).generate(world, random, posX + i1, posZ, posY + j1))
{
if (flag)
{
world.setBlock(posX + i1, posZ, posY + j1, this, l, 4);
world.setBlock(posX + i1 + 1, posZ, posY + j1, this, l, 4);
world.setBlock(posX + i1, posZ, posY + j1 + 1, this, l, 4);
world.setBlock(posX + i1 + 1, posZ, posY + j1 + 1, this, l, 4);
}
else
{
world.setBlock(posX, posZ, posY, this, l, 4);
}
}
}
public boolean func_149880_a(World world, int posX, int posZ, int posY, int random)
{
return world.getBlock(posX, posZ, posY) == this && (world.getBlockMetadata(posX, posZ, posY) & 7) == random;
}
/**
* Determines the damage on the item the block drops. Used in cloth and wood.
*/
public int damageDropped(int dmg)
{
return MathHelper.clamp_int(dmg & 7, 0, 5);
}
}
Sarcasm doesn´t mean what you think it means, It means what you don´t think it means, so it means what you don´t think it means, simple!
When you right click on an IGrowable block with Bone Meal (ItemDye#applyBonemeal), it calls the following IGrowable methods in order (each of the first two methods must return true for the next to be called):
Your func_149851_a and func_149852_a methods both return false, so func_149853_b is never called.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Tnx for the reply ill try it now!
Sarcasm doesn´t mean what you think it means, It means what you don´t think it means, so it means what you don´t think it means, simple!
ok so that did worked for bonemeal effect, but now when i Rclick with bonemeal on sapling, it disappears, and grass block turns into dirt block. LoL
Sarcasm doesn´t mean what you think it means, It means what you don´t think it means, so it means what you don´t think it means, simple!
Thanks i fixed it with deleting flat lines of code
Sarcasm doesn´t mean what you think it means, It means what you don´t think it means, so it means what you don´t think it means, simple!