- 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
This commit is contained in:
dags- 2020-03-12 10:12:38 +00:00
parent 6d37357fc2
commit c6eec52518
16 changed files with 49 additions and 100 deletions

View File

@ -30,20 +30,19 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag; import net.minecraft.tags.Tag;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public class MaterialTags { public class WGTags {
public static final Tag<Block> WG_ROCK = tag("rock"); public static final Tag<Block> STONE = tag("wg_stone");
public static final Tag<Block> WG_EARTH = tag("earth"); public static final Tag<Block> DIRT = tag("wg_dirt");
public static final Tag<Block> WG_CLAY = tag("clay"); public static final Tag<Block> CLAY = tag("wg_clay");
public static final Tag<Block> WG_SEDIMENT = tag("sediment"); public static final Tag<Block> SEDIMENT = tag("wg_sediment");
public static final Tag<Block> WG_ORE = tag("ore"); public static final Tag<Block> ERODIBLE = tag("wg_erodible");
public static final Tag<Block> WG_ERODIBLE = tag("erodible");
public static void init() { public static void init() {
} }
private static Tag<Block> tag(String name) { private static Tag<Block> tag(String name) {
return new BlockTags.Wrapper(new ResourceLocation("terraforged", name)); return new BlockTags.Wrapper(new ResourceLocation("forge", name));
} }
} }

View File

@ -43,6 +43,7 @@ public class RegionCache implements RegionExtent {
public RegionCache(boolean queueNeighbours, RegionGenerator renderer) { public RegionCache(boolean queueNeighbours, RegionGenerator renderer) {
this.renderer = renderer; this.renderer = renderer;
this.queuing = queueNeighbours; this.queuing = queueNeighbours;
this.cache = Cache.concurrent(180, 60, TimeUnit.SECONDS); this.cache = Cache.concurrent(180, 60, TimeUnit.SECONDS);
} }

View File

@ -75,11 +75,11 @@ public class RegionGenerator implements RegionExtent {
} }
public CompletableFuture<Region> generate(int regionX, int regionZ) { public CompletableFuture<Region> generate(int regionX, int regionZ) {
return CompletableFuture.supplyAsync(() -> generateRegion(regionX, regionZ)); return CompletableFuture.supplyAsync(() -> generateRegion(regionX, regionZ), threadPool);
} }
public CompletableFuture<Region> generate(float centerX, float centerZ, float zoom, boolean filter) { public CompletableFuture<Region> 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) { public Region generateRegion(int regionX, int regionZ) {

View File

@ -72,7 +72,7 @@ public class GeneratorSettings {
@Serializable @Serializable
public static class Land { public static class Land {
@Range(min = 500, max = 10000) @Range(min = 100, max = 10000)
@Comment("Controls the size of continents") @Comment("Controls the size of continents")
public int continentScale = 4000; public int continentScale = 4000;
@ -80,7 +80,7 @@ public class GeneratorSettings {
@Comment("Controls the size of mountain ranges") @Comment("Controls the size of mountain ranges")
public int mountainScale = 950; public int mountainScale = 950;
@Range(min = 125, max = 2500) @Range(min = 125, max = 5000)
@Comment("Controls the size of terrain regions") @Comment("Controls the size of terrain regions")
public int regionSize = 1000; public int regionSize = 1000;
} }
@ -88,15 +88,15 @@ public class GeneratorSettings {
@Serializable @Serializable
public static class Biome { public static class Biome {
@Range(min = 50, max = 500) @Range(min = 50, max = 1000)
@Comment("Controls the size of individual biomes") @Comment("Controls the size of individual biomes")
public int biomeSize = 200; public int biomeSize = 200;
@Range(min = 1, max = 200) @Range(min = 1, max = 500)
@Comment("Controls the scale of shape distortion for biomes") @Comment("Controls the scale of shape distortion for biomes")
public int biomeWarpScale = 35; public int biomeWarpScale = 35;
@Range(min = 1, max = 200) @Range(min = 1, max = 500)
@Comment("Controls the strength of shape distortion for biomes") @Comment("Controls the strength of shape distortion for biomes")
public int biomeWarpStrength = 70; public int biomeWarpStrength = 70;
} }
@ -107,7 +107,7 @@ public class GeneratorSettings {
@Comment("The noise type") @Comment("The noise type")
public Source type = Source.PERLIN; public Source type = Source.PERLIN;
@Range(min = 1, max = 100) @Range(min = 1, max = 500)
@Comment("Controls the scale of the noise") @Comment("Controls the scale of the noise")
public int scale = 8; public int scale = 8;
@ -123,7 +123,7 @@ public class GeneratorSettings {
@Comment("Controls the lacunarity of subsequent noise octaves") @Comment("Controls the lacunarity of subsequent noise octaves")
public float lacunarity = 2.5F; public float lacunarity = 2.5F;
@Range(min = 1, max = 100) @Range(min = 1, max = 500)
@Comment("Controls the strength of the noise") @Comment("Controls the strength of the noise")
public int strength = 24; public int strength = 24;

View File

@ -30,12 +30,13 @@ import com.terraforged.core.util.concurrent.batcher.Batcher;
import com.terraforged.core.util.concurrent.batcher.SyncBatcher; import com.terraforged.core.util.concurrent.batcher.SyncBatcher;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future; import java.util.concurrent.Future;
public class ThreadPool { public class ThreadPool implements Executor {
public static final int DEFAULT_POOL_SIZE = defaultPoolSize(); 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 <T> Future<?> submit(Runnable runnable) { public <T> Future<?> submit(Runnable runnable) {
return service.submit(runnable); return service.submit(runnable);
} }
@ -116,6 +122,6 @@ public class ThreadPool {
private static int defaultPoolSize() { private static int defaultPoolSize() {
int threads = Runtime.getRuntime().availableProcessors(); int threads = Runtime.getRuntime().availableProcessors();
return Math.max(1, (threads / 3) * 2); return Math.max(2, (int) ((threads / 3F) * 2));
} }
} }

View File

@ -25,7 +25,7 @@
package com.terraforged.mod; 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.core.util.concurrent.ThreadPool;
import com.terraforged.feature.FeatureManager; import com.terraforged.feature.FeatureManager;
import com.terraforged.mod.data.DataGen; import com.terraforged.mod.data.DataGen;
@ -53,7 +53,7 @@ public class TerraForgedMod {
public static void setup(FMLCommonSetupEvent event) { public static void setup(FMLCommonSetupEvent event) {
Log.info("Common setup"); Log.info("Common setup");
MinecraftForge.EVENT_BUS.addListener(TerraForgedMod::onShutdown); MinecraftForge.EVENT_BUS.addListener(TerraForgedMod::onShutdown);
MaterialTags.init(); WGTags.init();
TerraWorld.init(); TerraWorld.init();
SaplingManager.init(); SaplingManager.init();
} }

View File

@ -27,7 +27,7 @@ package com.terraforged.mod.data;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; 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.block.Block;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -38,12 +38,10 @@ public class WorldGenBlocks extends DataGen {
public static void genBlockTags(File dataDir) { public static void genBlockTags(File dataDir) {
if (dataDir.exists() || dataDir.mkdirs()) { if (dataDir.exists() || dataDir.mkdirs()) {
Materials materials = new Materials(); printMaterials(dataDir, "stone", WGTags.STONE.getAllElements());
printMaterials(dataDir, "stone", materials.getStone()); printMaterials(dataDir, "dirt", WGTags.DIRT.getAllElements());
printMaterials(dataDir, "dirt", materials.getDirt()); printMaterials(dataDir, "clay", WGTags.CLAY.getAllElements());
printMaterials(dataDir, "clay", materials.getClay()); printMaterials(dataDir, "sediment", WGTags.SEDIMENT.getAllElements());
printMaterials(dataDir, "sediment",materials.getSediment());
printMaterials(dataDir, "ore", materials.getOre());
} }
} }

View File

@ -25,28 +25,26 @@
package com.terraforged.mod.material; 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.layer.LayerManager;
import com.terraforged.api.material.state.States;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.tags.Tag; import net.minecraft.tags.Tag;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate; import java.util.function.Predicate;
@Deprecated
public class Materials { public class Materials {
private final Set<Block> stone = create(MaterialTags.WG_ROCK); private final Set<Block> stone = create(WGTags.STONE);
private final Set<Block> dirt = create(MaterialTags.WG_EARTH); private final Set<Block> dirt = create(WGTags.DIRT);
private final Set<Block> clay = create(MaterialTags.WG_CLAY); private final Set<Block> clay = create(WGTags.CLAY);
private final Set<Block> sediment = create(MaterialTags.WG_SEDIMENT); private final Set<Block> sediment = create(WGTags.SEDIMENT);
private final Set<Block> ore = create(MaterialTags.WG_ORE); private final Set<Block> erodible = create(WGTags.ERODIBLE);
private final Set<Block> erodible = create(MaterialTags.WG_ERODIBLE);
private final LayerManager layerManager = new LayerManager(); private final LayerManager layerManager = new LayerManager();
public Materials() { public Materials() {
@ -68,8 +66,6 @@ public class Materials {
clay.add(block); clay.add(block);
} else if (MaterialHelper.isSediment(block)) { } else if (MaterialHelper.isSediment(block)) {
sediment.add(block); sediment.add(block);
} else if (MaterialHelper.isOre(block)) {
ore.add(block);
} }
} }
@ -98,60 +94,20 @@ public class Materials {
return sediment.contains(block); return sediment.contains(block);
} }
public boolean isOre(Block block) {
return ore.contains(block);
}
public boolean isErodible(Block block) { public boolean isErodible(Block block) {
return erodible.contains(block); return erodible.contains(block);
} }
public Collection<Block> getStone() {
if (stone.isEmpty()) {
return Collections.singleton(States.STONE.getBlock());
}
return Collections.unmodifiableSet(stone);
}
public Collection<Block> getDirt() {
if (dirt.isEmpty()) {
return Collections.singleton(States.DIRT.getBlock());
}
return Collections.unmodifiableSet(dirt);
}
public Collection<Block> getClay() {
if (clay.isEmpty()) {
return Collections.singleton(States.STONE.getBlock());
}
return Collections.unmodifiableSet(clay);
}
public Collection<Block> getSediment() {
if (sediment.isEmpty()) {
return Collections.singleton(States.CLAY.getBlock());
}
return Collections.unmodifiableSet(sediment);
}
public Collection<Block> getOre() {
if (ore.isEmpty()) {
return Collections.singleton(States.STONE.getBlock());
}
return Collections.unmodifiableSet(ore);
}
private static Set<Block> create(Tag<Block> tag) { private static Set<Block> create(Tag<Block> tag) {
return new HashSet<>(tag.getAllElements()); return new HashSet<>(tag.getAllElements());
} }
private static Predicate<Block> getTagFilter() { private static Predicate<Block> getTagFilter() {
Set<String> namespaces = new HashSet<>(); Set<String> namespaces = new HashSet<>();
collectNamespace(namespaces, MaterialTags.WG_ROCK.getAllElements()); collectNamespace(namespaces, WGTags.STONE.getAllElements());
collectNamespace(namespaces, MaterialTags.WG_EARTH.getAllElements()); collectNamespace(namespaces, WGTags.DIRT.getAllElements());
collectNamespace(namespaces, MaterialTags.WG_EARTH.getAllElements()); collectNamespace(namespaces, WGTags.DIRT.getAllElements());
collectNamespace(namespaces, MaterialTags.WG_SEDIMENT.getAllElements()); collectNamespace(namespaces, WGTags.SEDIMENT.getAllElements());
collectNamespace(namespaces, MaterialTags.WG_ORE.getAllElements());
return b -> namespaces.contains(MaterialHelper.getNamespace(b)); return b -> namespaces.contains(MaterialHelper.getNamespace(b));
} }

View File

@ -25,6 +25,7 @@
package com.terraforged.mod.material.geology; 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.StrataConfig;
import com.terraforged.api.material.geology.StrataGenerator; import com.terraforged.api.material.geology.StrataGenerator;
import com.terraforged.core.world.geology.Strata; import com.terraforged.core.world.geology.Strata;
@ -49,10 +50,10 @@ public class GeoGenerator implements StrataGenerator {
public GeoGenerator(Materials materials) { public GeoGenerator(Materials materials) {
types.add(Source.PERLIN); types.add(Source.PERLIN);
rock = new ArrayList<>(materials.getStone()); rock = new ArrayList<>(WGTags.STONE.getAllElements());
soil = new ArrayList<>(materials.getDirt()); soil = new ArrayList<>(WGTags.DIRT.getAllElements());
clay = new ArrayList<>(materials.getClay()); clay = new ArrayList<>(WGTags.CLAY.getAllElements());
sediment = new ArrayList<>(materials.getSediment()); sediment = new ArrayList<>(WGTags.SEDIMENT.getAllElements());
} }
@Override @Override

View File

@ -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"
]
}

View File

@ -1,4 +1,4 @@
mod_version=0.0.3 mod_version=0.0.4
mc_version=1.15.2 mc_version=1.15.2
forge_version=31.1.1 forge_version=31.1.1
mcp_channel=snapshot mcp_channel=snapshot