diff options
Diffstat (limited to 'src/Java')
13 files changed, 803 insertions, 344 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus_Secondary.java b/src/Java/gtPlusPlus/GTplusplus_Secondary.java index 0a8517e9bc..ae163191fd 100644 --- a/src/Java/gtPlusPlus/GTplusplus_Secondary.java +++ b/src/Java/gtPlusPlus/GTplusplus_Secondary.java @@ -9,6 +9,8 @@ import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_Config; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.MaterialGenerator; @@ -17,6 +19,7 @@ import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; import gtPlusPlus.core.world.darkworld.biome.Biome_DarkWorld; import gtPlusPlus.core.world.darkworld.block.DarkWorldContentLoader; import gtPlusPlus.core.world.darkworld.gen.gt.WorldGen_GT_Base; +import gtPlusPlus.core.world.darkworld.gen.gt.WorldGen_Ores; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; import net.minecraftforge.common.DimensionManager; @@ -44,7 +47,7 @@ public class GTplusplus_Secondary { Logger.INFO("Loading " + MODID2 + " V" + VERSION2); //Setup - setVars(); + setVars(event); setDarkBiome(new Biome_DarkWorld()); DarkWorld_Dimension = new Dimension_DarkWorld(); @@ -112,7 +115,10 @@ public class GTplusplus_Secondary { } - void setVars(){ + void setVars(FMLPreInitializationEvent event){ + //Init WorldGen config. + HANDLER_GT.sCustomWorldgenFile = new GTPP_Config(new Configuration(new File(new File(event.getModConfigurationDirectory(), "GTplusplus"), "WorldGeneration.cfg"))); + if (DimensionManager.isDimensionRegistered(Dimension_DarkWorld.DIMID)){ Dimension_DarkWorld.DIMID = DimensionManager.getNextFreeDimId(); } @@ -120,7 +126,7 @@ public class GTplusplus_Secondary { /* * Set World Generation Values */ - + WorldGen_Ores.generateValidOreVeins(); WorldGen_GT_Base.oreveinPercentage = 75; WorldGen_GT_Base.oreveinAttempts = 64; WorldGen_GT_Base.oreveinMaxPlacementAttempts = 8; diff --git a/src/Java/gtPlusPlus/api/objects/MaterialHelper.java b/src/Java/gtPlusPlus/api/objects/MaterialHelper.java index 9ffecefb26..d63ab7a15a 100644 --- a/src/Java/gtPlusPlus/api/objects/MaterialHelper.java +++ b/src/Java/gtPlusPlus/api/objects/MaterialHelper.java @@ -1,5 +1,6 @@ package gtPlusPlus.api.objects; +import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.item.ItemUtils; @@ -10,5 +11,8 @@ public class MaterialHelper { public static ItemStack getComponentFromMaterial(OrePrefixes oreprefix, Material material, int amount){ return ItemUtils.getOrePrefixStack(oreprefix, material, amount); } + public static ItemStack getComponentFromGtMaterial(OrePrefixes oreprefix, Materials material, int amount){ + return ItemUtils.getGregtechOreStack(oreprefix, material, amount); + } } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 1fab791c25..97cf3310ea 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -352,16 +352,16 @@ public final class ModItems { */ if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGadolinium", 1) == null){ - ItemUtils.generateSpecialUseDusts("Gadolinium", "Gadolinium", Materials.Gadolinium.mChemicalFormula, Utils.rgbtoHexValue(226, 172, 9)); + ItemUtils.generateSpecialUseDusts("Gadolinium", "Gadolinium", Materials.Gadolinium.mElement.name(), Utils.rgbtoHexValue(226, 172, 9)); } if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustYtterbium", 1) == null){ - ItemUtils.generateSpecialUseDusts("Ytterbium", "Ytterbium", Materials.Ytterbium.mChemicalFormula, Utils.rgbtoHexValue(Materials.Yttrium.mRGBa[0]-60, Materials.Yttrium.mRGBa[1]-60, Materials.Yttrium.mRGBa[2]-60)); + ItemUtils.generateSpecialUseDusts("Ytterbium", "Ytterbium", Materials.Ytterbium.mElement.name(), Utils.rgbtoHexValue(Materials.Yttrium.mRGBa[0]-60, Materials.Yttrium.mRGBa[1]-60, Materials.Yttrium.mRGBa[2]-60)); } if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustSamarium", 1) == null){ - ItemUtils.generateSpecialUseDusts("Samarium", "Samarium", Materials.Samarium.mChemicalFormula, Utils.rgbtoHexValue(161, 168, 114)); + ItemUtils.generateSpecialUseDusts("Samarium", "Samarium", Materials.Samarium.mElement.name(), Utils.rgbtoHexValue(161, 168, 114)); } if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustLanthanum", 1) == null){ - ItemUtils.generateSpecialUseDusts("Lanthanum", "Lanthanum", Materials.Lanthanum.mChemicalFormula, Utils.rgbtoHexValue(106, 127, 163)); + ItemUtils.generateSpecialUseDusts("Lanthanum", "Lanthanum", Materials.Lanthanum.mElement.name(), Utils.rgbtoHexValue(106, 127, 163)); } /*if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustGadolinium", 1) == null){ ItemUtils.generateSpecialUseDusts("Gadolinium", "Gadolinium", "", Utils.rgbtoHexValue(Materials.Gadolinium.mRGBa[0], Materials.Gadolinium.mRGBa[1], Materials.Gadolinium.mRGBa[2])); diff --git a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java index 2c32c0c8af..64155df7c4 100644 --- a/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java +++ b/src/Java/gtPlusPlus/core/item/base/dusts/BaseItemDustUnique.java @@ -108,7 +108,7 @@ public class BaseItemDustUnique extends Item{ if (this.sRadiation > 0){ list.add(CORE.GT_Tooltip_Radioactive); } - if (StringUtils.containsSuperOrSubScript(this.chemicalNotation)){ + if (this.chemicalNotation.length() > 0 && !chemicalNotation.equals("") && !chemicalNotation.equals("NullFormula")){ list.add(this.chemicalNotation); } super.addInformation(stack, aPlayer, list, bool); diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index 732c59c9a9..e2de72fa57 100644 --- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -117,10 +117,10 @@ public class BaseOreComponent extends Item{ @SideOnly(Side.CLIENT) public void registerIcons(final IIconRegister par1IconRegister){ if (CORE.ConfigSwitches.useGregtechTextures){ - Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" is using `"+"gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"' as the layer 0 texture path."); + //Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" is using `"+"gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"' as the layer 0 texture path."); this.base = par1IconRegister.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME); if (this.componentType.hasOverlay()){ - Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" is using `"+"gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"_OVERLAY"+"' as the layer 1 texture path."); + //Logger.MATERIALS(this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME+" is using `"+"gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"_OVERLAY"+"' as the layer 1 texture path."); this.overlay = par1IconRegister.registerIcon("gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME+"_OVERLAY"); } } diff --git a/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java b/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java index ea4d8f5a1b..fc92d5d82c 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java @@ -3,6 +3,7 @@ package gtPlusPlus.core.item.general; import java.util.List; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.base.BlockBaseOre; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; @@ -107,35 +108,40 @@ public class ItemAreaClear extends CoreItem { int y1 = pos.yPos; int z1 = pos.zPos; - int x2 = (x1-12); - int y2 = (y1-5); - int z2 = (z1-12); + int x2 = (x1-24); + int y2 = (y1-10); + int z2 = (z1-24); removeBlockColumn(world, new BlockPos(x2, y2, z2)); return true; } public boolean removeBlockColumn(World world, BlockPos pos){ - for (int i=0; i<25; i++){ + for (int i=0; i<50; i++){ + removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos-10, pos.zPos+i)); removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos, pos.zPos+i)); + removeBlockRow(world, new BlockPos(pos.xPos, pos.yPos+10, pos.zPos+i)); } return true; } public boolean removeBlockRow(World world, BlockPos pos){ - for (int j=0; j<10; j++){ - for (int i=0; i<25; i++){ - if (!world.isAirBlock(pos.xPos+i, pos.yPos+j, pos.zPos) && - world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) != Blocks.bedrock){ - int chance = MathUtils.randInt(0, 100); - if (chance <= 0){ - if (pos.yPos+j <= 50){ - world.setBlock(pos.xPos+i, pos.yPos+j, pos.zPos, Blocks.glowstone); + for (int j=0; j<20; j++){ + for (int i=0; i<50; i++){ + + if (!(world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) instanceof BlockBaseOre)){ + if (!world.isAirBlock(pos.xPos+i, pos.yPos+j, pos.zPos) && + world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) != Blocks.bedrock){ + int chance = MathUtils.randInt(0, 100); + if (chance <= 0){ + if (pos.yPos+j <= 50){ + world.setBlock(pos.xPos+i, pos.yPos+j, pos.zPos, Blocks.glowstone); + } } - } - else { - if ((world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) == Blocks.glowstone && ((pos.yPos+j) > 50)) || world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) != Blocks.glowstone){ - world.setBlock(pos.xPos+i, pos.yPos+j, pos.zPos, Blocks.air); + else { + if ((world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) == Blocks.glowstone && ((pos.yPos+j) > 50)) || world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) != Blocks.glowstone){ + world.setBlock(pos.xPos+i, pos.yPos+j, pos.zPos, Blocks.air); + } } } } @@ -168,7 +174,7 @@ public class ItemAreaClear extends CoreItem { for (int j=0; j<2; j++){ for (int i=0; i<21; i++){ if (world.getBlock(pos.xPos+i, pos.yPos+j, pos.zPos) != Blocks.bedrock){ - world.setBlock(pos.xPos+i, pos.yPos+j, pos.zPos, Blocks.grass); + world.setBlock(pos.xPos+i, pos.yPos+j, pos.zPos, Blocks.grass); } } } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 3884920c96..0f90d61312 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -15,6 +15,7 @@ import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -483,6 +484,28 @@ public class Material { public final ItemStack getOre(final int stacksize){ return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ore"+Utils.sanitizeString(this.getUnlocalizedName()), stacksize); } + public final Block getOreBlock(final int stacksize){ + Logger.DEBUG_MATERIALS("Trying to get ore block for "+this.getLocalizedName()+". Looking for '"+"ore"+Utils.sanitizeString(this.getUnlocalizedName())+"'."); + try{ + ItemStack a1 = getOre(1); + Item a2 = a1.getItem(); + Block a3 = Block.getBlockFromItem(a2); + + Logger.DEBUG_MATERIALS("[Invalid Ore] Is a1 valid? "+(a1 != null)); + Logger.DEBUG_MATERIALS("[Invalid Ore] Is a2 valid? "+(a2 != null)); + Logger.DEBUG_MATERIALS("[Invalid Ore] Is a3 valid? "+(a3 != null)); + + Block x = Block.getBlockFromItem(ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ore"+Utils.sanitizeString(this.unlocalizedName), stacksize).getItem()); + if (x != null){ + return x; + } + } + catch (Throwable t){ + t.printStackTrace(); + } + Logger.MATERIALS("Failed getting the Ore Block for "+this.getLocalizedName()+"."); + return Blocks.stone; + } public final ItemStack getCrushed(final int stacksize){ return ItemUtils.getItemStackOfAmountFromOreDictNoBroken("crushed"+this.unlocalizedName, stacksize); } diff --git a/src/Java/gtPlusPlus/core/material/ORES.java b/src/Java/gtPlusPlus/core/material/ORES.java index 6428c0dd4f..22e43a0aef 100644 --- a/src/Java/gtPlusPlus/core/material/ORES.java +++ b/src/Java/gtPlusPlus/core/material/ORES.java @@ -188,7 +188,7 @@ public final class ORES { new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), - new MaterialStack(ELEMENT.getInstance().IRON, 1), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 1), new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 2), new MaterialStack(ELEMENT.getInstance().SILICON, 7), new MaterialStack(ELEMENT.getInstance().OXYGEN, 14), @@ -209,7 +209,7 @@ public final class ORES { new MaterialStack(ELEMENT.getInstance().LANTHANUM, 2), new MaterialStack(ELEMENT.getInstance().NEODYMIUM, 2), new MaterialStack(ELEMENT.getInstance().YTTRIUM, 4), - new MaterialStack(ELEMENT.getInstance().IRON, 2), + new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), new MaterialStack(ELEMENT.getInstance().BERYLLIUM, 3), new MaterialStack(ELEMENT.getInstance().SILICON, 4), new MaterialStack(ELEMENT.getInstance().OXYGEN, 9), @@ -223,7 +223,7 @@ public final class ORES { 1500, 50, 75, - 0, //Radiation + 1, //Radiation new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().CALCIUM, 1), new MaterialStack(ELEMENT.getInstance().GADOLINIUM, 2), @@ -280,19 +280,6 @@ public final class ORES { new MaterialStack(ELEMENT.getInstance().YTTRIUM, 1), }); - - - - - - - - - - - - - public static final Material POLYCRASE = new Material( "Polycrase", //Material Name MaterialState.ORE, //State diff --git a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java index cc9a679193..7db80c70fb 100644 --- a/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/materials/MaterialUtils.java @@ -47,15 +47,20 @@ public class MaterialUtils { final int durability = material.mDurability; boolean mGenerateCell = false; MaterialState materialState; - final String chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mChemicalFormula)); + String chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mChemicalFormula)); final Element element = material.mElement; int radioactivity = 0; if (material.isRadioactive()){ radioactivity = 1; } - + + //Weird Blacklist of Bad Chemical Strings + if (material.mElement == Element.Pb || material.mElement == Element.Na || material.mElement == Element.Ar){ + chemicalFormula = StringUtils.subscript(Utils.sanitizeString(material.mElement.name())); + } + //Determine default state - Logger.MATERIALS("[Debug] Setting State of GT generated material."); + Logger.MATERIALS("[Debug] Setting State of GT generated material. "+material.mDefaultLocalName); if (material.getMolten(1) != null || material.getSolid(1) != null){ materialState = MaterialState.SOLID; Logger.MATERIALS("[Debug] Molten or Solid was not null."); @@ -96,6 +101,9 @@ public class MaterialUtils { //ModItems.itemBaseCentidust = UtilsItems.generateCentidust(material); return new Material(name, materialState, durability, rgba, melting, boiling, protons, neutrons, blastFurnace, chemicalFormula, radioactivity, mGenerateCell); } + else { + Logger.DEBUG_MATERIALS("Failed to generate GT++ material instance for "+material.name() +" | Valid RGB? "+(hasValidRGBA(rgba))); + } return null; } @@ -116,26 +124,10 @@ public class MaterialUtils { return temp; } - public static boolean hasValidRGBA(final short[] rgba){ - boolean test1 = false; - boolean test2 = false; - boolean test3 = false; - for (int r=0;r<rgba.length;r++){ - if (rgba[r] == 0){ - if (r == 0){ - test1 = true; - } - else if (r == 1){ - test2 = true; - } - else if (r == 2){ - test3 = true; - } - } - } - if ((test1 && test2) || (test1 && test3) || (test3 && test2)){ + public static boolean hasValidRGBA(final short[] rgba){ + if (rgba == null || rgba.length < 3 || rgba.length > 4){ return false; - } + } return true; } diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java index 608bf91e58..93c34e6fcc 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java @@ -4,177 +4,172 @@ import java.util.*; import cpw.mods.fml.common.IWorldGenerator; import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; import gregtech.api.util.GT_Log; -import gregtech.api.world.GT_Worldgen; -import gtPlusPlus.api.objects.CSPRNG; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.api.objects.XSTR; import net.minecraft.block.Block; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.ChunkProviderEnd; -import net.minecraft.world.gen.ChunkProviderHell; import net.minecraft.world.gen.feature.WorldGenMinable; -public class WorldGen_GT_Base implements IWorldGenerator{ +public class WorldGen_GT_Base implements IWorldGenerator { /** * Class Variables */ /** - * Control percentage of filled 3x3 chunks. Lower number means less oreveins spawn - */ - public static int oreveinPercentage; - /** - * Control number of attempts to find a valid orevein. Generally this maximum limit isn't hit, selecting a vein is cheap - */ - public static int oreveinAttempts; - /** - * Control number of attempts to place a valid orevein. If a vein wasn't placed due to height restrictions, completely in the water, etc, another attempt is tried. - */ - public static int oreveinMaxPlacementAttempts; - /** - * Debug parameter for world generation. Tracks chunks added/removed from run queue. - */ - public static boolean debugWorldGen = false; + * Control percentage of filled 3x3 chunks. Lower number means less oreveins + * spawn + */ + public static int oreveinPercentage; + /** + * Control number of attempts to find a valid orevein. Generally this + * maximum limit isn't hit, selecting a vein is cheap + */ + public static int oreveinAttempts; /** - * Try re-implement Richard Hendrick's Chunk by Chunk Ore Generation from his GT5u fork. + * Control number of attempts to place a valid orevein. If a vein wasn't + * placed due to height restrictions, completely in the water, etc, another + * attempt is tried. + */ + public static int oreveinMaxPlacementAttempts; + /** + * Debug parameter for world generation. Tracks chunks added/removed from + * run queue. + */ + public static boolean debugWorldGen = false; + /** + * Try re-implement Richard Hendrick's Chunk by Chunk Ore Generation from + * his GT5u fork. */ public static List<Runnable> mList = new ArrayList<Runnable>(); public static HashSet<Long> ProcChunks = new HashSet<Long>(); - // This is probably not going to work. Trying to create a fake orevein to put into hashtable when there will be no ores in a vein. - public static WorldGen_GT_Ore_Layer noOresInVein = new WorldGen_GT_Ore_Layer( "NoOresInVein", false, 0, 255, 0, 255, 16, false, false, false, false, false, false, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium); - public static Hashtable<Long, WorldGen_GT_Ore_Layer> validOreveins = new Hashtable<Long, WorldGen_GT_Ore_Layer>(1024); + // This is probably not going to work. Trying to create a fake orevein to + // put into hashtable when there will be no ores in a vein. + public static WorldGen_GT_Ore_Layer noOresInVein = new WorldGen_GT_Ore_Layer("vein0", 0, 255, 0, 0, + 0, ELEMENT.getInstance().ALUMINIUM, ELEMENT.getInstance().ALUMINIUM, ELEMENT.getInstance().ALUMINIUM, ELEMENT.getInstance().ALUMINIUM); + + public static Hashtable<Long, WorldGen_GT_Ore_Layer> validOreveins = new Hashtable<Long, WorldGen_GT_Ore_Layer>( + 1024); + public boolean mIsGenerating = false; public static final Object listLock = new Object(); - //private static boolean gcAsteroids = true; - + // private static boolean gcAsteroids = true; - public WorldGen_GT_Base(){ + public WorldGen_GT_Base() { GameRegistry.registerWorldGenerator(this, 7735); if (debugWorldGen) { GT_Log.out.println("GTPP_Worldgenerator created"); } } - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, + IChunkProvider chunkProvider) { if (world.provider.dimensionId == Dimension_DarkWorld.DIMID) { generateSafely(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); } } - public synchronized void generateSafely(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){ + public synchronized void generateSafely(Random random, int chunkX, int chunkZ, World world, + IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { int xDim = Dimension_DarkWorld.DIMID; - switch(world.provider.dimensionId){ - case -1: //Nether - generateNether(world, random, chunkX * 16, chunkZ * 16); + switch (world.provider.dimensionId) { + case -1: // Nether + // generateNether(world, random, chunkX * 16, chunkZ * 16); break; - case 0: //Overworld - generateSurface(world, random, chunkX * 16, chunkZ * 16); + case 0: // Overworld + // generateSurface(world, random, chunkX * 16, chunkZ * 16); break; - case 1: //End - generateEnd(world, random, chunkX * 16, chunkZ * 16); + case 1: // End + // generateEnd(world, random, chunkX * 16, chunkZ * 16); break; - default: //Any other dimension - if (world.provider.dimensionId != xDim){ + default: // Any other dimension + if (world.provider.dimensionId != xDim) { break; } else { generateDarkWorld(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); - break; + break; } } } - private void generateEnd(World world, Random random, int x, int z) - { - //... + private void generateEnd(World world, Random random, int x, int z) { + // ... } - private void generateSurface(World world, Random random, int x, int z) - { - //... + private void generateSurface(World world, Random random, int x, int z) { + // ... } - private void generateNether(World world, Random random, int x, int z) - { - //... + private void generateNether(World world, Random random, int x, int z) { + // ... } - private synchronized void generateDarkWorld(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider){ - synchronized (listLock) - { - WorldGen_GT_Base.mList.add(new WorldGenContainer(new CSPRNG(Math.abs(aRandom.nextInt()) +1), aX, aZ, ((aChunkGenerator instanceof ChunkProviderEnd)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.sky) ? 1 : ((aChunkGenerator instanceof ChunkProviderHell)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.hell) ? -1 : 0, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName)); - if (debugWorldGen) GT_Log.out.println( - "ADD WorldSeed:"+aWorld.getSeed() + - " DimId" + aWorld.provider.dimensionId + - " chunk x:" + aX + - " z:" + aZ + - " SIZE: " + WorldGen_GT_Base.mList.size() - ); + private synchronized void generateDarkWorld(Random aRandom, int aX, int aZ, World aWorld, + IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + Logger.WORLD("Trying to Generate Dimension."); + synchronized (listLock) { + Logger.WORLD("Locked List addition."); + if (WorldGen_GT_Base.mList.add(new WorldGenContainer(new XSTR(Math.abs(aRandom.nextInt()) + 1), aX, aZ, + Dimension_DarkWorld.DIMID, + aWorld, aChunkGenerator, aChunkProvider, + aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName))){ + Logger.WORLD("Locked List addition. Success."); + } + else { + Logger.WORLD("Locked List addition. Fail."); + } + if (debugWorldGen) + GT_Log.out.println("ADD WorldSeed:" + aWorld.getSeed() + " DimId" + aWorld.provider.dimensionId + + " chunk x:" + aX + " z:" + aZ + " SIZE: " + WorldGen_GT_Base.mList.size()); } if (!this.mIsGenerating) { + Logger.WORLD("Is not generating."); this.mIsGenerating = true; - int mList_sS=WorldGen_GT_Base.mList.size(); - mList_sS = Math.min(mList_sS, 5); // Run a maximum of 5 chunks at a time through worldgen. Extra chunks get done later. + Logger.WORLD("Setting Generation to true."); + int mList_sS = WorldGen_GT_Base.mList.size(); + mList_sS = Math.min(mList_sS, 5); // Run a maximum of 5 chunks at a + // time through worldgen. Extra + // chunks get done later. for (int i = 0; i < mList_sS; i++) { WorldGenContainer toRun = (WorldGenContainer) WorldGen_GT_Base.mList.get(0); - if (debugWorldGen) GT_Log.out.println( - "RUN WorldSeed:"+aWorld.getSeed()+ - " DimId" + aWorld.provider.dimensionId + - " chunk x:" + toRun.mX + - " z:" + toRun.mZ + - " SIZE: " + WorldGen_GT_Base.mList.size() + - " i: " + i - ); - synchronized (listLock) - { + if (debugWorldGen) + GT_Log.out.println("RUN WorldSeed:" + aWorld.getSeed() + " DimId" + aWorld.provider.dimensionId + + " chunk x:" + toRun.mX + " z:" + toRun.mZ + " SIZE: " + WorldGen_GT_Base.mList.size() + + " i: " + i); + synchronized (listLock) { + Logger.WORLD("Locked List Removal."); WorldGen_GT_Base.mList.remove(0); } toRun.run(); } this.mIsGenerating = false; + Logger.WORLD("Is Generating now set to false.."); } } - public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn) - { - - + public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ, + int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn) { int heightRange = maxY - minY; WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn); - for (int k1 = 0; k1 < chancesToSpawn; ++k1) - { + for (int k1 = 0; k1 < chancesToSpawn; ++k1) { int xrand = random.nextInt(16); int yrand = random.nextInt(heightRange) + minY; int zrand = random.nextInt(16); - worldgenminable.generate(world, random, chunk_x+xrand, yrand, chunk_z+zrand); + worldgenminable.generate(world, random, chunk_x + xrand, yrand, chunk_z + zrand); } } - - - - - - - - - - - - - public static class WorldGenContainer - implements Runnable { + public static class WorldGenContainer implements Runnable { public final Random mRandom; public final int mX; public final int mZ; @@ -183,19 +178,24 @@ public class WorldGen_GT_Base implements IWorldGenerator{ public final IChunkProvider mChunkGenerator; public final IChunkProvider mChunkProvider; public final String mBiome; - // Local class to track which orevein seeds must be checked when doing chunkified worldgen + + // Local class to track which orevein seeds must be checked when doing + // chunkified worldgen class NearbySeeds { public int mX; public int mZ; - NearbySeeds( int x, int z) { + + NearbySeeds(int x, int z) { this.mX = x; this.mZ = z; } }; + public static ArrayList<NearbySeeds> seedList = new ArrayList<NearbySeeds>(); // aX and aZ are now the by-chunk X and Z for the chunk of interest - public WorldGenContainer(Random aRandom, int aX, int aZ, int aDimensionType, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider, String aBiome) { + public WorldGenContainer(Random aRandom, int aX, int aZ, int aDimensionType, World aWorld, + IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider, String aBiome) { this.mRandom = aRandom; this.mX = aX; this.mZ = aZ; @@ -206,124 +206,177 @@ public class WorldGen_GT_Base implements IWorldGenerator{ this.mBiome = aBiome; } - public void worldGenFindVein( int oreseedX, int oreseedZ) { + public void worldGenFindVein(int oreseedX, int oreseedZ) { // Explanation of oreveinseed implementation. - // (long)this.mWorld.getSeed()<<16) Deep Dark does two oregen passes, one with getSeed set to +1 the original world seed. This pushes that +1 off the low bits of oreseedZ, so that the hashes are far apart for the two passes. - // ((this.mWorld.provider.dimensionId & 0xffL)<<56) Puts the dimension in the top bits of the hash, to make sure to get unique hashes per dimension - // ((long)oreseedX & 0x000000000fffffffL) << 28) Puts the chunk X in the bits 29-55. Cuts off the top few bits of the chunk so we have bits for dimension. - // ( (long)oreseedZ & 0x000000000fffffffL )) Puts the chunk Z in the bits 0-27. Cuts off the top few bits of the chunk so we have bits for dimension. - long oreveinSeed = (this.mWorld.getSeed()<<16) ^ ((this.mWorld.provider.dimensionId & 0xffL)<<56 |( (oreseedX & 0x000000000fffffffL) << 28) | ( oreseedZ & 0x000000000fffffffL )); // Use an RNG that is identical every time it is called for this oreseed. - CSPRNG oreveinRNG = CSPRNG.generate(new XSTR(oreveinSeed)); - int oreveinPercentageRoll = oreveinRNG.nextInt(100); // Roll the dice, see if we get an orevein here at all - int noOrePlacedCount=0; + // (long)this.mWorld.getSeed()<<16) Deep Dark does two oregen + // passes, one with getSeed set to +1 the original world seed. This + // pushes that +1 off the low bits of oreseedZ, so that the hashes + // are far apart for the two passes. + // ((this.mWorld.provider.dimensionId & 0xffL)<<56) Puts the + // dimension in the top bits of the hash, to make sure to get unique + // hashes per dimension + // ((long)oreseedX & 0x000000000fffffffL) << 28) Puts the chunk X in + // the bits 29-55. Cuts off the top few bits of the chunk so we have + // bits for dimension. + // ( (long)oreseedZ & 0x000000000fffffffL )) Puts the chunk Z in the + // bits 0-27. Cuts off the top few bits of the chunk so we have bits + // for dimension. + long oreveinSeed = (this.mWorld.getSeed() << 16) ^ ((this.mWorld.provider.dimensionId & 0xffL) << 56 + | ((oreseedX & 0x000000000fffffffL) << 28) | (oreseedZ & 0x000000000fffffffL)); // Use + // an + // RNG + // that + // is + // identical + // every + // time + // it + // is + // called + // for + // this + // oreseed. + XSTR oreveinRNG = new XSTR(oreveinSeed); + int oreveinPercentageRoll = oreveinRNG.nextInt(100); // Roll the + // dice, see + // if we get + // an + // orevein + // here at + // all + int noOrePlacedCount = 0; String tDimensionName = ""; - if (debugWorldGen) { tDimensionName = this.mWorld.provider.getDimensionName(); } + if (debugWorldGen) { + tDimensionName = this.mWorld.provider.getDimensionName(); + } - if (debugWorldGen) GT_Log.out.println( - " Finding oreveins for oreveinSeed="+ oreveinSeed + - " mX="+ this.mX + - " mZ="+ this.mZ + - " oreseedX="+ oreseedX + - " oreseedZ="+ oreseedZ + - " worldSeed="+this.mWorld.getSeed() - ); + if (debugWorldGen){ + GT_Log.out.println(" Finding oreveins for oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + + this.mZ + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " worldSeed=" + + this.mWorld.getSeed()); + } + Logger.INFO("[World Generation Debug] !validOreveins.containsKey(oreveinSeed) | oreveinSeed: "+oreveinSeed); // Search for a valid orevein for this dimension - if(!validOreveins.containsKey(oreveinSeed) ) { - if ( (oreveinPercentageRoll<oreveinPercentage) && (WorldGen_GT_Ore_Layer.sWeight > 0) && (WorldGen_GT_Ore_Layer.sList.size() > 0)) { + if (!validOreveins.containsKey(oreveinSeed)) { + + + Logger.INFO("[World Generation Debug] oreveinPercentageRoll < oreveinPercentage? "+((oreveinPercentageRoll < oreveinPercentage))); + Logger.INFO("[World Generation Debug] WorldGen_GT_Ore_Layer.sWeight > 0? "+(WorldGen_GT_Ore_Layer.sWeight > 0)); + Logger.INFO("[World Generation Debug] WorldGen_GT_Ore_Layer.sList.size() > 0? "+(WorldGen_GT_Ore_Layer.sList.size() > 0)); + if ((oreveinPercentageRoll < oreveinPercentage) && (WorldGen_GT_Ore_Layer.sWeight > 0) + && (WorldGen_GT_Ore_Layer.sList.size() > 0)) { int placementAttempts = 0; boolean oreveinFound = false; int i; - for( i = 0; (i < oreveinAttempts) && (!oreveinFound) && (placementAttempts<oreveinMaxPlacementAttempts); i++ ) { + for (i = 0; (i < oreveinAttempts) && (!oreveinFound) + && (placementAttempts < oreveinMaxPlacementAttempts); i++) { + Logger.INFO("[World Generation Debug] i: "+i); + Logger.INFO("[World Generation Debug] placementAttempts: "+placementAttempts); + Logger.INFO("[World Generation Debug] oreveinAttempts: "+oreveinAttempts); + Logger.INFO("[World Generation Debug] (placementAttempts < oreveinMaxPlacementAttempts): "+(placementAttempts < oreveinMaxPlacementAttempts)); + Logger.INFO("[World Generation Debug] oreveinFound: "+oreveinFound); int tRandomWeight = oreveinRNG.nextInt(WorldGen_GT_Ore_Layer.sWeight); for (WorldGen_GT_Ore_Layer tWorldGen : WorldGen_GT_Ore_Layer.sList) { - tRandomWeight -= ( tWorldGen).mWeight; + Logger.INFO("[World Generation Debug] Iterating sList - Size: "+WorldGen_GT_Ore_Layer.sList.size()); + tRandomWeight -= (tWorldGen).mWeight; if (tRandomWeight <= 0) { - try { - // Adjust the seed so that this layer has a series of unique random numbers. Otherwise multiple attempts at this same oreseed will get the same offset and X/Z values. If an orevein failed, any orevein with the - // same minimum heights would fail as well. This prevents that, giving each orevein a unique height each pass through here. - int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, new XSTR( oreveinSeed ^ (tWorldGen.mPrimaryMeta)), this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, oreseedX*16, oreseedZ*16, this.mChunkGenerator, this.mChunkProvider); - switch(placementResult) { + try { + // Adjust the seed so that this layer has a + // series of unique random numbers. + // Otherwise multiple attempts at this same + // oreseed will get the same offset and X/Z + // values. If an orevein failed, any orevein + // with the + // same minimum heights would fail as well. + // This prevents that, giving each orevein a + // unique height each pass through here. + int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, + new XSTR(oreveinSeed ^ (Block.getIdFromBlock(tWorldGen.mPrimaryMeta))), this.mBiome, + this.mDimensionType, this.mX * 16, this.mZ * 16, oreseedX * 16, + oreseedZ * 16, this.mChunkGenerator, this.mChunkProvider); + switch (placementResult) { case WorldGen_GT_Ore_Layer.ORE_PLACED: - if (debugWorldGen) GT_Log.out.println( - " Added oreveinSeed=" + oreveinSeed + - " tries at oremix=" + i + - " placementAttempts=" + placementAttempts + - " dimensionName=" + tDimensionName - ); + if (debugWorldGen) + GT_Log.out.println(" Added oreveinSeed=" + oreveinSeed + + " tries at oremix=" + i + " placementAttempts=" + + placementAttempts + " dimensionName=" + tDimensionName); validOreveins.put(oreveinSeed, tWorldGen); oreveinFound = true; + Logger.INFO("[World Generation Debug] ORE_PLACED"); break; case WorldGen_GT_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER: placementAttempts++; - // SHould do retry in this case until out of chances + Logger.INFO("[World Generation Debug] NO_ORE_IN_BOTTOM_LAYER | Attempts: "+placementAttempts); + // SHould do retry in this case + // until out of chances break; case WorldGen_GT_Ore_Layer.NO_OVERLAP: - // Orevein didn't reach this chunk, can't add it yet to the hash + // Orevein didn't reach this chunk, + // can't add it yet to the hash + Logger.INFO("[World Generation Debug] NO_OVERLAP"); break; } break; // Try the next orevein - } catch (Throwable e) { - if (debugWorldGen) GT_Log.out.println( - "Exception occurred on oreVein" + tWorldGen + - " oreveinSeed="+ oreveinSeed + - " mX="+ this.mX + - " mZ="+ this.mZ + - " oreseedX="+ oreseedX + - " oreseedZ="+ oreseedZ - ); + } + catch (Throwable e) { + if (debugWorldGen) + GT_Log.out.println("Exception occurred on oreVein" + tWorldGen + " oreveinSeed=" + + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ + " oreseedX=" + + oreseedX + " oreseedZ=" + oreseedZ); e.printStackTrace(GT_Log.err); } } } } - // Only add an empty orevein if are unable to place a vein at the oreseed chunk. - if ((!oreveinFound) && (this.mX == oreseedX) && (this.mZ == oreseedZ)){ - if (debugWorldGen) GT_Log.out.println( - " Empty oreveinSeed="+ oreveinSeed + - " mX="+ this.mX + - " mZ="+ this.mZ + - " oreseedX="+ oreseedX + - " oreseedZ="+ oreseedZ + - " tries at oremix=" + i + - " placementAttempts=" + placementAttempts + - " dimensionName=" + tDimensionName - ); - validOreveins.put(oreveinSeed, noOresInVein ); + // Only add an empty orevein if are unable to place a vein + // at the oreseed chunk. + if ((!oreveinFound) && (this.mX == oreseedX) && (this.mZ == oreseedZ)) { + if (debugWorldGen) + GT_Log.out.println(" Empty oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ + + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " tries at oremix=" + i + + " placementAttempts=" + placementAttempts + " dimensionName=" + tDimensionName); + validOreveins.put(oreveinSeed, noOresInVein); } - } else if(oreveinPercentageRoll >= oreveinPercentage) { - if (debugWorldGen) GT_Log.out.println( - " Skipped oreveinSeed="+ oreveinSeed + - " mX="+ this.mX + - " mZ="+ this.mZ + - " oreseedX=" + oreseedX + - " oreseedZ="+ oreseedZ + - " RNG=" + oreveinPercentageRoll + - " %=" + oreveinPercentage+ - " dimensionName=" + tDimensionName - ); + } + else if (oreveinPercentageRoll >= oreveinPercentage) { + if (debugWorldGen) + GT_Log.out.println(" Skipped oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ + + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " RNG=" + oreveinPercentageRoll + + " %=" + oreveinPercentage + " dimensionName=" + tDimensionName); validOreveins.put(oreveinSeed, noOresInVein); } - }else { + } + else { // oreseed is located in the previously processed table - if (debugWorldGen) GT_Log.out.print( - " Valid oreveinSeed="+ oreveinSeed + - " validOreveins.size()=" + validOreveins.size() + " " - ); + if (debugWorldGen) + GT_Log.out.print(" Valid oreveinSeed=" + oreveinSeed + " validOreveins.size()=" + + validOreveins.size() + " "); WorldGen_GT_Ore_Layer tWorldGen = validOreveins.get(oreveinSeed); - oreveinRNG.setSeed(oreveinSeed ^ (tWorldGen.mPrimaryMeta)); // Reset RNG to only be based on oreseed X/Z and type of vein - int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, oreveinRNG, this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, oreseedX*16, oreseedZ*16, this.mChunkGenerator, this.mChunkProvider); - switch( placementResult ) - { + oreveinRNG.setSeed(oreveinSeed ^ (Block.getIdFromBlock(tWorldGen.mPrimaryMeta))); // Reset + // RNG + // to + // only + // be + // based + // on + // oreseed + // X/Z + // and + // type + // of + // vein + int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, oreveinRNG, this.mBiome, + this.mDimensionType, this.mX * 16, this.mZ * 16, oreseedX * 16, oreseedZ * 16, + this.mChunkGenerator, this.mChunkProvider); + switch (placementResult) { case WorldGen_GT_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER: - if (debugWorldGen) GT_Log.out.println( - " No ore in bottom layer" - ); + if (debugWorldGen) + GT_Log.out.println(" No ore in bottom layer"); break; case WorldGen_GT_Ore_Layer.NO_OVERLAP: - if (debugWorldGen) GT_Log.out.println( - " No overlap" - ); + if (debugWorldGen) + GT_Log.out.println(" No overlap"); } } } @@ -333,62 +386,64 @@ public class WorldGen_GT_Base implements IWorldGenerator{ long startTime = System.nanoTime(); int oreveinMaxSize; - // Determine bounding box on how far out to check for oreveins affecting this chunk - // For now, manually reducing oreveinMaxSize when not in the Underdark for performance - if(this.mWorld.provider.getDimensionName().equals("Underdark") ) { - oreveinMaxSize=32; // Leave Deep Dark/Underdark max oregen at 32, instead of 64 - } else { - oreveinMaxSize=32; + // Determine bounding box on how far out to check for oreveins + // affecting this chunk + // For now, manually reducing oreveinMaxSize when not in the + // Underdark for performance + if (this.mWorld.provider.getDimensionName().equals("Underdark")) { + oreveinMaxSize = 32; // Leave Deep Dark/Underdark max oregen at + // 32, instead of 64 + } + else { + oreveinMaxSize = 32; } - int wXbox = this.mX - (oreveinMaxSize/16); - int eXbox = this.mX + (oreveinMaxSize/16 + 1); // Need to add 1 since it is compared using a < - int nZbox = this.mZ - (oreveinMaxSize/16); - int sZbox = this.mZ + (oreveinMaxSize/16 + 1); + int wXbox = this.mX - (oreveinMaxSize / 16); + int eXbox = this.mX + (oreveinMaxSize / 16 + 1); // Need to add 1 + // since it is + // compared + // using a < + int nZbox = this.mZ - (oreveinMaxSize / 16); + int sZbox = this.mZ + (oreveinMaxSize / 16 + 1); // Search for orevein seeds and add to the list; - for( int x = wXbox; x < eXbox; x++ ) { - for( int z = nZbox; z < sZbox; z++ ) { + for (int x = wXbox; x < eXbox; x++) { + for (int z = nZbox; z < sZbox; z++) { // Determine if this X/Z is an orevein seed - if ( ( (Math.abs(x)%3) == 1) && ( (Math.abs(z)%3) == 1 ) ) { - if (debugWorldGen) GT_Log.out.println( - "Adding seed x="+x+ - " z="+z - ); - seedList.add( new NearbySeeds(x,z) ); + if (((Math.abs(x) % 3) == 1) && ((Math.abs(z) % 3) == 1)) { + if (debugWorldGen) + GT_Log.out.println("Adding seed x=" + x + " z=" + z); + seedList.add(new NearbySeeds(x, z)); } } } // Now process each oreseed vs this requested chunk - for( ; seedList.size() != 0; seedList.remove(0) ) { - if (debugWorldGen) GT_Log.out.println( - "Processing seed x="+seedList.get(0).mX+ - " z="+seedList.get(0).mZ - ); - worldGenFindVein( seedList.get(0).mX, seedList.get(0).mZ ); + for (; seedList.size() != 0; seedList.remove(0)) { + if (debugWorldGen) + GT_Log.out.println("Processing seed x=" + seedList.get(0).mX + " z=" + seedList.get(0).mZ); + worldGenFindVein(seedList.get(0).mX, seedList.get(0).mZ); } long oregenTime = System.nanoTime(); // Do leftover worldgen for this chunk (GT_Stones and GT_small_ores) try { - for (GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) { + for (WorldGen_GT tWorldGen : HANDLER_GT.sWorldgenList) { /* - if (debugWorldGen) GT_Log.out.println( - "tWorldGen.mWorldGenName="+tWorldGen.mWorldGenName - ); + * if (debugWorldGen) GT_Log.out.println( + * "tWorldGen.mWorldGenName="+tWorldGen.mWorldGenName ); */ - tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, this.mChunkGenerator, this.mChunkProvider); + tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, this.mX * 16, + this.mZ * 16, this.mChunkGenerator, this.mChunkProvider); } - } catch (Throwable e) { + } + catch (Throwable e) { e.printStackTrace(GT_Log.err); } long leftOverTime = System.nanoTime(); - - Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ); if (tChunk != null) { tChunk.isModified = true; @@ -396,17 +451,10 @@ public class WorldGen_GT_Base implements IWorldGenerator{ long endTime = System.nanoTime(); long duration = (endTime - startTime); if (debugWorldGen) { - GT_Log.out.println( - " Oregen took " + (oregenTime-startTime)+ - " Leftover gen took " + (leftOverTime - oregenTime ) + - " Worldgen took " + duration + - " nanoseconds" - ); + GT_Log.out.println(" Oregen took " + (oregenTime - startTime) + " Leftover gen took " + + (leftOverTime - oregenTime) + " Worldgen took " + duration + " nanoseconds"); } } } - } - - diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Ore_Layer.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Ore_Layer.java index 3f2673a770..74ef604a56 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Ore_Layer.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Ore_Layer.java @@ -5,18 +5,23 @@ import static gtPlusPlus.core.world.darkworld.gen.gt.WorldGen_GT_Base.debugWorld import java.util.ArrayList; import java.util.Random; -import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Log; -import gregtech.api.world.GT_Worldgen; +import gregtech.common.blocks.GT_Block_Ores; import gregtech.common.blocks.GT_TileEntity_Ores; -import gregtech.loaders.misc.GT_Achievements; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; public class WorldGen_GT_Ore_Layer - extends GT_Worldgen { + extends WorldGen_GT { public static ArrayList<WorldGen_GT_Ore_Layer> sList = new ArrayList<WorldGen_GT_Ore_Layer>(); public static int sWeight = 0; public final short mMinY; @@ -24,10 +29,16 @@ public class WorldGen_GT_Ore_Layer public final short mWeight; public final short mDensity; public final short mSize; - public final short mPrimaryMeta; - public final short mSecondaryMeta; - public final short mBetweenMeta; - public final short mSporadicMeta; + public Block mPrimaryMeta; + public Block mSecondaryMeta; + public Block mBetweenMeta; + public Block mSporadicMeta; + public final Material mPrimary; + public final Material mSecondary; + public final Material mBetween; + public final Material mSporadic; + + //public final String mBiome; public final String mRestrictBiome; public final boolean mOverworld; @@ -45,16 +56,22 @@ public class WorldGen_GT_Ore_Layer //public final boolean mAsteroid; public final String aTextWorldgen = "worldgen."; - public WorldGen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, boolean aOverworld, boolean aNether, boolean aEnd, boolean GC_UNUSED1, boolean GC_UNUSED2, boolean GC_UNUSED3, Materials aPrimary, Materials aSecondary, Materials aBetween, Materials aSporadic) { + public WorldGen_GT_Ore_Layer(String aName, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic) { + this(aName, true, aMinY, aMaxY, aWeight, aDensity, aSize, false, false, false, false, false, false, aPrimary, aSecondary, aBetween, aSporadic); + } + + + public WorldGen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, boolean aOverworld, boolean aNether, boolean aEnd, boolean GC_UNUSED1, boolean GC_UNUSED2, boolean GC_UNUSED3, Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic) { super(aName, sList, aDefault); - this.mOverworld = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); - this.mNether = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Nether", aNether); - this.mEnd = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "TheEnd", aEnd); - //this.mMoon = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Moon", aMoon); - //this.mMars = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Mars", aMars); - //this.mAsteroid = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid); - this.mMinY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); - short mMaxY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY)); + Logger.WORLD("Creating Ore Layer Object"); + this.mOverworld = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); + this.mNether = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Nether", aNether); + this.mEnd = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "TheEnd", aEnd); + //this.mMoon = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Moon", aMoon); + //this.mMars = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Mars", aMars); + //this.mAsteroid = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid); + this.mMinY = ((short) HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); + short mMaxY = ((short) HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY)); if (mMaxY < (this.mMinY + 7)) { GT_Log.out.println( "Oremix " + this.mWorldGenName + @@ -63,14 +80,18 @@ public class WorldGen_GT_Ore_Layer mMaxY = (short) (this.mMinY + 7); } this.mMaxY = mMaxY; - this.mWeight = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); - this.mDensity = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); - this.mSize = ((short) Math.max(1, GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); - this.mPrimaryMeta = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); - this.mSecondaryMeta = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); - this.mBetweenMeta = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); - this.mSporadicMeta = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); - this.mRestrictBiome = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); + this.mWeight = ((short) HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + this.mPrimary = aPrimary; + this.mSecondary = aSecondary; + this.mBetween = aBetween; + this.mSporadic = aSporadic; + this.mPrimaryMeta = aPrimary.getOreBlock(1); + this.mSecondaryMeta = aSecondary.getOreBlock(1); + this.mBetweenMeta = aBetween.getOreBlock(1); + this.mSporadicMeta = aSporadic.getOreBlock(1); + this.mRestrictBiome = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); //if (mPrimaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mPrimaryMeta + " for " + mWorldGenName + " does not exist"); //if (mSecondaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mSecondaryMeta + " for " + mWorldGenName + " does not exist"); @@ -78,23 +99,39 @@ public class WorldGen_GT_Ore_Layer //if (mPrimaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mSporadicMeta + " for " + mWorldGenName + " does not exist"); if (this.mEnabled) { - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); + //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); + //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); + //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); + //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); sWeight += this.mWeight; } } public int executeWorldgenChunkified(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, int aSeedX, int aSeedZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - if( mWorldGenName.equals("NoOresInVein") ) { + + //Debug Handler + /** + * This handles Variables that are null during Init + */ + + if (this.mPrimaryMeta == Blocks.stone || this.mSecondaryMeta == Blocks.stone + || this.mBetweenMeta == Blocks.stone || this.mSporadicMeta == Blocks.stone){ + this.mPrimaryMeta = this.mPrimary.getOreBlock(1); + this.mSecondaryMeta = this.mSecondary.getOreBlock(1); + this.mBetweenMeta = this.mBetween.getOreBlock(1); + this.mSporadicMeta = this.mSporadic.getOreBlock(1); + Logger.WORLD("[Vein Generator] An Ore in a Vein had defaulted back to a default value, so they have now been reset to correct values."); + } + + if( mWorldGenName.equals("vein0") ) { if (debugWorldGen) GT_Log.out.println( - " NoOresInVein" + " NoOresInVein-vein0" ); // This is a special empty orevein + Logger.WORLD("[World Generation Debug] Special Empty Vein placed."); return ORE_PLACED; } - if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld)) || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) { + if (aDimensionType != Dimension_DarkWorld.DIMID) { /* // Debug code, but spams log if (debugWorldGen) { GT_Log.out.println( @@ -102,6 +139,7 @@ public class WorldGen_GT_Ore_Layer ); } */ + Logger.WORLD("[World Generation Debug] Wrong dimension."); return WRONG_DIMENSION; } if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { @@ -152,35 +190,36 @@ public class WorldGen_GT_Ore_Layer int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); for (int tZ = nZ; tZ < sZ; tZ++) { int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta > 0) ) { - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) { + if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta != null) ) { + if (setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) { placeCount[1]++; } } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) + else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; } } } - if ((placeCount[1]+placeCount[3])==0) { + /*if ((placeCount[1]+placeCount[3])==0) { if (debugWorldGen) GT_Log.out.println( " No ore in bottom layer" ); return NO_ORE_IN_BOTTOM_LAYER; // Exit early, didn't place anything in the bottom layer - } + }*/ + Logger.WORLD("[World Generation Debug] Trying to set Ores?"); for (level = tMinY; level < (tMinY-1+3); level++) { for (int tX = wX; tX < eX; tX++) { int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); for (int tZ = nZ; tZ < sZ; tZ++) { int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta > 0) ) { - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) { + if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta != null) ) { + if (setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) { placeCount[1]++; } } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) + else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; } } @@ -192,13 +231,13 @@ public class WorldGen_GT_Ore_Layer int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); for (int tZ = nZ; tZ < sZ; tZ++) { int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { + if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta != null) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { placeCount[2]++; } } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) + else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; } } @@ -209,18 +248,18 @@ public class WorldGen_GT_Ore_Layer int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); for (int tZ = nZ; tZ < sZ; tZ++) { int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { + if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta != null) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { placeCount[2]++; } } - else if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta > 0) ) { - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) { + else if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta != null) ) { + if (setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) { placeCount[0]++; } } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) + else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; } } @@ -232,13 +271,13 @@ public class WorldGen_GT_Ore_Layer int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity); for (int tZ = nZ; tZ < sZ; tZ++) { int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity); - if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta > 0) ) { - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) { + if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta != null) ) { + if (setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) { placeCount[0]++; } } - else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) + else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) placeCount[3]++; } } @@ -269,4 +308,82 @@ public class WorldGen_GT_Ore_Layer // Something (at least the bottom layer must have 1 block) must have been placed, return true return ORE_PLACED; } + + @SuppressWarnings("deprecation") + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, Block aMetaData, boolean isSmallOre, + boolean air) { + if (!air) { + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + } + + //Set GT ORE + if (aMetaData instanceof GT_Block_Ores){ + + if (this.mPrimaryMeta == aMetaData){ + for (Materials f : Materials.values()){ + if (Utils.sanitizeString(f.name().toLowerCase()).contains(Utils.sanitizeString(this.mPrimary.getLocalizedName().toLowerCase()))){ + int r = f.mMetaItemSubID; + if (GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, r, false)){ + Logger.WORLD("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ); + return true; + } + } + } + } + if (this.mSecondaryMeta == aMetaData){ + for (Materials f : Materials.values()){ + if (Utils.sanitizeString(f.name().toLowerCase()).contains(Utils.sanitizeString(this.mSecondary.getLocalizedName().toLowerCase()))){ + int r = f.mMetaItemSubID; + if (GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, r, false)){ + Logger.WORLD("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ); + return true; + } + } + } + } + if (this.mBetweenMeta == aMetaData){ + for (Materials f : Materials.values()){ + if (Utils.sanitizeString(f.name().toLowerCase()).contains(Utils.sanitizeString(this.mBetween.getLocalizedName().toLowerCase()))){ + int r = f.mMetaItemSubID; + if (GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, r, false)){ + Logger.WORLD("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ); + return true; + } + } + } + } + if (this.mSporadicMeta == aMetaData){ + for (Materials f : Materials.values()){ + if (Utils.sanitizeString(f.name().toLowerCase()).contains(Utils.sanitizeString(this.mSporadic.getLocalizedName().toLowerCase()))){ + int r = f.mMetaItemSubID; + if (GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, r, false)){ + Logger.WORLD("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ); + return true; + } + } + } + } + + } + + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = aMetaData; + int BlockMeta = aWorld.getBlockMetadata(aX, aY, aZ); + String BlockName = tBlock.getUnlocalizedName(); + if ( + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.sand) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.dirt) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_DarkWorld.blockTopLayer) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_DarkWorld.blockSecondLayer) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_DarkWorld.blockMainFiller) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_DarkWorld.blockSecondaryFiller) || + tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.sandstone)) { + if (aWorld.setBlock(aX, aY, aZ, tOreBlock, 0, 3)){ + Logger.WORLD("[World Generation Debug] Set "+tOreBlock.getLocalizedName()+" at X: "+aX+" | Y: "+aY+" | Z: "+aZ); + return true; + } + } + return false; + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java index 76ccfdcc80..4b099ee4cf 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java @@ -1,6 +1,16 @@ package gtPlusPlus.core.world.darkworld.gen.gt; +import java.util.Hashtable; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gtPlusPlus.api.objects.MaterialHelper; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.ORES; +import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.world.darkworld.object.BoxedQuad; import net.minecraft.block.Block; @@ -42,12 +52,276 @@ public class WorldGen_Ores { public static volatile Pair<Block, Integer> Florencite; // SmAl3(PO4)2(OH)6 public static volatile Pair<Block, Integer> Cryolite; // Na3AlF6 //public static volatile Pair<Block, Integer> Pyroxene; // + + private static final Material PYRITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Pyrite); + private static final Material PYROPE = MaterialUtils.generateMaterialFromGtENUM(Materials.Pyrope); + private static final Material ALMANDINE = MaterialUtils.generateMaterialFromGtENUM(Materials.Almandine); + private static final Material RUBY = MaterialUtils.generateMaterialFromGtENUM(Materials.Ruby); + private static final Material CHALCOPYRITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Chalcopyrite); + private static final Material PLATINUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Platinum); + private static final Material TOPAZ = MaterialUtils.generateMaterialFromGtENUM(Materials.Topaz); + private static final Material SAPPHIRE_GREEN = MaterialUtils.generateMaterialFromGtENUM(Materials.GreenSapphire); + private static final Material SAPPHIRE_BLUE = MaterialUtils.generateMaterialFromGtENUM(Materials.Sapphire); + private static final Material BAUXITE = MaterialUtils.generateMaterialFromGtENUM(Materials.Bauxite); + + private static final Material NAQPLUS = MaterialUtils.generateMaterialFromGtENUM(Materials.NaquadahEnriched); + private static final Material NAQUADRIA = MaterialUtils.generateMaterialFromGtENUM(Materials.Naquadria); + private static final Material OSMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Osmium); + private static final Material AMETHYST = MaterialUtils.generateMaterialFromGtENUM(Materials.Amethyst); + private static final Material BISMUTH = MaterialUtils.generateMaterialFromGtENUM(Materials.Bismuth); + private static final Material PLUTONIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Plutonium); + private static final Material URNAIUM235 = MaterialUtils.generateMaterialFromGtENUM(Materials.Uranium235); + private static final Material INFUSEDGOLD = MaterialUtils.generateMaterialFromGtENUM(Materials.InfusedGold); + + + + public static WorldGen_GT_Ore_Layer BaseVein = new WorldGen_GT_Ore_Layer( + "veinA", + 20, 40, + 1, + 8, + 128, + ELEMENT.getInstance().ALUMINIUM, + ELEMENT.getInstance().SILICON, + ELEMENT.getInstance().COPPER, + ELEMENT.getInstance().LEAD); + + + + /** + * Custom ore Veins + */ + + public static WorldGen_GT_Ore_Layer Vein1 = new WorldGen_GT_Ore_Layer( + "vein1", + 0, 60, + 30, + 16, + 16, + ORES.AGARDITE_CD, + ORES.AGARDITE_LA, + ELEMENT.getInstance().SILICON, + ELEMENT.getInstance().BERYLLIUM); + + public static WorldGen_GT_Ore_Layer Vein2 = new WorldGen_GT_Ore_Layer( + "vein2", + 0, 60, + 30, + 16, + 16, + ORES.AGARDITE_ND, + ORES.AGARDITE_Y, + PYRITE, + ORES.CERITE); + + public static WorldGen_GT_Ore_Layer Vein3 = new WorldGen_GT_Ore_Layer( + "vein3", + 0, 60, + 30, + 16, + 32, + ORES.CERITE, + ORES.NICHROMITE, + PYROPE, + ORES.HIBONITE); + + public static WorldGen_GT_Ore_Layer Vein4 = new WorldGen_GT_Ore_Layer( + "vein4", + 0, 60, + 40, + 16, + 32, + ORES.GEIKIELITE, + ORES.CRYOLITE, + ORES.GADOLINITE_CE, + RUBY); + + + + public static WorldGen_GT_Ore_Layer Vein5 = new WorldGen_GT_Ore_Layer( + "vein5", + 30, 128, + 20, + 8, + 64, + ORES.HIBONITE, + ORES.YTTRIALITE, + ORES.ZIRCONILITE, + ORES.CERITE); + public static WorldGen_GT_Ore_Layer Vein6 = new WorldGen_GT_Ore_Layer( + "vein6", + 0, 40, + 20, + 8, + 64, + ORES.XENOTIME, + ORES.ZIRKELITE, + ORES.CROCROITE, + ALMANDINE); + public static WorldGen_GT_Ore_Layer Vein7 = new WorldGen_GT_Ore_Layer( + "vein7", + 40, 128, + 20, + 8, + 64, + RUBY, + TOPAZ, + ORES.SAMARSKITE_Y, + ORES.SAMARSKITE_YB); + public static WorldGen_GT_Ore_Layer Vein8 = new WorldGen_GT_Ore_Layer( + "vein8", + 0, 40, + 20, + 8, + 64, + ORES.TITANITE, + ORES.ZIMBABWEITE, + ORES.ZIRCON, + ORES.FLORENCITE); + + + + + public static WorldGen_GT_Ore_Layer Vein9 = new WorldGen_GT_Ore_Layer( + "vein9", + 10, 30, + 20, + 4, + 64, + ORES.LANTHANITE_CE, + FLUORIDES.FLUORITE, + PLATINUM, + ORES.FLORENCITE); + public static WorldGen_GT_Ore_Layer Vein10 = new WorldGen_GT_Ore_Layer( + "vein10", + 20, 50, + 20, + 8, + 32, + ORES.GEIKIELITE, + ORES.YTTROCERITE, + ORES.LANTHANITE_LA, + BAUXITE); + public static WorldGen_GT_Ore_Layer Vein11 = new WorldGen_GT_Ore_Layer( + "vein11", + 30, 70, + 20, + 5, + 64, + FLUORIDES.FLUORITE, + SAPPHIRE_BLUE, + ORES.ZIRCON, + ORES.CRYOLITE); + public static WorldGen_GT_Ore_Layer Vein12 = new WorldGen_GT_Ore_Layer( + "vein12", + 40, 80, + 20, + 8, + 32, + ORES.CERITE, + SAPPHIRE_GREEN, + CHALCOPYRITE, + ORES.HIBONITE); + + /** + * Best Rarest Veins 2017 + */ + + public static WorldGen_GT_Ore_Layer Vein13 = new WorldGen_GT_Ore_Layer( + "vein13", + 5, 15, + 5, + 5, + 16, + ORES.CRYOLITE, + NAQPLUS, + NAQUADRIA, + ORES.FLORENCITE); + + public static WorldGen_GT_Ore_Layer Vein14 = new WorldGen_GT_Ore_Layer( + "vein14", + 10, 20, + 8, + 3, + 16, + URNAIUM235, + PLUTONIUM, + OSMIUM, + AMETHYST); + + public static WorldGen_GT_Ore_Layer Vein15 = new WorldGen_GT_Ore_Layer( + "vein15", + 5, 25, + 5, + 6, + 24, + ORES.FLUORCAPHITE, + BISMUTH, + ORES.GADOLINITE_CE, + ORES.GADOLINITE_Y); + + public static WorldGen_GT_Ore_Layer Vein16 = new WorldGen_GT_Ore_Layer( + "vein16", + 0, 25, + 4, + 6, + 32, + ORES.YTTROCERITE, + ORES.LEPERSONNITE, + INFUSEDGOLD, + FLUORIDES.FLUORITE); + + public static WorldGen_GT_Ore_Layer Vein17 = new WorldGen_GT_Ore_Layer( + "vein17", + 10, 35, + 4, + 5, + 32, + ORES.FLORENCITE, + URNAIUM235, + ORES.SAMARSKITE_YB, + ORES.POLYCRASE); + public static WorldGen_GT_Ore_Layer Vein18 = new WorldGen_GT_Ore_Layer( + "vein18", + 15, 40, + 4, + 4, + 64, + ORES.GADOLINITE_CE, + ORES.GADOLINITE_Y, + ORES.AGARDITE_LA, + ORES.AGARDITE_CD); + + public static Hashtable<Long, WorldGen_GT_Ore_Layer> validOreveins = new Hashtable<Long, WorldGen_GT_Ore_Layer>( + 1024); public static volatile BoxedQuad<Integer, Integer, Integer, Integer> OreVein1 = new BoxedQuad(null, null, null, null); + static long ID = 0; + public static void generateValidOreVeins(){ + validOreveins.put(ID++, BaseVein); + validOreveins.put(ID++, Vein1); + validOreveins.put(ID++, Vein2); + validOreveins.put(ID++, Vein3); + validOreveins.put(ID++, Vein4); + validOreveins.put(ID++, Vein5); + validOreveins.put(ID++, Vein6); + validOreveins.put(ID++, Vein7); + validOreveins.put(ID++, Vein8); + validOreveins.put(ID++, Vein9); + validOreveins.put(ID++, Vein10); + validOreveins.put(ID++, Vein11); + validOreveins.put(ID++, Vein12); + validOreveins.put(ID++, Vein13); + validOreveins.put(ID++, Vein14); + validOreveins.put(ID++, Vein15); + validOreveins.put(ID++, Vein16); + validOreveins.put(ID++, Vein17); + validOreveins.put(ID++, Vein18); + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 594c32d80d..9945665705 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -8,6 +8,7 @@ import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.OldCircuitHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; +import gtPlusPlus.core.world.darkworld.gen.gt.WorldGen_GT; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; @@ -23,6 +24,7 @@ public class HANDLER_GT { public static GT_Config mMaterialProperties = null; public static GTPP_Config sCustomWorldgenFile = null; + public static final List<WorldGen_GT> sWorldgenList = new ArrayList<WorldGen_GT>(); public static final List<GTPP_Worldgen> sCustomWorldgenList = new ArrayList<GTPP_Worldgen>(); public static void preInit(){ |