diff --git a/platforms/allay/src/main/java/com/dfsek/terra/allay/AllayPlatform.java b/platforms/allay/src/main/java/com/dfsek/terra/allay/AllayPlatform.java index e0b966e9f..ef48be9ad 100644 --- a/platforms/allay/src/main/java/com/dfsek/terra/allay/AllayPlatform.java +++ b/platforms/allay/src/main/java/com/dfsek/terra/allay/AllayPlatform.java @@ -25,6 +25,7 @@ * @author daoge_cmd */ public class AllayPlatform extends AbstractPlatform { + public static final Set GENERATOR_WRAPPERS = new HashSet<>(); protected static final AllayWorldHandle ALLAY_WORLD_HANDLE = new AllayWorldHandle(); @@ -81,14 +82,12 @@ public void runPossiblyUnsafeTask(@NotNull Runnable task) { @Override public void register(TypeRegistry registry) { super.register(registry); - registry.registerLoader(BlockState.class, ($, o, $$, $$$) -> ALLAY_WORLD_HANDLE.createBlockState((String) o)) - .registerLoader(PlatformBiome.class, ($, o, $$, depthTracker) -> parseBiome((String) o, depthTracker)); + registry.registerLoader(BlockState.class, (type, o, loader, depthTracker) -> ALLAY_WORLD_HANDLE.createBlockState((String) o)) + .registerLoader(PlatformBiome.class, (type, o, loader, depthTracker) -> parseBiome((String) o, depthTracker)); } protected AllayBiome parseBiome(String id, DepthTracker depthTracker) throws LoadException { - if(!id.startsWith("minecraft:")) { - throw new LoadException("Invalid biome identifier " + id, depthTracker); - } + if(!id.startsWith("minecraft:")) throw new LoadException("Invalid biome identifier " + id, depthTracker); return new AllayBiome(BiomeId.fromId(Mapping.biomeIdJeToBe(id))); } } diff --git a/platforms/allay/src/main/java/com/dfsek/terra/allay/JeBlockState.java b/platforms/allay/src/main/java/com/dfsek/terra/allay/JeBlockState.java index a0fe73c9b..60583f22c 100644 --- a/platforms/allay/src/main/java/com/dfsek/terra/allay/JeBlockState.java +++ b/platforms/allay/src/main/java/com/dfsek/terra/allay/JeBlockState.java @@ -45,11 +45,8 @@ private void completeMissingProperties() { if(properties.size() == defaultProperties.size()) { return; } - defaultProperties - .entrySet() - .stream() - .filter(entry -> !properties.containsKey(entry.getKey())) - .forEach(entry -> properties.put(entry.getKey(), entry.getValue())); + defaultProperties.entrySet().stream().filter(entry -> !properties.containsKey(entry.getKey())).forEach( + entry -> properties.put(entry.getKey(), entry.getValue())); } private JeBlockState(String identifier, TreeMap properties) { diff --git a/platforms/allay/src/main/java/com/dfsek/terra/allay/Mapping.java b/platforms/allay/src/main/java/com/dfsek/terra/allay/Mapping.java index 5f2996ae5..2ef9f7a0e 100644 --- a/platforms/allay/src/main/java/com/dfsek/terra/allay/Mapping.java +++ b/platforms/allay/src/main/java/com/dfsek/terra/allay/Mapping.java @@ -25,6 +25,7 @@ * @author daoge_cmd */ public final class Mapping { + private static final Map> JE_BLOCK_DEFAULT_PROPERTIES = new Object2ObjectOpenHashMap<>(); private static final Map BLOCK_STATE_BE_TO_JE = new Object2ObjectOpenHashMap<>(); private static final Map BLOCK_STATE_JE_HASH_TO_BE = new Int2ObjectOpenHashMap<>(); @@ -89,10 +90,7 @@ private static boolean initBiomeMapping() { TerraAllayPlugin.INSTANCE.getPluginLogger().error("biomes mapping not found"); return false; } - Set>> mappings = JSONUtils.from( - stream, - new TypeToken>>() {} - ).entrySet(); + Set>> mappings = JSONUtils.from(stream, new TypeToken>>(){}).entrySet(); mappings.forEach(mapping -> BIOME_ID_JE_TO_BE.put(mapping.getKey(), mapping.getValue().get("bedrock_id"))); } catch(IOException e) { TerraAllayPlugin.INSTANCE.getPluginLogger().error("Failed to load biomes mapping", e); @@ -107,10 +105,7 @@ private static boolean initItemMapping() { TerraAllayPlugin.INSTANCE.getPluginLogger().error("items mapping not found"); return false; } - Set>> mappings = JSONUtils.from( - stream, - new TypeToken>>() {} - ).entrySet(); + Set>> mappings = JSONUtils.from(stream, new TypeToken>>() {}).entrySet(); mappings.forEach(mapping -> { ItemType item = ItemTypeSafeGetter .name((String) mapping.getValue().get("bedrock_identifier")) @@ -132,10 +127,7 @@ private static boolean initBlockStateMapping() { return false; } // noinspection unchecked - List>> mappings = (List>>) JSONUtils.from( - stream, - new TypeToken>() {} - ).get("mappings"); + List>> mappings = (List>>) JSONUtils.from(stream, new TypeToken>() {}).get("mappings"); mappings.forEach(mapping -> { JeBlockState jeState = createJeBlockState(mapping.get("java_state")); BlockState beState = createBeBlockState(mapping.get("bedrock_state")); @@ -167,7 +159,8 @@ private static boolean initJeBlockDefaultProperties() { } private static BlockState createBeBlockState(Map data) { - Getter getter = BlockStateSafeGetter.name("minecraft:" + data.get("bedrock_identifier")); + Getter getter = BlockStateSafeGetter + .name("minecraft:" + data.get("bedrock_identifier")); if(data.containsKey("state")) { // noinspection unchecked convertValueType((Map) data.get("state")).forEach(getter::property); @@ -190,7 +183,6 @@ private static Map convertValueType(Map data) { private static JeBlockState createJeBlockState(Map data) { // noinspection unchecked - return JeBlockState.create((String) data.get("Name"), - new TreeMap<>((Map) data.getOrDefault("Properties", Map.of()))); + return JeBlockState.create((String) data.get("Name"), new TreeMap<>((Map) data.getOrDefault("Properties", Map.of()))); } } diff --git a/platforms/allay/src/main/java/com/dfsek/terra/allay/TerraAllayPlugin.java b/platforms/allay/src/main/java/com/dfsek/terra/allay/TerraAllayPlugin.java index ba4dbfe4b..d6f5f1d14 100644 --- a/platforms/allay/src/main/java/com/dfsek/terra/allay/TerraAllayPlugin.java +++ b/platforms/allay/src/main/java/com/dfsek/terra/allay/TerraAllayPlugin.java @@ -70,8 +70,6 @@ public void reload() { @EventHandler private void onWorldUnload(WorldUnloadEvent event) { - AllayPlatform.GENERATOR_WRAPPERS.removeIf( - wrapper -> wrapper.getAllayWorldGenerator().getDimension().getWorld() == event.getWorld() - ); + AllayPlatform.GENERATOR_WRAPPERS.removeIf(wrapper -> wrapper.getAllayWorldGenerator().getDimension().getWorld() == event.getWorld()); } } diff --git a/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayChunk.java b/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayChunk.java index 7c515acd4..c67ed2d88 100644 --- a/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayChunk.java +++ b/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayChunk.java @@ -21,8 +21,7 @@ public record AllayChunk(ServerWorld world, Chunk allayChunk) implements com.dfs public void setBlock(int x, int y, int z, BlockState data, boolean physics) { AllayBlockState allayBlockState = (AllayBlockState) data; allayChunk.setBlockState(x, y, z, allayBlockState.allayBlockState()); - boolean containsWater = allayBlockState.containsWater() || allayChunk.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER); - if (containsWater) { + if (allayBlockState.containsWater() || allayChunk.getBlockState(x, y, z).getBlockType().hasBlockTag(BlockTags.WATER)) { allayChunk.setBlockState(x, y, z, WATER, 1); } } diff --git a/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayProtoChunk.java b/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayProtoChunk.java index 84c03b803..5b67727fb 100644 --- a/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayProtoChunk.java +++ b/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayProtoChunk.java @@ -14,6 +14,7 @@ * @author daoge_cmd */ public record AllayProtoChunk(UnsafeChunk allayChunk) implements ProtoChunk { + private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0)); @Override diff --git a/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayProtoWorld.java b/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayProtoWorld.java index ca0f622ba..0fb8173eb 100644 --- a/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayProtoWorld.java +++ b/platforms/allay/src/main/java/com/dfsek/terra/allay/delegate/AllayProtoWorld.java @@ -21,6 +21,7 @@ * @author daoge_cmd */ public record AllayProtoWorld(AllayServerWorld allayServerWorld, OtherChunkAccessibleContext context) implements ProtoWorld { + private static final org.allaymc.api.block.type.BlockState WATER = BlockTypes.WATER.ofState(BlockPropertyTypes.LIQUID_DEPTH.createValue(0)); @Override