forked from TAIGA/TAIGA
added void detection in worldgen
This commit is contained in:
@@ -14,6 +14,8 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import slimeknights.tconstruct.library.MaterialIntegration;
|
||||
import slimeknights.tconstruct.library.materials.BowMaterialStats;
|
||||
|
||||
@@ -31,6 +33,7 @@ public class TAIGA {
|
||||
public static final String MODID = "taiga";
|
||||
public static final String VERSION = "@VERSION@";
|
||||
public static final String GUIFACTORY = "com.sosnitzka.taiga.TAIGAGuiFactory";
|
||||
public static final Logger logger = LogManager.getLogger("TAIGA");
|
||||
|
||||
@SidedProxy(clientSide = "com.sosnitzka.taiga.proxy.ClientProxy", serverSide = "com.sosnitzka.taiga.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
@@ -52,7 +55,7 @@ public class TAIGA {
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
proxy.registerModels(); // Registers models on the client side
|
||||
GameRegistry.registerWorldGenerator(new WorldGen(), 100); // Generates ores
|
||||
GameRegistry.registerWorldGenerator(WorldGen.getInstance(), 100); // Generates ores
|
||||
// GameRegistry.registerFuelHandler(new FuelHandler()); Registeres fuels' burn times
|
||||
SmeltingRegistry.register(); // Registers smelting recipes
|
||||
CraftingRegistry.register(); // Registers crafting recipes
|
||||
@@ -66,8 +69,6 @@ public class TAIGA {
|
||||
for (MaterialIntegration m : integrateList) {
|
||||
m.integrateRecipes();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@@ -1,11 +1,10 @@
|
||||
package com.sosnitzka.taiga.recipes;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class SmeltingRegistry {
|
||||
public static void register() {
|
||||
ItemStack nugget_iron = OreDictionary.getOres("nuggetIron").get(OreDictionary.getOres("nuggetIron").size() - 1);
|
||||
OreDictionary.getOres("nuggetIron").get(OreDictionary.getOres("nuggetIron").size() - 1);
|
||||
}
|
||||
}
|
||||
|
@@ -178,7 +178,7 @@ public class Generator {
|
||||
}
|
||||
|
||||
|
||||
public static void generateMeteor(IBlockState centerBlock, IBlockState hullBlock, Random random, int chunkX, int chunkZ, World world, int count, int chance, int minY, int maxY) {
|
||||
public static int generateMeteor(IBlockState centerBlock, IBlockState hullBlock, Random random, int chunkX, int chunkZ, World world, int count, int chance, int minY, int maxY) {
|
||||
Set<Item> validSurface = new HashSet<Item>();
|
||||
List<String> oredictentries = Lists.newArrayList("dirt", "grass", "stone", "sand", "gravel", "cobblestone", "sandstone");
|
||||
for (String e : oredictentries) {
|
||||
@@ -187,6 +187,8 @@ public class Generator {
|
||||
}
|
||||
}
|
||||
|
||||
int mGenerated = 0;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (random.nextFloat() < 0.01 * chance) {
|
||||
int r = nextInt(random, 1, 5);
|
||||
@@ -199,8 +201,7 @@ public class Generator {
|
||||
while (world.getBlockState(cPos.down()).equals(Blocks.AIR.getDefaultState())) {
|
||||
cPos = cPos.down();
|
||||
|
||||
// if we are below 0, we might be in a void dim
|
||||
if (cPos.getY() < 0)
|
||||
if (cPos.getY() < minY)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -212,6 +213,8 @@ public class Generator {
|
||||
saveData.addPos(cPos);
|
||||
saveData.markDirty();
|
||||
|
||||
mGenerated++;
|
||||
|
||||
int t = 1;
|
||||
if (r > 3) t = random.nextInt(r - 1);
|
||||
for (int x = -t; x <= t; x++) {
|
||||
@@ -239,5 +242,7 @@ public class Generator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mGenerated;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.sosnitzka.taiga.world;
|
||||
|
||||
|
||||
import com.sosnitzka.taiga.TAIGA;
|
||||
import com.sosnitzka.taiga.util.Generator;
|
||||
import net.minecraft.block.BlockStone;
|
||||
import net.minecraft.init.Biomes;
|
||||
@@ -10,7 +11,7 @@ import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
import static com.sosnitzka.taiga.Blocks.*;
|
||||
@@ -18,6 +19,18 @@ import static com.sosnitzka.taiga.TAIGAConfiguration.*;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class WorldGen implements IWorldGenerator {
|
||||
private static WorldGen INSTANCE;
|
||||
private final List<Integer> blackList = new ArrayList();
|
||||
private final Map<Integer, Integer> meteorGenStats = new HashMap();
|
||||
private final Map<Integer, Integer> meteorChunkStats = new HashMap();
|
||||
|
||||
public static WorldGen getInstance() {
|
||||
if (INSTANCE == null)
|
||||
INSTANCE = new WorldGen();
|
||||
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private void nether(Random random, int x, int z, World world) {
|
||||
Generator.generateOre(tiberiumOre.getDefaultState(), Blocks.NETHERRACK.getDefaultState(), random, x, z, world, TIBERIUM_VAL, 32, 128, 10, 35);
|
||||
Generator.generateOre(prometheumOre.getDefaultState(), Blocks.NETHERRACK.getDefaultState(), random, x, z, world, PROMETHEUM_VAL, 0, 32, 2, 4);
|
||||
@@ -26,7 +39,15 @@ public class WorldGen implements IWorldGenerator {
|
||||
}
|
||||
|
||||
private void world(Random random, int x, int z, World world) {
|
||||
Generator.generateMeteor(duraniteOre.getDefaultState(), blockMeteorite.getDefaultState(), random, x, z, world, DURANITE_VAL, 6, 16, 112);
|
||||
int dim = world.provider.getDimension();
|
||||
if (!meteorGenStats.containsKey(dim))
|
||||
meteorGenStats.put(dim, 0);
|
||||
|
||||
if (!meteorChunkStats.containsKey(dim))
|
||||
meteorChunkStats.put(dim, 0);
|
||||
|
||||
meteorChunkStats.put(dim, meteorChunkStats.get(dim) + 1);
|
||||
meteorGenStats.put(meteorGenStats.get(dim), meteorGenStats.get(dim) + Generator.generateMeteor(duraniteOre.getDefaultState(), blockMeteorite.getDefaultState(), random, x, z, world, DURANITE_VAL, 6, 16, 112));
|
||||
Generator.generateOreDescending(newArrayList(Blocks.LAVA.getDefaultState(), Blocks.FLOWING_LAVA.getDefaultState()), basaltBlock.getDefaultState(), random, x, z, world, BASALT_VAL, 0, 64);
|
||||
Generator.generateOreDescending(newArrayList(Blocks.BEDROCK.getDefaultState()), eezoOre.getDefaultState(), random, x, z, world, EEZO_VAL, 0, 10);
|
||||
Generator.generateOreStoneVariant(karmesineOre.getDefaultState(), BlockStone.EnumType.ANDESITE, random, x, z, world, KARMESINE_VAL);
|
||||
@@ -38,6 +59,11 @@ public class WorldGen implements IWorldGenerator {
|
||||
if (ironGen) {
|
||||
Generator.generateOre(Blocks.IRON_ORE.getDefaultState(), Blocks.STONE.getDefaultState(), random, x, z, world, IRON_VAL, 0, 32, 2, 8);
|
||||
}
|
||||
|
||||
if (meteorChunkStats.get(dim) > 100 && meteorGenStats.get(dim) == 0) {
|
||||
blackList.add(dim);
|
||||
TAIGA.logger.info(String.format("Detected void dimension, adding to blacklist: %d", dim));
|
||||
}
|
||||
}
|
||||
|
||||
private void end(Random random, int x, int z, World world) {
|
||||
@@ -64,7 +90,8 @@ public class WorldGen implements IWorldGenerator {
|
||||
end(random, x, z, world);
|
||||
break;
|
||||
default:
|
||||
world(random, x, z, world);
|
||||
if (!blackList.contains(world.provider.getDimension()))
|
||||
world(random, x, z, world);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user