From 011a0bf4baeda9871efc086edeaff80e825b4bfc Mon Sep 17 00:00:00 2001 From: dags- Date: Tue, 2 Jun 2020 14:33:31 +0100 Subject: [PATCH] unbreak the things --- Engine | 2 +- .../terraforged/biome/provider/BiomeProvider.java | 7 +++++-- .../chunk/generator/TerrainGenerator.java | 1 - .../java/com/terraforged/command/TerraCommand.java | 14 ++++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Engine b/Engine index 7f617d3..5c77c56 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit 7f617d303c09d52d4242379ef87bc4b679d8fcea +Subproject commit 5c77c566a5e5fd035d3421c1a3b58d7d3fc7bb9d diff --git a/src/main/java/com/terraforged/biome/provider/BiomeProvider.java b/src/main/java/com/terraforged/biome/provider/BiomeProvider.java index f77a8fc..059057b 100644 --- a/src/main/java/com/terraforged/biome/provider/BiomeProvider.java +++ b/src/main/java/com/terraforged/biome/provider/BiomeProvider.java @@ -33,6 +33,7 @@ import com.terraforged.chunk.TerraContext; import com.terraforged.chunk.util.FastChunk; import com.terraforged.chunk.util.TerraContainer; import com.terraforged.core.cell.Cell; +import com.terraforged.core.concurrent.Resource; import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.util.setup.SetupHooks; import com.terraforged.world.heightmap.WorldLookup; @@ -66,7 +67,7 @@ public class BiomeProvider extends AbstractBiomeProvider { this.modifierManager = SetupHooks.setup(new BiomeModifierManager(context, biomeMap), context.copy()); } - public Cell lookupPos(int x, int z) { + public Resource lookupPos(int x, int z) { return getWorldLookup().getCell(x, z); } @@ -74,7 +75,9 @@ public class BiomeProvider extends AbstractBiomeProvider { public Biome getNoiseBiome(int x, int y, int z) { x = (x << 2); z = (z << 2); - return getBiome(lookupPos(x, z), x, z); + try (Resource cell = lookupPos(x, z)) { + return getBiome(cell.get(), x, z); + } } @Override diff --git a/src/main/java/com/terraforged/chunk/generator/TerrainGenerator.java b/src/main/java/com/terraforged/chunk/generator/TerrainGenerator.java index 2afe367..db25857 100644 --- a/src/main/java/com/terraforged/chunk/generator/TerrainGenerator.java +++ b/src/main/java/com/terraforged/chunk/generator/TerrainGenerator.java @@ -75,7 +75,6 @@ public class TerrainGenerator { // bake biome array & discard gen data ((ChunkPrimer) chunk).func_225548_a_(container.bakeBiomes(Environment.isVanillaBiomes())); - // marks the heightmap data for this chunk for removal container.getChunkReader().dispose(); } diff --git a/src/main/java/com/terraforged/command/TerraCommand.java b/src/main/java/com/terraforged/command/TerraCommand.java index 7ace97a..de8677e 100644 --- a/src/main/java/com/terraforged/command/TerraCommand.java +++ b/src/main/java/com/terraforged/command/TerraCommand.java @@ -42,6 +42,7 @@ import com.terraforged.command.search.BothSearchTask; import com.terraforged.command.search.Search; import com.terraforged.command.search.TerrainSearchTask; import com.terraforged.core.cell.Cell; +import com.terraforged.core.concurrent.Resource; import com.terraforged.data.DataGen; import com.terraforged.settings.SettingsHelper; import com.terraforged.world.WorldGenerator; @@ -126,12 +127,13 @@ public class TerraCommand { BlockPos pos = context.getSource().asPlayer().getPosition(); BiomeProvider biomeProvider = getBiomeProvider(context); - Cell cell = biomeProvider.lookupPos(pos.getX(), pos.getZ()); - Biome biome = biomeProvider.getBiome(cell, pos.getX(), pos.getZ()); - context.getSource().sendFeedback( - new StringTextComponent("Terrain=" + cell.terrain.getName() + ", Biome=" + biome.getRegistryName()), - false - ); + try (Resource cell = biomeProvider.lookupPos(pos.getX(), pos.getZ())) { + Biome biome = biomeProvider.getBiome(cell.get(), pos.getX(), pos.getZ()); + context.getSource().sendFeedback( + new StringTextComponent("Terrain=" + cell.get().terrain.getName() + ", Biome=" + biome.getRegistryName()), + false + ); + } return Command.SINGLE_SUCCESS; }