From c6eec525189b83fb5856bc827d99b2b0dd3be7f1 Mon Sep 17 00:00:00 2001 From: dags- Date: Thu, 12 Mar 2020 10:12:38 +0000 Subject: [PATCH] - moved wg block tags to the forge namespace - change strata decorator to only use blocks specified in the wg tags - tweaks to the min number of threads used --- .../{MaterialTags.java => WGTags.java} | 15 ++--- .../terraforged/core/region/RegionCache.java | 1 + .../core/region/RegionGenerator.java | 4 +- .../core/settings/GeneratorSettings.java | 14 ++-- .../core/util/concurrent/ThreadPool.java | 10 ++- .../com/terraforged/mod/TerraForgedMod.java | 4 +- .../terraforged/mod/data/WorldGenBlocks.java | 12 ++-- .../terraforged/mod/material/Materials.java | 66 ++++--------------- .../mod/material/geology/GeoGenerator.java | 9 +-- .../tags/blocks/wg_clay.json} | 0 .../tags/blocks/wg_dirt.json} | 0 .../tags/blocks/wg_erodible.json} | 0 .../tags/blocks/wg_sediment.json} | 0 .../tags/blocks/wg_stone.json} | 0 .../data/terraforged/tags/blocks/ore.json | 12 ---- gradle.properties | 2 +- 16 files changed, 49 insertions(+), 100 deletions(-) rename TerraForgedAPI/src/main/java/com/terraforged/api/material/{MaterialTags.java => WGTags.java} (75%) rename TerraForgedMod/src/main/resources/data/{terraforged/tags/blocks/clay.json => forge/tags/blocks/wg_clay.json} (100%) rename TerraForgedMod/src/main/resources/data/{terraforged/tags/blocks/earth.json => forge/tags/blocks/wg_dirt.json} (100%) rename TerraForgedMod/src/main/resources/data/{terraforged/tags/blocks/erodible.json => forge/tags/blocks/wg_erodible.json} (100%) rename TerraForgedMod/src/main/resources/data/{terraforged/tags/blocks/sediment.json => forge/tags/blocks/wg_sediment.json} (100%) rename TerraForgedMod/src/main/resources/data/{terraforged/tags/blocks/rock.json => forge/tags/blocks/wg_stone.json} (100%) delete mode 100644 TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/ore.json diff --git a/TerraForgedAPI/src/main/java/com/terraforged/api/material/MaterialTags.java b/TerraForgedAPI/src/main/java/com/terraforged/api/material/WGTags.java similarity index 75% rename from TerraForgedAPI/src/main/java/com/terraforged/api/material/MaterialTags.java rename to TerraForgedAPI/src/main/java/com/terraforged/api/material/WGTags.java index 1081916..e968e40 100644 --- a/TerraForgedAPI/src/main/java/com/terraforged/api/material/MaterialTags.java +++ b/TerraForgedAPI/src/main/java/com/terraforged/api/material/WGTags.java @@ -30,20 +30,19 @@ import net.minecraft.tags.BlockTags; import net.minecraft.tags.Tag; import net.minecraft.util.ResourceLocation; -public class MaterialTags { +public class WGTags { - public static final Tag WG_ROCK = tag("rock"); - public static final Tag WG_EARTH = tag("earth"); - public static final Tag WG_CLAY = tag("clay"); - public static final Tag WG_SEDIMENT = tag("sediment"); - public static final Tag WG_ORE = tag("ore"); - public static final Tag WG_ERODIBLE = tag("erodible"); + public static final Tag STONE = tag("wg_stone"); + public static final Tag DIRT = tag("wg_dirt"); + public static final Tag CLAY = tag("wg_clay"); + public static final Tag SEDIMENT = tag("wg_sediment"); + public static final Tag ERODIBLE = tag("wg_erodible"); public static void init() { } private static Tag tag(String name) { - return new BlockTags.Wrapper(new ResourceLocation("terraforged", name)); + return new BlockTags.Wrapper(new ResourceLocation("forge", name)); } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionCache.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionCache.java index 5320537..a3b541c 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionCache.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionCache.java @@ -43,6 +43,7 @@ public class RegionCache implements RegionExtent { public RegionCache(boolean queueNeighbours, RegionGenerator renderer) { this.renderer = renderer; this.queuing = queueNeighbours; + this.cache = Cache.concurrent(180, 60, TimeUnit.SECONDS); } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionGenerator.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionGenerator.java index efb736a..5e15732 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionGenerator.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionGenerator.java @@ -75,11 +75,11 @@ public class RegionGenerator implements RegionExtent { } public CompletableFuture generate(int regionX, int regionZ) { - return CompletableFuture.supplyAsync(() -> generateRegion(regionX, regionZ)); + return CompletableFuture.supplyAsync(() -> generateRegion(regionX, regionZ), threadPool); } public CompletableFuture generate(float centerX, float centerZ, float zoom, boolean filter) { - return CompletableFuture.supplyAsync(() -> generateRegion(centerX, centerZ, zoom, filter)); + return CompletableFuture.supplyAsync(() -> generateRegion(centerX, centerZ, zoom, filter), threadPool); } public Region generateRegion(int regionX, int regionZ) { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java index cbf07ca..e6068f7 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java @@ -72,7 +72,7 @@ public class GeneratorSettings { @Serializable public static class Land { - @Range(min = 500, max = 10000) + @Range(min = 100, max = 10000) @Comment("Controls the size of continents") public int continentScale = 4000; @@ -80,7 +80,7 @@ public class GeneratorSettings { @Comment("Controls the size of mountain ranges") public int mountainScale = 950; - @Range(min = 125, max = 2500) + @Range(min = 125, max = 5000) @Comment("Controls the size of terrain regions") public int regionSize = 1000; } @@ -88,15 +88,15 @@ public class GeneratorSettings { @Serializable public static class Biome { - @Range(min = 50, max = 500) + @Range(min = 50, max = 1000) @Comment("Controls the size of individual biomes") public int biomeSize = 200; - @Range(min = 1, max = 200) + @Range(min = 1, max = 500) @Comment("Controls the scale of shape distortion for biomes") public int biomeWarpScale = 35; - @Range(min = 1, max = 200) + @Range(min = 1, max = 500) @Comment("Controls the strength of shape distortion for biomes") public int biomeWarpStrength = 70; } @@ -107,7 +107,7 @@ public class GeneratorSettings { @Comment("The noise type") public Source type = Source.PERLIN; - @Range(min = 1, max = 100) + @Range(min = 1, max = 500) @Comment("Controls the scale of the noise") public int scale = 8; @@ -123,7 +123,7 @@ public class GeneratorSettings { @Comment("Controls the lacunarity of subsequent noise octaves") public float lacunarity = 2.5F; - @Range(min = 1, max = 100) + @Range(min = 1, max = 500) @Comment("Controls the strength of the noise") public int strength = 24; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java index d1b9615..a4079e9 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java @@ -30,12 +30,13 @@ import com.terraforged.core.util.concurrent.batcher.Batcher; import com.terraforged.core.util.concurrent.batcher.SyncBatcher; import java.util.concurrent.Callable; +import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.Future; -public class ThreadPool { +public class ThreadPool implements Executor { public static final int DEFAULT_POOL_SIZE = defaultPoolSize(); @@ -62,6 +63,11 @@ public class ThreadPool { } } + @Override + public void execute(Runnable command) { + service.execute(command); + } + public Future submit(Runnable runnable) { return service.submit(runnable); } @@ -116,6 +122,6 @@ public class ThreadPool { private static int defaultPoolSize() { int threads = Runtime.getRuntime().availableProcessors(); - return Math.max(1, (threads / 3) * 2); + return Math.max(2, (int) ((threads / 3F) * 2)); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/TerraForgedMod.java b/TerraForgedMod/src/main/java/com/terraforged/mod/TerraForgedMod.java index d774ed7..f27184f 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/TerraForgedMod.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/TerraForgedMod.java @@ -25,7 +25,7 @@ package com.terraforged.mod; -import com.terraforged.api.material.MaterialTags; +import com.terraforged.api.material.WGTags; import com.terraforged.core.util.concurrent.ThreadPool; import com.terraforged.feature.FeatureManager; import com.terraforged.mod.data.DataGen; @@ -53,7 +53,7 @@ public class TerraForgedMod { public static void setup(FMLCommonSetupEvent event) { Log.info("Common setup"); MinecraftForge.EVENT_BUS.addListener(TerraForgedMod::onShutdown); - MaterialTags.init(); + WGTags.init(); TerraWorld.init(); SaplingManager.init(); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBlocks.java b/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBlocks.java index e101bc4..91fe0f6 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBlocks.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/data/WorldGenBlocks.java @@ -27,7 +27,7 @@ package com.terraforged.mod.data; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import com.terraforged.mod.material.Materials; +import com.terraforged.api.material.WGTags; import net.minecraft.block.Block; import net.minecraft.util.ResourceLocation; @@ -38,12 +38,10 @@ public class WorldGenBlocks extends DataGen { public static void genBlockTags(File dataDir) { if (dataDir.exists() || dataDir.mkdirs()) { - Materials materials = new Materials(); - printMaterials(dataDir, "stone", materials.getStone()); - printMaterials(dataDir, "dirt", materials.getDirt()); - printMaterials(dataDir, "clay", materials.getClay()); - printMaterials(dataDir, "sediment",materials.getSediment()); - printMaterials(dataDir, "ore", materials.getOre()); + printMaterials(dataDir, "stone", WGTags.STONE.getAllElements()); + printMaterials(dataDir, "dirt", WGTags.DIRT.getAllElements()); + printMaterials(dataDir, "clay", WGTags.CLAY.getAllElements()); + printMaterials(dataDir, "sediment", WGTags.SEDIMENT.getAllElements()); } } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/material/Materials.java b/TerraForgedMod/src/main/java/com/terraforged/mod/material/Materials.java index aa42ad1..151450d 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/material/Materials.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/material/Materials.java @@ -25,28 +25,26 @@ package com.terraforged.mod.material; -import com.terraforged.api.material.MaterialTags; +import com.terraforged.api.material.WGTags; import com.terraforged.api.material.layer.LayerManager; -import com.terraforged.api.material.state.States; import net.minecraft.block.Block; import net.minecraft.block.Blocks; import net.minecraft.tags.Tag; import net.minecraftforge.registries.ForgeRegistries; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.Set; import java.util.function.Predicate; +@Deprecated public class Materials { - private final Set stone = create(MaterialTags.WG_ROCK); - private final Set dirt = create(MaterialTags.WG_EARTH); - private final Set clay = create(MaterialTags.WG_CLAY); - private final Set sediment = create(MaterialTags.WG_SEDIMENT); - private final Set ore = create(MaterialTags.WG_ORE); - private final Set erodible = create(MaterialTags.WG_ERODIBLE); + private final Set stone = create(WGTags.STONE); + private final Set dirt = create(WGTags.DIRT); + private final Set clay = create(WGTags.CLAY); + private final Set sediment = create(WGTags.SEDIMENT); + private final Set erodible = create(WGTags.ERODIBLE); private final LayerManager layerManager = new LayerManager(); public Materials() { @@ -68,8 +66,6 @@ public class Materials { clay.add(block); } else if (MaterialHelper.isSediment(block)) { sediment.add(block); - } else if (MaterialHelper.isOre(block)) { - ore.add(block); } } @@ -98,60 +94,20 @@ public class Materials { return sediment.contains(block); } - public boolean isOre(Block block) { - return ore.contains(block); - } - public boolean isErodible(Block block) { return erodible.contains(block); } - public Collection getStone() { - if (stone.isEmpty()) { - return Collections.singleton(States.STONE.getBlock()); - } - return Collections.unmodifiableSet(stone); - } - - public Collection getDirt() { - if (dirt.isEmpty()) { - return Collections.singleton(States.DIRT.getBlock()); - } - return Collections.unmodifiableSet(dirt); - } - - public Collection getClay() { - if (clay.isEmpty()) { - return Collections.singleton(States.STONE.getBlock()); - } - return Collections.unmodifiableSet(clay); - } - - public Collection getSediment() { - if (sediment.isEmpty()) { - return Collections.singleton(States.CLAY.getBlock()); - } - return Collections.unmodifiableSet(sediment); - } - - public Collection getOre() { - if (ore.isEmpty()) { - return Collections.singleton(States.STONE.getBlock()); - } - return Collections.unmodifiableSet(ore); - } - private static Set create(Tag tag) { return new HashSet<>(tag.getAllElements()); } private static Predicate getTagFilter() { Set namespaces = new HashSet<>(); - collectNamespace(namespaces, MaterialTags.WG_ROCK.getAllElements()); - collectNamespace(namespaces, MaterialTags.WG_EARTH.getAllElements()); - collectNamespace(namespaces, MaterialTags.WG_EARTH.getAllElements()); - collectNamespace(namespaces, MaterialTags.WG_SEDIMENT.getAllElements()); - collectNamespace(namespaces, MaterialTags.WG_ORE.getAllElements()); + collectNamespace(namespaces, WGTags.STONE.getAllElements()); + collectNamespace(namespaces, WGTags.DIRT.getAllElements()); + collectNamespace(namespaces, WGTags.DIRT.getAllElements()); + collectNamespace(namespaces, WGTags.SEDIMENT.getAllElements()); return b -> namespaces.contains(MaterialHelper.getNamespace(b)); } diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java b/TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java index 75a770a..a8760b9 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/material/geology/GeoGenerator.java @@ -25,6 +25,7 @@ package com.terraforged.mod.material.geology; +import com.terraforged.api.material.WGTags; import com.terraforged.api.material.geology.StrataConfig; import com.terraforged.api.material.geology.StrataGenerator; import com.terraforged.core.world.geology.Strata; @@ -49,10 +50,10 @@ public class GeoGenerator implements StrataGenerator { public GeoGenerator(Materials materials) { types.add(Source.PERLIN); - rock = new ArrayList<>(materials.getStone()); - soil = new ArrayList<>(materials.getDirt()); - clay = new ArrayList<>(materials.getClay()); - sediment = new ArrayList<>(materials.getSediment()); + rock = new ArrayList<>(WGTags.STONE.getAllElements()); + soil = new ArrayList<>(WGTags.DIRT.getAllElements()); + clay = new ArrayList<>(WGTags.CLAY.getAllElements()); + sediment = new ArrayList<>(WGTags.SEDIMENT.getAllElements()); } @Override diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/clay.json b/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_clay.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/clay.json rename to TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_clay.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/earth.json b/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_dirt.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/earth.json rename to TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_dirt.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/erodible.json b/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_erodible.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/erodible.json rename to TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_erodible.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/sediment.json b/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_sediment.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/sediment.json rename to TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_sediment.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/rock.json b/TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_stone.json similarity index 100% rename from TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/rock.json rename to TerraForgedMod/src/main/resources/data/forge/tags/blocks/wg_stone.json diff --git a/TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/ore.json b/TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/ore.json deleted file mode 100644 index 59fe3e2..0000000 --- a/TerraForgedMod/src/main/resources/data/terraforged/tags/blocks/ore.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:lapis_ore", - "minecraft:diamond_ore", - "minecraft:coal_ore", - "minecraft:emerald_ore", - "minecraft:gold_ore", - "minecraft:redstone_ore", - "minecraft:iron_ore" - ] -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 06db157..6392e61 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -mod_version=0.0.3 +mod_version=0.0.4 mc_version=1.15.2 forge_version=31.1.1 mcp_channel=snapshot