More enhanced switches

This commit is contained in:
dordsor21 2021-12-29 16:44:18 +00:00
parent 8d565b93f7
commit f505828af1
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 9 additions and 22 deletions

View File

@ -277,17 +277,10 @@ public class CavesGen extends GenBase {
} }
protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) { protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) {
switch (material.getBlockType().getId()) { return switch (material.getBlockType().getId()) {
case "minecraft:air": case "minecraft:air", "minecraft:cave_air", "minecraft:void_air", "minecraft:water", "minecraft:lava", "minecraft:bedrock" -> false;
case "minecraft:cave_air": default -> true;
case "minecraft:void_air": };
case "minecraft:water":
case "minecraft:lava":
case "minecraft:bedrock":
return false;
default:
return true;
}
} }
@Override @Override

View File

@ -116,9 +116,7 @@ public interface IBlocks extends Trimable {
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < ids.length; i++) {
char ordinal = ids[i]; char ordinal = ids[i];
switch (ordinal) { switch (ordinal) {
case BlockTypesCache.ReservedIDs.__RESERVED__: case BlockTypesCache.ReservedIDs.__RESERVED__, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR:
case BlockTypesCache.ReservedIDs.CAVE_AIR:
case BlockTypesCache.ReservedIDs.VOID_AIR:
ids[i] = BlockTypesCache.ReservedIDs.AIR; ids[i] = BlockTypesCache.ReservedIDs.AIR;
case BlockTypesCache.ReservedIDs.AIR: case BlockTypesCache.ReservedIDs.AIR:
continue; continue;
@ -140,17 +138,13 @@ public interface IBlocks extends Trimable {
for (int i = 0; i < palette.paletteToBlockLength; i++) { for (int i = 0; i < palette.paletteToBlockLength; i++) {
int ordinal = palette.paletteToBlock[i]; int ordinal = palette.paletteToBlock[i];
switch (ordinal) { switch (ordinal) {
case BlockTypesCache.ReservedIDs.__RESERVED__: case BlockTypesCache.ReservedIDs.__RESERVED__, BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR,
case BlockTypesCache.ReservedIDs.AIR: BlockTypesCache.ReservedIDs.VOID_AIR -> sectionWriter.write(0);
case BlockTypesCache.ReservedIDs.CAVE_AIR: default -> {
case BlockTypesCache.ReservedIDs.VOID_AIR:
sectionWriter.write(0);
break;
default:
BlockState state = BlockState.getFromOrdinal(ordinal); BlockState state = BlockState.getFromOrdinal(ordinal);
int mcId = registry.getInternalBlockStateId(state).getAsInt(); int mcId = registry.getInternalBlockStateId(state).getAsInt();
sectionWriter.writeVarInt(mcId); sectionWriter.writeVarInt(mcId);
break; }
} }
} }
sectionWriter.writeVarInt(palette.blockStatesLength); sectionWriter.writeVarInt(palette.blockStatesLength);