Ok now we need to learn how to actually understand how to set these blocks. So heres what we should do.Add this code to dirt's DestroyedByPlayer method.
world.setBlock(i, j + 1, k, Block.tnt.blockID);
Now you can test it if you want. It will not explode or anything but, it will set a tnt above the destroyed dirt.
Let me teach you about the ints i, j, k, and l. int i is the x-axis on your map. j is the y-axis on your map. k is the z-axis on your map.
l is the block set relevant to these ints'. So now that we kind of understand that, test out that method. It should do this:
This:
Will turn into this.
Now if we do this:
world.setBlock(i+1, j, k, Block.tnt.blockID);
It will set a tnt 1 x poistion away from the destroyed dirt.If we do this.
world.setBlock(i, j, k + 1, Block.tnt.blockID);
It will set a tnt one z poistion away from the destroyed dirt.
You can also set them in the opisite direction.
world.setBlock(i - 1, j - 1, k - 1, Block.tnt.blockID);
To set a row of blocks with a single line of code do this.
for(int i1 = -5; i1 < 5; i1++){
world.setBlock(i + i1, j, k, Block.tnt.blockID);
}
for(int j1 = -5; j1 < 5; j1++){
world.setBlock(i, j + j1, k, Block.tnt.blockID);
}
for(int k1 = -5; k1 < 5; k1++){
world.setBlock(i, j, k + k1, Block.tnt.blockID);
}
Now i1, j1, k1 can be named whatever you want. Just makes it easier. This will set a line of blocks along the said poistion. It will start with whatever
number the int equals. If the int equals -1 it will start 1 to the negative direction moving in the positive direction.
If you say int = -5; int < 4, -5 would be the starting poisition and 4 would be the end. Making it 10 blocks long.