I managed to make it grow 1 more block, but I have a problem with the function updateTick
I've got the function from another mod, but that mod was making the crop grow 3 blocks, so I tried to make it grow only 2 but it doesnt update corectly.. well.. it doesnt grow fully.. it looks like this http://prntscr.com/deb0g9 instead of http://i.imgur.com/dOAPPQ5.png
I was trying to recreate the flax mod from 1.7.10 so the assets are taken from that mod..
I know it is because of this function because I messed around for like 2 hours trying figure out what was wrong
the original code:
/*public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
int j = ((Integer)state.getValue(AGE)).intValue();
if ((j != 9) && (j != 10) && (j != 11) && ((worldIn.getBlockState(pos.down()).getBlock() == this) || (canBlockStay(worldIn, pos, state)))) {
if ((worldIn.isAirBlock(pos.up())) || (j == 4) || (j == 7)) {
if (worldIn.getLightFromNeighbors(pos.up()) >= 9) {
if ((j == 0) || (j == 1) || (j == 2)) {
worldIn.setBlockState(pos, getStateFromMeta(j + 1));
}
if (j == 3) {
worldIn.setBlockState(pos, getStateFromMeta(4));
}
if (j == 5) {
worldIn.setBlockState(pos, getStateFromMeta(6));
}
if (j == 6) {
worldIn.setBlockState(pos, getStateFromMeta(7));
worldIn.setBlockState(pos.up(), getStateFromMeta();
}
if (j == {
worldIn.setBlockState(pos, getStateFromMeta(10));
worldIn.setBlockState(pos.down(), getStateFromMeta(9));
worldIn.setBlockState(pos.down(2), getStateFromMeta(9));
}
if (((j == 4) || (j == 7)) && (worldIn.getBlockState(pos.up()).getBlock() == this)) {
int k = ((Integer)worldIn.getBlockState(pos.up()).getValue(AGE)).intValue();
if (k == 5) {
worldIn.setBlockState(pos.up(), getStateFromMeta(6));
}
if (k == 6) {
worldIn.setBlockState(pos.up(), getStateFromMeta(7));
worldIn.setBlockState(pos.up(2), getStateFromMeta();
}
if (k == 7) {
worldIn.setBlockState(pos.up(2), getStateFromMeta(11));
worldIn.setBlockState(pos.up(), getStateFromMeta(10));
worldIn.setBlockState(pos, getStateFromMeta(9));
}
if (k == {
worldIn.setBlockState(pos.up(), getStateFromMeta(11));
worldIn.setBlockState(pos, getStateFromMeta(10));
worldIn.setBlockState(pos.down(), getStateFromMeta(9));
}
}
}
}
}
}*/
what I tried to do and have now:
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
int j = ((Integer)state.getValue(AGE)).intValue();
if (((worldIn.getBlockState(pos.down()).getBlock() == this) || (canBlockStay(worldIn, pos, state)))) {
if ((worldIn.isAirBlock(pos.up()))) {
if (worldIn.getLightFromNeighbors(pos.up()) >= {
if ((j == 0) || (j == 1) || (j == 2)) {
worldIn.setBlockState(pos, getStateFromMeta(j + 1));
}
if (j == 3) {
worldIn.setBlockState(pos, getStateFromMeta(4));
}
if (j == 4) {
worldIn.setBlockState(pos, getStateFromMeta(5));
}
if (j == 5) {
worldIn.setBlockState(pos, getStateFromMeta(6));
}
if (j == 6) {
worldIn.setBlockState(pos, getStateFromMeta(7));
worldIn.setBlockState(pos.up(), getStateFromMeta();
}
if ((j == 7) && (worldIn.getBlockState(pos.up()).getBlock() == this)) {
int k = ((Integer)worldIn.getBlockState(pos.up()).getValue(AGE)).intValue();
if (k == {
worldIn.setBlockState(pos.up(), getStateFromMeta(9));
}
if (k == 9) {
worldIn.setBlockState(pos.up(), getStateFromMeta(10));
}
if (k == 10) {
worldIn.setBlockState(pos.up(), getStateFromMeta(11));
}
if (k == 11) {
worldIn.setBlockState(pos.up(), getStateFromMeta(12));
}
if (k == 12) {
worldIn.setBlockState(pos.up(), getStateFromMeta(13));
}
if (k == 13) {
worldIn.setBlockState(pos.up(), getStateFromMeta(14));
}
}
}
}
}
}
the crop json:
{
"forge_marker": 1,
"defaults": {
"model": "cross"
},
"variants": {
"age": {
"0": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_0"
}
},
"1": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_1"
}
},
"2": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_2"
}
},
"3": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_3"
}
},
"4": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_4"
}
},
"5": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_5"
}
},
"6": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_6"
}
},
"7": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_7"
}
},
"8": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_8"
}
},
"9": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_9"
}
},
"10": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_10"
}
},
"11": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_11"
}
},
"12": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_12"
}
},
"13": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_13"
}
},
"14": {
"textures": {
"cross": "xcrops:blocks/flax/flaxBlock_stage_14"
}
}
}
}
}
what confuse me the most is the part where I add the second block and where I need to update it..