diff options
| author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
| commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
| tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/xmod/gregtech/api/world | |
| parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
| download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip | |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/api/world')
8 files changed, 530 insertions, 257 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java index 795fd18826..6f58823eb1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java @@ -6,11 +6,10 @@ import java.util.List; import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; - import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; -public abstract class GTPP_Worldgen{ +public abstract class GTPP_Worldgen { public final String mWorldGenName; public final boolean mEnabled; @@ -31,7 +30,15 @@ public abstract class GTPP_Worldgen{ * @param aChunkZ zCoord of the Chunk * @return if the Worldgeneration has been successfully completed */ - public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + public boolean executeWorldgen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { return false; } @@ -44,7 +51,15 @@ public abstract class GTPP_Worldgen{ * @param aChunkZ zCoord of the Chunk * @return if the Worldgeneration has been successfully completed */ - public boolean executeCavegen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + public boolean executeCavegen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { return false; } @@ -52,10 +67,11 @@ public abstract class GTPP_Worldgen{ String aDimName = aWorld.provider.getDimensionName(); Boolean tAllowed = mDimensionMap.get(aDimName); if (tAllowed == null) { - boolean tValue = sCustomWorldgenFile.get("worldgen.dimensions." + mWorldGenName, aDimName, aDimensionType == aAllowedDimensionType); + boolean tValue = sCustomWorldgenFile.get( + "worldgen.dimensions." + mWorldGenName, aDimName, aDimensionType == aAllowedDimensionType); mDimensionMap.put(aDimName, tValue); return tValue; } return tAllowed; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java index ca78a72e04..26f1b38084 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java @@ -1,9 +1,8 @@ package gtPlusPlus.xmod.gregtech.api.world; +import gtPlusPlus.core.lib.CORE; import java.util.Collection; import java.util.Random; - -import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.util.MathHelper; @@ -11,26 +10,69 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; public class GTPP_Worldgen_Boulder extends GTPP_Worldgen_Ore { - public GTPP_Worldgen_Boulder(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) { - super(aName, aDefault, aBlock, aBlockMeta, aDimensionType, aAmount, aSize, aProbability, aMinY, aMaxY, aBiomeList, aAllowToGenerateinVoid); + public GTPP_Worldgen_Boulder( + String aName, + boolean aDefault, + Block aBlock, + int aBlockMeta, + int aDimensionType, + int aAmount, + int aSize, + int aProbability, + int aMinY, + int aMaxY, + Collection<String> aBiomeList, + boolean aAllowToGenerateinVoid) { + super( + aName, + aDefault, + aBlock, + aBlockMeta, + aDimensionType, + aAmount, + aSize, + aProbability, + aMinY, + aMaxY, + aBiomeList, + aAllowToGenerateinVoid); } @Override - public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - if (isGenerationAllowed(aWorld, aDimensionType, mDimensionType) && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome)) && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) { + public boolean executeWorldgen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + if (isGenerationAllowed(aWorld, aDimensionType, mDimensionType) + && (mBiomeList.isEmpty() || mBiomeList.contains(aBiome)) + && (mProbability <= 1 || aRandom.nextInt(mProbability) == 0)) { for (int i = 0; i < mAmount; i++) { - int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); + int tX = aChunkX + aRandom.nextInt(16), + tY = mMinY + aRandom.nextInt(mMaxY - mMinY), + tZ = aChunkZ + aRandom.nextInt(16); Block tBlock = aWorld.getBlock(tX, tY - 7, tZ); - if (tBlock != null && tBlock.isOpaqueCube() && aWorld.getBlock(tX, tY - 6, tZ).isAir(aWorld, tX, tY - 6, tZ)) { + if (tBlock != null + && tBlock.isOpaqueCube() + && aWorld.getBlock(tX, tY - 6, tZ).isAir(aWorld, tX, tY - 6, tZ)) { float math_pi = CORE.PI; float var6 = aRandom.nextFloat() * math_pi; float var1b = mSize / 8.0F; - float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; - float var8b = -2*var3b;float var9b = -2*var4b; - int var10b = (tX + 8);int var11b = (tZ + 8); + float var3b = MathHelper.sin(var6) * var1b; + float var4b = MathHelper.cos(var6) * var1b; + float var8b = -2 * var3b; + float var9b = -2 * var4b; + int var10b = (tX + 8); + int var11b = (tZ + 8); float var7 = (var10b + var3b); float var11 = (var11b + var4b); - int var5b = aRandom.nextInt(3);int var6b = aRandom.nextInt(3);int var7b = var6b - var5b; + int var5b = aRandom.nextInt(3); + int var6b = aRandom.nextInt(3); + int var7b = var6b - var5b; float var15 = (tY + var5b - 2); float var12b = math_pi / mSize; @@ -59,7 +101,11 @@ public class GTPP_Worldgen_Boulder extends GTPP_Worldgen_Ore { for (int var44 = var34; var44 <= var37; ++var44) { float var45 = (var44 + 0.5F - var24) / (var28); Block block = aWorld.getBlock(var38, var41, var44); - if (var14b + var45 * var45 < 1.0F && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && !(block instanceof BlockContainer)))) { + if (var14b + var45 * var45 < 1.0F + && ((mAllowToGenerateinVoid + && aWorld.getBlock(var38, var41, var44) + .isAir(aWorld, var38, var41, var44)) + || (block != null && !(block instanceof BlockContainer)))) { aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); } } @@ -74,4 +120,4 @@ public class GTPP_Worldgen_Boulder extends GTPP_Worldgen_Ore { } return false; } -}
\ No newline at end of file +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java index 7cd215aa4e..0dbd354547 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java @@ -2,166 +2,274 @@ package gtPlusPlus.xmod.gregtech.api.world; import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.common.blocks.GT_TileEntity_Ores; +import gregtech.loaders.misc.GT_Achievements; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Random; - import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Materials; -import gregtech.common.blocks.GT_TileEntity_Ores; -import gregtech.loaders.misc.GT_Achievements; +public class GTPP_Worldgen_GT_Ore_Layer extends GTPP_Worldgen { + public static ArrayList<GTPP_Worldgen_GT_Ore_Layer> sList = new ArrayList<GTPP_Worldgen_GT_Ore_Layer>(); + public static int sWeight = 0; + public final short mMinY; + public final short mMaxY; + public final short mWeight; + public final short mDensity; + public final short mSize; + public short mPrimaryMeta; + public short mSecondaryMeta; + public short mBetweenMeta; + public short mSporadicMeta; + public final String mRestrictBiome; + public final boolean mDarkWorld; + public final String aTextWorldgen = "worldgen.gtpp."; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; + public GTPP_Worldgen_GT_Ore_Layer( + String aName, + boolean aDefault, + int aMinY, + int aMaxY, + int aWeight, + int aDensity, + int aSize, + boolean aOverworld, + Materials aPrimary, + Materials aSecondary, + Materials aBetween, + Materials aSporadic) { + super(aName, sList, aDefault); + this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); + this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); + this.mMaxY = ((short) Math.max( + this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); + this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + this.mPrimaryMeta = ((short) sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); + this.mSecondaryMeta = ((short) sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); + this.mBetweenMeta = ((short) sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); + this.mSporadicMeta = ((short) sCustomWorldgenFile.get( + aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); + this.mRestrictBiome = + sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); -public class GTPP_Worldgen_GT_Ore_Layer -extends GTPP_Worldgen { - public static ArrayList<GTPP_Worldgen_GT_Ore_Layer> sList = new ArrayList<GTPP_Worldgen_GT_Ore_Layer>(); - public static int sWeight = 0; - public final short mMinY; - public final short mMaxY; - public final short mWeight; - public final short mDensity; - public final short mSize; - public short mPrimaryMeta; - public short mSecondaryMeta; - public short mBetweenMeta; - public short mSporadicMeta; - public final String mRestrictBiome; - public final boolean mDarkWorld; - public final String aTextWorldgen = "worldgen.gtpp."; + if (this.mEnabled) { + GT_Achievements.registerOre( + GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], + aMinY, + aMaxY, + aWeight, + false, + false, + false); + GT_Achievements.registerOre( + GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], + aMinY, + aMaxY, + aWeight, + false, + false, + false); + GT_Achievements.registerOre( + GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], + aMinY, + aMaxY, + aWeight, + false, + false, + false); + GT_Achievements.registerOre( + GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], + aMinY, + aMaxY, + aWeight, + false, + false, + false); + sWeight += this.mWeight; + } + } - public GTPP_Worldgen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, boolean aOverworld, Materials aPrimary, Materials aSecondary, Materials aBetween, Materials aSporadic) { - super(aName, sList, aDefault); - this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld); - this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); - this.mMaxY = ((short) Math.max(this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); - this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); - this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); - this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); - this.mPrimaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); - this.mSecondaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); - this.mBetweenMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); - this.mSporadicMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); - this.mRestrictBiome = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); + public GTPP_Worldgen_GT_Ore_Layer( + String aName, + boolean aDefault, + int aMinY, + int aMaxY, + int aWeight, + int aDensity, + int aSize, + Material aPrimary, + Material aSecondary, + Material aBetween, + Material aSporadic) { + super(aName, sList, aDefault); + this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Darkworld", true); + this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); + this.mMaxY = ((short) Math.max( + this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); + this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); + this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); + this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); + /*this.mPrimaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); + this.mSecondaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); + this.mBetweenMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); + this.mSporadicMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); + */ this.mRestrictBiome = + sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); - if (this.mEnabled) { - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - sWeight += this.mWeight; - } - } + if (this.mEnabled) { + /* GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); + */ sWeight += this.mWeight; + } + } - public GTPP_Worldgen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, - int aSize, Material aPrimary, Material aSecondary, Material aBetween, - Material aSporadic) { - super(aName, sList, aDefault); - this.mDarkWorld = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Darkworld", true); - this.mMinY = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); - this.mMaxY = ((short) Math.max(this.mMinY + 5, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY))); - this.mWeight = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight)); - this.mDensity = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity)); - this.mSize = ((short) Math.max(1, sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize))); - /*this.mPrimaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OrePrimaryLayer", aPrimary.mMetaItemSubID)); - this.mSecondaryMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSecondaryLayer", aSecondary.mMetaItemSubID)); - this.mBetweenMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporadiclyInbetween", aBetween.mMetaItemSubID)); - this.mSporadicMeta = ((short) sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "OreSporaticlyAround", aSporadic.mMetaItemSubID)); - */this.mRestrictBiome = sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None"); + @Override + public boolean executeWorldgen( + World aWorld, + Random aRandom, + String aBiome, + int aDimensionType, + int aChunkX, + int aChunkZ, + IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { + return false; // Not the correct biome for ore mix + } + if (!isGenerationAllowed( + aWorld, + aDimensionType, + ((aDimensionType == -1) && (false)) + || ((aDimensionType == 0) && (this.mDarkWorld)) + || ((aDimensionType == 1) && (false)) + || ((aWorld.provider.getDimensionName().equals("Moon")) && (false)) + || ((aWorld.provider.getDimensionName().equals("Mars")) && (false)) + ? aDimensionType + : aDimensionType ^ 0xFFFFFFFF)) { + return false; + } + int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); - if (this.mEnabled) { - /* GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, false, false, false); - */ sWeight += this.mWeight; - } - } + int cX = aChunkX - aRandom.nextInt(this.mSize); + int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); + for (int tX = cX; tX <= eX; tX++) { + int cZ = aChunkZ - aRandom.nextInt(this.mSize); + int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); + for (int tZ = cZ; tZ <= eZ; tZ++) { + if (this.mSecondaryMeta > 0) { + for (int i = tMinY - 1; i < tMinY + 2; i++) { + if ((aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) + / this.mDensity)) + == 0) + || (aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) + / this.mDensity)) + == 0)) { + setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); + } + } + } + if ((this.mBetweenMeta > 0) + && ((aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) + / this.mDensity)) + == 0) + || (aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) + / this.mDensity)) + == 0))) { + setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); + } + if (this.mPrimaryMeta > 0) { + for (int i = tMinY + 3; i < tMinY + 6; i++) { + if ((aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) + / this.mDensity)) + == 0) + || (aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) + / this.mDensity)) + == 0)) { + setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); + } + } + } + if ((this.mSporadicMeta > 0) + && ((aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) + / this.mDensity)) + == 0) + || (aRandom.nextInt(Math.max( + 1, + Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) + / this.mDensity)) + == 0))) { + setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + } + } + } + if (GT_Values.D1) { + System.out.println("Generated Orevein: " + this.mWorldGenName + " " + aChunkX + " " + aChunkZ); + } + return true; + } - @Override - public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { - return false; //Not the correct biome for ore mix - } - if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (false)) || ((aDimensionType == 0) && (this.mDarkWorld)) || ((aDimensionType == 1) && (false)) || ((aWorld.provider.getDimensionName().equals("Moon")) && (false)) || ((aWorld.provider.getDimensionName().equals("Mars")) && (false)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) { - return false; - } - int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); + private Method mSetOre = null; - int cX = aChunkX - aRandom.nextInt(this.mSize); - int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); - for (int tX = cX; tX <= eX; tX++) { - int cZ = aChunkZ - aRandom.nextInt(this.mSize); - int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); - for (int tZ = cZ; tZ <= eZ; tZ++) { - if (this.mSecondaryMeta > 0) { - for (int i = tMinY - 1; i < tMinY + 2; i++) { - if ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { - setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); - } - } - } - if ((this.mBetweenMeta > 0) && ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0))) { - setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); - } - if (this.mPrimaryMeta > 0) { - for (int i = tMinY + 3; i < tMinY + 6; i++) { - if ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { - setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); - } - } - } - if ((this.mSporadicMeta > 0) && ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0))) { - setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); - } - } - } - if (GT_Values.D1) { - System.out.println("Generated Orevein: " + this.mWorldGenName+" "+aChunkX +" "+ aChunkZ); - } - return true; - } - private Method mSetOre = null; - private boolean setOreBlock(World world, int x, int y, int z, int secondarymeta, boolean bool){ + private boolean setOreBlock(World world, int x, int y, int z, int secondarymeta, boolean bool) { - if (mSetOre == null){ - try { - mSetOre = GT_TileEntity_Ores.class.getMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class, boolean.class); - } - catch (SecurityException | NoSuchMethodException e) { - try { - mSetOre = GT_TileEntity_Ores.class.getMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class); - } - catch (SecurityException | NoSuchMethodException r) {} - } - } + if (mSetOre == null) { + try { + mSetOre = GT_TileEntity_Ores.class.getMethod( + "setOreBlock", World.class, int.class, int.class, int.class, int.class, boolean.class); + } catch (SecurityException | NoSuchMethodException e) { + try { + mSetOre = GT_TileEntity_Ores.class.getMethod( + "setOreBlock", World.class, int.class, int.class, int.class, int.class); + } catch (SecurityException | NoSuchMethodException r) { + } + } + } - if (mSetOre != null) { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ - try { - return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta, bool); - } - catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { - return false; - } - } - else { - try { - return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta); - } - catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { - return false;} - } - } - else { - return false; - } - } -}
\ No newline at end of file + if (mSetOre != null) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta, bool); + } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { + return false; + } + } else { + try { + return (boolean) mSetOre.invoke(world, x, y, z, secondarymeta); + } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException t) { + return false; + } + } + } else { + return false; + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java index aae3bdd48a..b295d5be82 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java @@ -4,38 +4,52 @@ import static gtPlusPlus.xmod.gregtech.api.world.WorldGenUtils.mOresToRegister; import gtPlusPlus.core.material.Material; -public class GTPP_Worldgen_Handler implements Runnable{ - - - - @Override - public void run() { - - for (GT_OreVein_Object ore : mOresToRegister){ - generateNewVein(ore); - } - - } - - - - private final GTPP_Worldgen_GT_Ore_Layer generateNewVein(final GT_OreVein_Object ore){ - return generateNewVein(ore.mOreMixName, ore.minY, ore.maxY, ore.weight, ore.density, ore.size, ore.aPrimary, ore.aSecondary, ore.aBetween, ore.aSporadic); - } - - private final GTPP_Worldgen_GT_Ore_Layer generateNewVein(String mOreMixName, int minY, int maxY, int weight, int density, int size, - Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ - return new GTPP_Worldgen_GT_Ore_Layer( - "ore.mix."+mOreMixName, //String aName, - true, //boolean aDefault, - minY, maxY, //int aMinY, int aMaxY, - weight, //int aWeight, - density, //int aDensity, - size, //int aSize, - aPrimary, //Materials aPrimary, - aSecondary, //Materials aSecondary, - aBetween, //Materials aBetween, - aSporadic); //Materials aSporadic - } - +public class GTPP_Worldgen_Handler implements Runnable { + + @Override + public void run() { + + for (GT_OreVein_Object ore : mOresToRegister) { + generateNewVein(ore); + } + } + + private final GTPP_Worldgen_GT_Ore_Layer generateNewVein(final GT_OreVein_Object ore) { + return generateNewVein( + ore.mOreMixName, + ore.minY, + ore.maxY, + ore.weight, + ore.density, + ore.size, + ore.aPrimary, + ore.aSecondary, + ore.aBetween, + ore.aSporadic); + } + + private final GTPP_Worldgen_GT_Ore_Layer generateNewVein( + String mOreMixName, + int minY, + int maxY, + int weight, + int density, + int size, + Material aPrimary, + Material aSecondary, + Material aBetween, + Material aSporadic) { + return new GTPP_Worldgen_GT_Ore_Layer( + "ore.mix." + mOreMixName, // String aName, + true, // boolean aDefault, + minY, + maxY, // int aMinY, int aMaxY, + weight, // int aWeight, + density, // int aDensity, + size, // int aSize, + aPrimary, // Materials aPrimary, + aSecondary, // Materials aSecondary, + aBetween, // Materials aBetween, + aSporadic); // Materials aSporadic + } } |
