- added wg_stone predicate for ores

- generate the settings json on dedicated servers if one doesn't exist
This commit is contained in:
dags- 2020-05-10 10:30:03 +01:00
parent 6f0f8efeba
commit 9786d819b0
11 changed files with 50 additions and 14 deletions

View File

@ -25,11 +25,15 @@
package com.terraforged.api.material;
import com.terraforged.api.material.state.StateTagPredicate;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.ResourceLocation;
import java.util.function.Predicate;
public class WGTags {
public static final Tag<Block> STONE = tag("wg_stone");
@ -45,4 +49,8 @@ public class WGTags {
private static Tag<Block> tag(String name) {
return new BlockTags.Wrapper(new ResourceLocation("forge", name));
}
public static Predicate<BlockState> stone() {
return new StateTagPredicate(STONE);
}
}

View File

@ -0,0 +1,21 @@
package com.terraforged.api.material.state;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.tags.Tag;
import java.util.function.Predicate;
public class StateTagPredicate implements Predicate<BlockState> {
private final Tag<Block> tag;
public StateTagPredicate(Tag<Block> tag) {
this.tag = tag;
}
@Override
public boolean test(BlockState state) {
return tag.contains(state.getBlock());
}
}

View File

@ -37,6 +37,7 @@ import com.terraforged.mod.util.DataPackFinder;
import com.terraforged.mod.util.Environment;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.event.RegistryEvent;
@ -62,11 +63,14 @@ public class TerraForgedMod {
TerraWorld.init();
SaplingManager.init();
TerraCommand.init();
SettingsHelper.moveSettings();
SettingsHelper.initSettings();
// temp fix
BiomeDictionary.addTypes(Biomes.BAMBOO_JUNGLE, BiomeDictionary.Type.OVERWORLD);
BiomeDictionary.addTypes(Biomes.BAMBOO_JUNGLE_HILLS, BiomeDictionary.Type.OVERWORLD);
// allows ores to replace any world-gen stone type
OreFeatureConfig.FillerBlockType.create("WG_STONE", "wg_stone", WGTags.stone());
}
@SubscribeEvent

View File

@ -8,8 +8,9 @@ import com.terraforged.mod.Log;
import com.terraforged.mod.TerraWorld;
import com.terraforged.mod.util.nbt.NBTHelper;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.World;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@ -72,10 +73,6 @@ public class SettingsHelper {
NBTHelper.deserialize(options, dest);
}
public static TerraSettings getSettings(World world) {
return getSettings(world.getWorldInfo());
}
public static TerraSettings getSettings(WorldInfo info) {
TerraSettings settings = new TerraSettings();
if (info.getGeneratorOptions().isEmpty()) {
@ -103,7 +100,7 @@ public class SettingsHelper {
info.setGeneratorOptions(options);
}
public static void moveSettings() {
public static void initSettings() {
if (SETTINGS_FILE.exists()) {
return;
}
@ -120,6 +117,12 @@ public class SettingsHelper {
e.printStackTrace();
}
}
} else {
DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () -> exportDefaults(new TerraSettings()));
}
}
private static void initServerSettings() {
DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, () -> () -> exportDefaults(new TerraSettings()));
}
}

View File

@ -12,7 +12,7 @@
"name": "minecraft:ore",
"config": {
"size": 16,
"target": "natural_stone",
"target": "wg_stone",
"state": {
"Name": "minecraft:coal_ore"
}

View File

@ -12,7 +12,7 @@
"name": "minecraft:ore",
"config": {
"size": 8,
"target": "natural_stone",
"target": "wg_stone",
"state": {
"Name": "minecraft:diamond_ore"
}

View File

@ -12,7 +12,7 @@
"name": "minecraft:ore",
"config": {
"size": 9,
"target": "natural_stone",
"target": "wg_stone",
"state": {
"Name": "minecraft:gold_ore"
}

View File

@ -19,7 +19,7 @@
"name": "minecraft:ore",
"config": {
"size": 9,
"target": "natural_stone",
"target": "wg_stone",
"state": {
"Name": "minecraft:gold_ore"
}

View File

@ -12,7 +12,7 @@
"name": "minecraft:ore",
"config": {
"size": 9,
"target": "natural_stone",
"target": "wg_stone",
"state": {
"Name": "minecraft:iron_ore"
}

View File

@ -12,7 +12,7 @@
"name": "minecraft:ore",
"config": {
"size": 7,
"target": "natural_stone",
"target": "wg_stone",
"state": {
"Name": "minecraft:lapis_ore"
}

View File

@ -12,7 +12,7 @@
"name": "minecraft:ore",
"config": {
"size": 8,
"target": "natural_stone",
"target": "wg_stone",
"state": {
"Name": "minecraft:redstone_ore",
"Properties": {