Initial draft on new ore config file
This commit is contained in:
parent
62fb79a6b0
commit
ee05dd5cb5
4 changed files with 121 additions and 0 deletions
|
@ -41,6 +41,7 @@ import techreborn.packets.PacketIdsu;
|
||||||
import techreborn.proxies.CommonProxy;
|
import techreborn.proxies.CommonProxy;
|
||||||
import techreborn.tiles.idsu.IDSUManager;
|
import techreborn.tiles.idsu.IDSUManager;
|
||||||
import techreborn.world.TROreGen;
|
import techreborn.world.TROreGen;
|
||||||
|
import techreborn.world.TechRebornWorldGen;
|
||||||
import techreborn.world.TreeGenerator;
|
import techreborn.world.TreeGenerator;
|
||||||
|
|
||||||
@Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES, guiFactory = ModInfo.GUI_FACTORY_CLASS, acceptedMinecraftVersions = "[1.8.8,1.8.9]")
|
@Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES, guiFactory = ModInfo.GUI_FACTORY_CLASS, acceptedMinecraftVersions = "[1.8.8,1.8.9]")
|
||||||
|
@ -60,6 +61,8 @@ public class Core {
|
||||||
private static RecipeCompact recipeCompact;
|
private static RecipeCompact recipeCompact;
|
||||||
private static File configDir;
|
private static File configDir;
|
||||||
|
|
||||||
|
public static TechRebornWorldGen worldGen;
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void preinit(FMLPreInitializationEvent event) {
|
public void preinit(FMLPreInitializationEvent event) {
|
||||||
event.getModMetadata().version = ModInfo.MOD_VERSION;
|
event.getModMetadata().version = ModInfo.MOD_VERSION;
|
||||||
|
@ -71,6 +74,8 @@ public class Core {
|
||||||
|
|
||||||
config = ConfigTechReborn.initialize(new File(path));
|
config = ConfigTechReborn.initialize(new File(path));
|
||||||
configDir = event.getModConfigurationDirectory();
|
configDir = event.getModConfigurationDirectory();
|
||||||
|
worldGen = new TechRebornWorldGen();
|
||||||
|
worldGen.configFile = (new File(event.getModConfigurationDirectory(), "techrebornOres.json"));
|
||||||
|
|
||||||
recipeCompact = new RecipeCompact();
|
recipeCompact = new RecipeCompact();
|
||||||
TechRebornAPI.recipeCompact = recipeCompact;
|
TechRebornAPI.recipeCompact = recipeCompact;
|
||||||
|
@ -111,6 +116,7 @@ public class Core {
|
||||||
// Client only init, needs to be done before parts system
|
// Client only init, needs to be done before parts system
|
||||||
proxy.init();
|
proxy.init();
|
||||||
// WorldGen
|
// WorldGen
|
||||||
|
worldGen.load();
|
||||||
GameRegistry.registerWorldGenerator(new TROreGen(), 0);
|
GameRegistry.registerWorldGenerator(new TROreGen(), 0);
|
||||||
GameRegistry.registerWorldGenerator(new TreeGenerator(), 0);
|
GameRegistry.registerWorldGenerator(new TreeGenerator(), 0);
|
||||||
// DungeonLoot.init();
|
// DungeonLoot.init();
|
||||||
|
|
39
src/main/java/techreborn/world/OreConfig.java
Normal file
39
src/main/java/techreborn/world/OreConfig.java
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package techreborn.world;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by modmuss50 on 11/03/2016.
|
||||||
|
*/
|
||||||
|
public class OreConfig {
|
||||||
|
|
||||||
|
public String blockName;
|
||||||
|
|
||||||
|
public String unloclisedName;
|
||||||
|
|
||||||
|
public String blockSate;
|
||||||
|
|
||||||
|
public int meta;
|
||||||
|
|
||||||
|
public String c = "↓↓↓↓CHANGE ME↓↓↓↓";
|
||||||
|
|
||||||
|
public int veinSize;
|
||||||
|
|
||||||
|
public int veinsPerChunk;
|
||||||
|
|
||||||
|
public int minYHeight;
|
||||||
|
|
||||||
|
public int maxYHeight;
|
||||||
|
|
||||||
|
|
||||||
|
public OreConfig(IBlockState blockSate, int veinSize, int veinsPerChunk, int minYHeight, int maxYHeight) {
|
||||||
|
this.blockName = blockSate.getBlock().getLocalizedName();
|
||||||
|
this.meta = blockSate.getBlock().getMetaFromState(blockSate);
|
||||||
|
this.unloclisedName = blockSate.getBlock().getUnlocalizedName();
|
||||||
|
this.blockSate = blockSate.toString();
|
||||||
|
this.veinSize = veinSize;
|
||||||
|
this.veinsPerChunk = veinsPerChunk;
|
||||||
|
this.minYHeight = minYHeight;
|
||||||
|
this.maxYHeight = maxYHeight;
|
||||||
|
}
|
||||||
|
}
|
61
src/main/java/techreborn/world/TechRebornWorldGen.java
Normal file
61
src/main/java/techreborn/world/TechRebornWorldGen.java
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
package techreborn.world;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
|
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||||
|
import techreborn.config.ConfigTechReborn;
|
||||||
|
import techreborn.init.ModBlocks;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by modmuss50 on 11/03/2016.
|
||||||
|
*/
|
||||||
|
public class TechRebornWorldGen implements IWorldGenerator {
|
||||||
|
|
||||||
|
WorldGenConfig config;
|
||||||
|
public File configFile;
|
||||||
|
|
||||||
|
public void load(){
|
||||||
|
if(config == null){
|
||||||
|
if(configFile.exists()){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
addOres();
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save(){
|
||||||
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
String json = gson.toJson(config);
|
||||||
|
try {
|
||||||
|
FileWriter writer = new FileWriter(configFile);
|
||||||
|
writer.write(json);
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addOres(){
|
||||||
|
config = new WorldGenConfig();
|
||||||
|
config.overworldOres = new ArrayList<>();
|
||||||
|
config.endOres = new ArrayList<>();
|
||||||
|
config.neatherOres = new ArrayList<>();
|
||||||
|
|
||||||
|
config.overworldOres.add(new OreConfig(ModBlocks.ore.getBlockStateFromName("Galena"), 8, 16, 10, 60));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
15
src/main/java/techreborn/world/WorldGenConfig.java
Normal file
15
src/main/java/techreborn/world/WorldGenConfig.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package techreborn.world;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by modmuss50 on 11/03/2016.
|
||||||
|
*/
|
||||||
|
public class WorldGenConfig {
|
||||||
|
|
||||||
|
public List<OreConfig> overworldOres;
|
||||||
|
|
||||||
|
public List<OreConfig> neatherOres;
|
||||||
|
|
||||||
|
public List<OreConfig> endOres;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue