From f505828af1c4a527169bd0d948fa75d2f59bd481 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 29 Dec 2021 16:44:18 +0000 Subject: [PATCH] More enhanced switches --- .../core/function/generator/CavesGen.java | 15 ++++----------- .../fastasyncworldedit/core/queue/IBlocks.java | 16 +++++----------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/CavesGen.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/CavesGen.java index 3af6fcf78..28bfa0a4c 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/CavesGen.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/CavesGen.java @@ -277,17 +277,10 @@ public class CavesGen extends GenBase { } protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) { - switch (material.getBlockType().getId()) { - case "minecraft:air": - case "minecraft:cave_air": - case "minecraft:void_air": - case "minecraft:water": - case "minecraft:lava": - case "minecraft:bedrock": - return false; - default: - return true; - } + return switch (material.getBlockType().getId()) { + case "minecraft:air", "minecraft:cave_air", "minecraft:void_air", "minecraft:water", "minecraft:lava", "minecraft:bedrock" -> false; + default -> true; + }; } @Override diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBlocks.java index 7080511e6..ff6842c0a 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/IBlocks.java @@ -116,9 +116,7 @@ public interface IBlocks extends Trimable { for (int i = 0; i < ids.length; i++) { char ordinal = ids[i]; switch (ordinal) { - case BlockTypesCache.ReservedIDs.__RESERVED__: - case BlockTypesCache.ReservedIDs.CAVE_AIR: - case BlockTypesCache.ReservedIDs.VOID_AIR: + case BlockTypesCache.ReservedIDs.__RESERVED__, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR: ids[i] = BlockTypesCache.ReservedIDs.AIR; case BlockTypesCache.ReservedIDs.AIR: continue; @@ -140,17 +138,13 @@ public interface IBlocks extends Trimable { for (int i = 0; i < palette.paletteToBlockLength; i++) { int ordinal = palette.paletteToBlock[i]; switch (ordinal) { - case BlockTypesCache.ReservedIDs.__RESERVED__: - case BlockTypesCache.ReservedIDs.AIR: - case BlockTypesCache.ReservedIDs.CAVE_AIR: - case BlockTypesCache.ReservedIDs.VOID_AIR: - sectionWriter.write(0); - break; - default: + case BlockTypesCache.ReservedIDs.__RESERVED__, BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, + BlockTypesCache.ReservedIDs.VOID_AIR -> sectionWriter.write(0); + default -> { BlockState state = BlockState.getFromOrdinal(ordinal); int mcId = registry.getInternalBlockStateId(state).getAsInt(); sectionWriter.writeVarInt(mcId); - break; + } } } sectionWriter.writeVarInt(palette.blockStatesLength);