Topic category: Help with MCreator software
I'm trying to make a custom tree spawn as a structure, but can't make it so that it only generates if it has enough room. Can you tell me what causes the error, or a better way to do it without the error?
Edit: It works after i removed the false statement from:
if ((world.getBlockState(new BlockPos(x + 2, y - 1, z + 2))).getBlock() == Blocks.SCULK || (world.getBlockState(new BlockPos(x + 2, y - 1, z + 2))).getBlock() == Blocks.DEEPSLATE
|| (world.getBlockState(new BlockPos(x + 2, y - 1, z + 2))).getBlock() == Blocks.STONE) {
return true;
} else {
return false;
Task :compileJava
F:\MCreator\Workspace\src\main\java\net\mcreator\test\procedures\Ancienttree1AdditionalGenerationConditionProcedure.java:15: error: unreachable statement if ((world.getBlockState(new BlockPos(x + 2, y + 1, z + 2))).getBlock() == Blocks.CAVE_AIR) {
^
1 error
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
1 actionable task: 1 executed
BUILD FAILED
Task completed in 7 seconds
The code:
public class Ancienttree1AdditionalGenerationConditionProcedure {
public static boolean execute(LevelAccessor world, double x, double y, double z) {
if ((world.getBlockState(new BlockPos(x + 2, y - 1, z + 2))).getBlock() == Blocks.SCULK || (world.getBlockState(new BlockPos(x + 2, y - 1, z + 2))).getBlock() == Blocks.DEEPSLATE
|| (world.getBlockState(new BlockPos(x + 2, y - 1, z + 2))).getBlock() == Blocks.STONE) {
return true;
} else {
return false;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 1, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 2, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 3, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 4, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 5, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 6, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 7, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 8, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
if ((world.getBlockState(new BlockPos(x + 2, y + 9, z + 2))).getBlock() == Blocks.CAVE_AIR) {
return true;
}
world.setBlock(new BlockPos(x + 2, y - 1, z + 2), Blocks.SCULK.defaultBlockState(), 3);
return true;
}
}