Started by
LeeLime5000
on
Topic category: Help with Minecraft modding (Java Edition)
Hello! I have been having some issues with return statments!
For this code, it gives me an error that the last return can't be reached.
public class GrapeVineBlockValidPlacementConditionProcedure {
public static boolean execute(LevelAccessor world, double x, double y, double z) {
if ((world.getBlockState(new BlockPos((int) (Math.floor(x)), (int) (Math.floor(y)), (int) (Math.floor(z))))).getBlock() == Blocks.AIR) {
return false;
} else {
return true;
}
return false;
}
}
public class GrapeVineBlockValidPlacementConditionProcedure {
public static boolean execute(LevelAccessor world, double x, double y, double z) {
if ((world.getBlockState(new BlockPos((int) (Math.floor(x)), (int) (Math.floor(y)), (int) (Math.floor(z))))).getBlock() == Blocks.AIR) {
return false;
} else {
return true;
}
}
}
But if I remove it, it will tell me that It needs to end in a valid return statement.
for me it works to remove the else block and putting an return there alone
because if you think about it if the return statement happened in the if-block then it wont get to the rest anyways.
It kind of treats the else like an else-if for some reason...