From 1b820de08a05070909a267e17f033fcf58ac8710 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Mon, 2 Sep 2024 23:17:17 +0200 Subject: The Great Renaming (#3014) * move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names --- .../galacticgreg/GT_TileEntity_Ores_Space.java | 144 ------ .../GT_Worldgen_GT_Ore_Layer_Space.java | 323 ------------ .../GT_Worldgen_GT_Ore_SmallPieces_Space.java | 116 ----- .../galacticgreg/GT_Worldgenerator_Space.java | 565 --------------------- .../java/bloodasp/galacticgreg/GalacticGreg.java | 113 ----- .../bloodasp/galacticgreg/SpaceDimRegisterer.java | 179 ------- .../java/bloodasp/galacticgreg/WorldGenGaGT.java | 28 - .../galacticgreg/api/AsteroidBlockComb.java | 77 --- .../bloodasp/galacticgreg/api/BlockMetaComb.java | 50 -- src/main/java/bloodasp/galacticgreg/api/Enums.java | 51 -- .../java/bloodasp/galacticgreg/api/GTOreTypes.java | 66 --- .../galacticgreg/api/ISpaceObjectGenerator.java | 58 --- .../bloodasp/galacticgreg/api/ModContainer.java | 85 ---- .../java/bloodasp/galacticgreg/api/ModDBMDef.java | 161 ------ .../bloodasp/galacticgreg/api/ModDimensionDef.java | 466 ----------------- .../galacticgreg/api/SpecialBlockComb.java | 71 --- .../galacticgreg/api/StructureInformation.java | 59 --- .../enums/DimensionBlockMetaDefinitionList.java | 57 --- .../galacticgreg/api/enums/DimensionDef.java | 228 --------- .../galacticgreg/api/enums/ModContainers.java | 19 - .../enums/properties/AsteroidPropertyBuilder.java | 105 ---- .../api/enums/properties/Asteroids.java | 78 --- .../galacticgreg/auxiliary/ConfigManager.java | 79 --- .../galacticgreg/auxiliary/GTOreGroup.java | 19 - .../galacticgreg/auxiliary/GalacticGregConfig.java | 141 ----- .../bloodasp/galacticgreg/auxiliary/LogHelper.java | 267 ---------- .../galacticgreg/auxiliary/PlayerChatHelper.java | 106 ---- .../galacticgreg/auxiliary/ProfilingStorage.java | 74 --- .../galacticgreg/command/AEStorageCommand.java | 180 ------- .../galacticgreg/command/ProfilingCommand.java | 99 ---- .../dynconfig/DynamicDimensionConfig.java | 160 ------ .../galacticgreg/generators/GenEllipsoid.java | 126 ----- .../registry/GalacticGregRegistry.java | 183 ------- .../galacticgreg/schematics/SpaceSchematic.java | 100 ---- .../schematics/SpaceSchematicFactory.java | 33 -- .../schematics/SpaceSchematicHandler.java | 182 ------- .../schematics/SpaceSchematicWrapper.java | 104 ---- 37 files changed, 4952 deletions(-) delete mode 100644 src/main/java/bloodasp/galacticgreg/GT_TileEntity_Ores_Space.java delete mode 100644 src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_Layer_Space.java delete mode 100644 src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_SmallPieces_Space.java delete mode 100644 src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java delete mode 100644 src/main/java/bloodasp/galacticgreg/GalacticGreg.java delete mode 100644 src/main/java/bloodasp/galacticgreg/SpaceDimRegisterer.java delete mode 100644 src/main/java/bloodasp/galacticgreg/WorldGenGaGT.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/AsteroidBlockComb.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/BlockMetaComb.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/Enums.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/GTOreTypes.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/ISpaceObjectGenerator.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/ModContainer.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/ModDBMDef.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/ModDimensionDef.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/SpecialBlockComb.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/StructureInformation.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/enums/DimensionBlockMetaDefinitionList.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/enums/DimensionDef.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/enums/ModContainers.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/enums/properties/AsteroidPropertyBuilder.java delete mode 100644 src/main/java/bloodasp/galacticgreg/api/enums/properties/Asteroids.java delete mode 100644 src/main/java/bloodasp/galacticgreg/auxiliary/ConfigManager.java delete mode 100644 src/main/java/bloodasp/galacticgreg/auxiliary/GTOreGroup.java delete mode 100644 src/main/java/bloodasp/galacticgreg/auxiliary/GalacticGregConfig.java delete mode 100644 src/main/java/bloodasp/galacticgreg/auxiliary/LogHelper.java delete mode 100644 src/main/java/bloodasp/galacticgreg/auxiliary/PlayerChatHelper.java delete mode 100644 src/main/java/bloodasp/galacticgreg/auxiliary/ProfilingStorage.java delete mode 100644 src/main/java/bloodasp/galacticgreg/command/AEStorageCommand.java delete mode 100644 src/main/java/bloodasp/galacticgreg/command/ProfilingCommand.java delete mode 100644 src/main/java/bloodasp/galacticgreg/dynconfig/DynamicDimensionConfig.java delete mode 100644 src/main/java/bloodasp/galacticgreg/generators/GenEllipsoid.java delete mode 100644 src/main/java/bloodasp/galacticgreg/registry/GalacticGregRegistry.java delete mode 100644 src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematic.java delete mode 100644 src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicFactory.java delete mode 100644 src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicHandler.java delete mode 100644 src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicWrapper.java (limited to 'src/main/java/bloodasp/galacticgreg') diff --git a/src/main/java/bloodasp/galacticgreg/GT_TileEntity_Ores_Space.java b/src/main/java/bloodasp/galacticgreg/GT_TileEntity_Ores_Space.java deleted file mode 100644 index dfa1307bce..0000000000 --- a/src/main/java/bloodasp/galacticgreg/GT_TileEntity_Ores_Space.java +++ /dev/null @@ -1,144 +0,0 @@ -package bloodasp.galacticgreg; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import bloodasp.galacticgreg.api.Enums.ReplaceState; -import bloodasp.galacticgreg.api.ModDimensionDef; -import gregtech.api.GregTech_API; -import gregtech.api.util.GT_Log; -import gregtech.common.blocks.GT_Block_Ores_Abstract; -import gregtech.common.blocks.GT_TileEntity_Ores; - -public class GT_TileEntity_Ores_Space { - - // Renamed function to prevent function shadowing with base GT-code - public static boolean setOuterSpaceOreBlock(ModDimensionDef pDimensionDef, World pWorld, int pX, int pY, int pZ, - int pMetaData) { - return setOuterSpaceOreBlock(pDimensionDef, pWorld, pX, pY, pZ, pMetaData, false, -1); - } - - public static boolean setOuterSpaceOreBlock(ModDimensionDef pDimensionDef, World pWorld, int pX, int pY, int pZ, - int pMetaData, boolean pAir) { - return setOuterSpaceOreBlock(pDimensionDef, pWorld, pX, pY, pZ, pMetaData, pAir, -1); - } - - /** - * Check if the block at given position may be replaced by an ore - * - * @param pWorld the world in question - * @param pX X-Cord - * @param pY Y-Cord - * @param pZ Z-Cord - * @return - */ - private static ReplaceState CheckForReplaceableBlock(World pWorld, int pX, int pY, int pZ, - ModDimensionDef pDimDef) { - try { - ReplaceState tFlag = ReplaceState.Unknown; - - Block targetBlock = pWorld.getBlock(pX, pY, pZ); - int targetBlockMeta = pWorld.getBlockMetadata(pX, pY, pZ); - - if (targetBlock == Blocks.air) tFlag = ReplaceState.Airblock; - else tFlag = pDimDef.getReplaceStateForBlock(targetBlock, targetBlockMeta); - - return tFlag; - } catch (Exception e) { - e.printStackTrace(GT_Log.err); - GalacticGreg.Logger.error("Error while processing CheckForReplaceableBlock(), defaulting to UNKNOWN"); - return ReplaceState.Unknown; - } - } - - /** - * Actually set the OreBlock - * - * @param pWorld the world in question - * @param pX - * @param pY - * @param pZ - * @param pMetaData GT-Ore metadata - * @param pAir - * @return - */ - public static boolean setOuterSpaceOreBlock(ModDimensionDef pDimensionDef, World pWorld, int pX, int pY, int pZ, - int pMetaData, boolean pAir, int pCustomGTOreOffset) { - if (!pAir) pY = Math.min(pWorld.getActualHeight(), Math.max(pY, 1)); - - if (pDimensionDef == null) { - GalacticGreg.Logger - .warn("Unknown DimensionID: %d. Will not set anything here", pWorld.provider.dimensionId); - return false; - } - try { - Block tBlock = pWorld.getBlock(pX, pY, pZ); - // If the meta is non-zero, and the target block is either non-air or the air-override is active - if ((pMetaData > 0) && ((tBlock != Blocks.air) || pAir)) { - // make sure we're either going with normal ore-metas, or small ores. - // Probably should do another check for <= 1700 - if (pMetaData < 1000 || pMetaData >= 16000) { - ReplaceState tRS = CheckForReplaceableBlock(pWorld, pX, pY, pZ, pDimensionDef); - - // Unable to lookup replacement state. Means: The block is unknown, and shall not be replaced - if (tRS == ReplaceState.Unknown) { - GalacticGreg.Logger.trace("Not placing ore Meta %d, as target block is unknown", pMetaData); - return false; - } else if (tRS == ReplaceState.Airblock && !pAir) { - GalacticGreg.Logger.trace("Not placing ore Meta %d in midair, as AIR is FALSE", pMetaData); - return false; - } - if (tRS == ReplaceState.CannotReplace) { - // wrong metaData ID for target block - GalacticGreg.Logger.trace("Not placing ore Meta %d, as the state is CANNOTREPLACE", pMetaData); - return false; - } - - if (pCustomGTOreOffset == -1) pMetaData += pDimensionDef.getStoneType() - .getOffset(); - else pMetaData += pCustomGTOreOffset; - // This fix seems like cargo cult coding...The Abstract class just returns 0 for the harvest level. - // But it aligns with the GT5U method, so yay? - pWorld.setBlock( - pX, - pY, - pZ, - GregTech_API.sBlockOres1, - GT_TileEntity_Ores.getHarvestData( - (short) pMetaData, - ((GT_Block_Ores_Abstract) GregTech_API.sBlockOres1) - .getBaseBlockHarvestLevel(pMetaData % 16000 / 1000)), - 0); - TileEntity tTileEntity = pWorld.getTileEntity(pX, pY, pZ); - if ((tTileEntity instanceof GT_TileEntity_Ores)) { - ((GT_TileEntity_Ores) tTileEntity).mMetaData = ((short) pMetaData); - ((GT_TileEntity_Ores) tTileEntity).mNatural = true; - } else { - // This is somehow triggered randomly, and most times the target block is air, which should - // never happen as we check for air... - // That's why I put this behind a debug config option. If you ever find the reason for it, - // please tell me what caused this - if (GalacticGreg.GalacticConfig.ReportOreGenFailures) GalacticGreg.Logger.warn( - "Something went wrong while placing GT OreTileEntity. Meta: %d X [%d] Y [%d] Z [%d]", - pMetaData, - pX, - pY, - pZ); - } - - return true; - } else GalacticGreg.Logger.warn( - "Not replacing block at pos %d %d %d due unexpected metaData for OreBlock: %d", - pX, - pY, - pZ, - pMetaData); - } - } catch (Exception e) { - if (GalacticGreg.GalacticConfig.ReportOreGenFailures) e.printStackTrace(); - } - return false; - } -} diff --git a/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_Layer_Space.java b/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_Layer_Space.java deleted file mode 100644 index 9dc8d2c070..0000000000 --- a/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_Layer_Space.java +++ /dev/null @@ -1,323 +0,0 @@ -package bloodasp.galacticgreg; - -import static gregtech.api.enums.GT_Values.oreveinPlacerOres; -import static gregtech.api.enums.GT_Values.oreveinPlacerOresMultiplier; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; - -import bloodasp.galacticgreg.api.ModContainer; -import bloodasp.galacticgreg.api.ModDimensionDef; -import bloodasp.galacticgreg.auxiliary.GTOreGroup; -import bloodasp.galacticgreg.registry.GalacticGregRegistry; -import gregtech.api.util.GT_Log; -import gregtech.api.world.GT_Worldgen; -import gregtech.common.OreMixBuilder; - -public class GT_Worldgen_GT_Ore_Layer_Space extends GT_Worldgen { - - 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 final short mPrimaryMeta; - public final short mSecondaryMeta; - public final short mBetweenMeta; - public final short mSporadicMeta; - - private long mProfilingStart; - private long mProfilingEnd; - private Map allowedDims; - - public GT_Worldgen_GT_Ore_Layer_Space(OreMixBuilder mix) { - super(mix.oreMixName, GalacticGreg.oreVeinWorldgenList, mix.enabledByDefault); - - mMinY = (short) mix.minY; - mMaxY = (short) Math.max(this.mMinY + 5, mix.maxY); - mWeight = (short) mix.weight; - mDensity = (short) mix.density; - mSize = (short) Math.max(1, mix.size); - mPrimaryMeta = (short) mix.primary.mMetaItemSubID; - mSecondaryMeta = (short) mix.secondary.mMetaItemSubID; - mBetweenMeta = (short) mix.between.mMetaItemSubID; - mSporadicMeta = (short) mix.sporadic.mMetaItemSubID; - - allowedDims = new HashMap<>(); - - for (ModContainer mc : GalacticGregRegistry.getModContainers()) { - if (!mc.getEnabled()) continue; - - for (ModDimensionDef mdd : mc.getDimensionList()) { - String tDimIdentifier = mdd.getDimIdentifier(); - if (allowedDims.containsKey(tDimIdentifier)) GalacticGreg.Logger.error( - "Found 2 Dimensions with the same Identifier: %s Dimension will not generate Ores", - tDimIdentifier); - else { - boolean tFlag = mix.dimsEnabled.getOrDefault(mdd.getDimensionName(), false); - allowedDims.put(tDimIdentifier, tFlag); - } - } - } - - GalacticGreg.Logger.trace("Initialized new OreLayer: %s", mix.oreMixName); - if (mEnabled) sWeight += this.mWeight; - } - - /** - * Check if *this* orelayer is enabled for pDimensionDef - * - * @param pDimensionDef the ChunkProvider in question - * @return - */ - public boolean isEnabledForDim(ModDimensionDef pDimensionDef) { - return allowedDims.getOrDefault(pDimensionDef.getDimIdentifier(), false); - } - - private static Map> _mBufferedVeinList = new HashMap<>(); - - /** - * Get a List of all Veins which are enabled for given Dim. Query is buffered - * - * @param pDimensionDef - * @return null if nothing is found or error - */ - private static List getOreMixIDsForDim(ModDimensionDef pDimensionDef) { - List tReturn; - - if (_mBufferedVeinList.containsKey(pDimensionDef.getDimIdentifier())) - tReturn = _mBufferedVeinList.get(pDimensionDef.getDimIdentifier()); - else { - tReturn = new ArrayList<>(); - for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) - if (tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space - && ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).isEnabledForDim(pDimensionDef)) - tReturn.add(tWorldGen.mWorldGenName); - - _mBufferedVeinList.put(pDimensionDef.getDimIdentifier(), tReturn); - } - - return tReturn; - } - - /** - * Select a random ore-vein from the list - * - * @param pDimensionDef - * @param pRandom - * @return - */ - public static GTOreGroup getRandomOreGroup(ModDimensionDef pDimensionDef, Random pRandom, boolean pIgnoreWeight) { - short primaryMeta = 0; - short secondaryMeta = 0; - short betweenMeta = 0; - short sporadicMeta = 0; - - if (pIgnoreWeight) { - List tEnabledVeins = getOreMixIDsForDim(pDimensionDef); - int tRnd = pRandom.nextInt(tEnabledVeins.size()); - String tVeinName = tEnabledVeins.get(tRnd); - - GT_Worldgen tGen = null; - for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) - if (tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space - && ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWorldGenName.equals(tVeinName)) tGen = tWorldGen; - - if (tGen != null) { - // GT_Worldgen_GT_Ore_Layer_Space tGen = GalacticGreg.oreVeinWorldgenList.get(tRndMix); - GalacticGreg.Logger.trace("Using Oremix %s for asteroid", tGen.mWorldGenName); - primaryMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tGen).mPrimaryMeta; - secondaryMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tGen).mSecondaryMeta; - betweenMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tGen).mBetweenMeta; - sporadicMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tGen).mSporadicMeta; - } - } else { - if ((GT_Worldgen_GT_Ore_Layer_Space.sWeight > 0) && (GalacticGreg.oreVeinWorldgenList.size() > 0)) { - GalacticGreg.Logger.trace("About to select oremix"); - boolean temp = true; - int tRandomWeight; - for (int i = 0; (i < 256) && (temp); i++) { - tRandomWeight = pRandom.nextInt(GT_Worldgen_GT_Ore_Layer_Space.sWeight); - for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) { - if (!(tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space)) continue; - - tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWeight; - if (tRandomWeight <= 0) { - try { - if (((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).isEnabledForDim(pDimensionDef)) { - GalacticGreg.Logger.trace("Using Oremix %s for asteroid", tWorldGen.mWorldGenName); - primaryMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mPrimaryMeta; - secondaryMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mSecondaryMeta; - betweenMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mBetweenMeta; - sporadicMeta = ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mSporadicMeta; - - temp = false; - break; - } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - } - } - } - } - if (primaryMeta != 0 || secondaryMeta != 0 || betweenMeta != 0 || sporadicMeta != 0) - return new GTOreGroup(primaryMeta, secondaryMeta, betweenMeta, sporadicMeta); - else return null; - } - - @Override - public boolean executeWorldgen(World pWorld, Random pRandom, String pBiome, int pDimensionType, int pChunkX, - int pChunkZ, IChunkProvider pChunkGenerator, IChunkProvider pChunkProvider) { - GalacticGreg.Logger.trace("Entering executeWorldgen for [%s]", mWorldGenName); - ModDimensionDef tMDD = GalacticGregRegistry.getDimensionTypeByChunkGenerator(pChunkGenerator); - if (tMDD == null) { - GalacticGreg.Logger - .trace("Can't find dimension definition for ChunkProvider %s, skipping", pChunkGenerator.toString()); - return false; - } - - if (!isEnabledForDim(tMDD)) { - GalacticGreg.Logger - .trace("OreGen for %s is disallowed in dimension %s, skipping", mWorldGenName, tMDD.getDimensionName()); - return false; - } - - if (GalacticGreg.GalacticConfig.ProfileOreGen) mProfilingStart = System.currentTimeMillis(); - // --------------------------- - int tMinY = this.mMinY + pRandom.nextInt(this.mMaxY - this.mMinY - 7); - - int cX = pChunkX - pRandom.nextInt(this.mSize); - int eX = pChunkX + 16 + pRandom.nextInt(this.mSize); - int cZ = pChunkZ - pRandom.nextInt(this.mSize); - int eZ = pChunkZ + 16 + pRandom.nextInt(this.mSize); - for (int tX = cX; tX <= eX; tX++) { - for (int tZ = cZ; tZ <= eZ; tZ++) { - if (this.mSecondaryMeta > 0) { - for (int i = tMinY - 1; i < tMinY + 3; i++) { - int placeX = Math.max( - 1, - Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) - / getDensityFromPos(tX, tZ, pChunkX, pChunkZ)); - int placeZ = Math.max( - 1, - Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) - / getDensityFromPos(tX, tZ, pChunkX, pChunkZ)); - if ((pRandom.nextInt(placeZ) == 0) || (pRandom.nextInt(placeX) == 0)) { - GT_TileEntity_Ores_Space - .setOuterSpaceOreBlock(tMDD, pWorld, tX, i, tZ, this.mSecondaryMeta); - } - } - } - if (this.mBetweenMeta > 0) { - for (int i = tMinY + 2; i < tMinY + 6; i++) { - int placeX = Math.max( - 1, - Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) - / getDensityFromPos(tX, tZ, pChunkX, pChunkZ)); - int placeZ = Math.max( - 1, - Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) - / getDensityFromPos(tX, tZ, pChunkX, pChunkZ)); - if (((pRandom.nextInt(placeZ) == 0) || (pRandom.nextInt(placeX) == 0)) - && (pRandom.nextInt(2) == 0)) { - GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, i, tZ, this.mBetweenMeta); - } - } - - } - if (this.mPrimaryMeta > 0) { - for (int i = tMinY + 4; i < tMinY + 8; i++) { - int placeX = Math.max( - 1, - Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) - / getDensityFromPos(tX, tZ, pChunkX, pChunkZ)); - int placeZ = Math.max( - 1, - Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) - / getDensityFromPos(tX, tZ, pChunkX, pChunkZ)); - if ((pRandom.nextInt(placeZ) == 0) || (pRandom.nextInt(placeX) == 0)) { - GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, i, tZ, this.mPrimaryMeta); - } - } - } - if (this.mSporadicMeta > 0) { - for (int i = tMinY - 1; i < tMinY + 8; i++) { - int placeX = Math.max( - 1, - Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) - / getDensityFromPos(tX, tZ, pChunkX, pChunkZ)); - int placeZ = Math.max( - 1, - Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) - / getDensityFromPos(tX, tZ, pChunkX, pChunkZ)); - if (((pRandom.nextInt(placeX) == 0) || (pRandom.nextInt(placeZ) == 0)) - && (pRandom.nextInt(7) == 0)) { - GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, i, tZ, this.mSporadicMeta); - } - } - } - } - } - - if (oreveinPlacerOres) { - int nSmallOres = (cX - eX) * (cZ - eZ) * this.mDensity / 10 * oreveinPlacerOresMultiplier; - for (int nSmallOresCount = 0; nSmallOresCount < nSmallOres; nSmallOresCount++) { - int tX = pRandom.nextInt(16) + pChunkX + 2; - int tZ = pRandom.nextInt(16) + pChunkZ + 2; - int tY = pRandom.nextInt(160) + 10; // Y height can vary from 10 to 170 for small ores. - if (this.mPrimaryMeta > 0) - GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, tY, tZ, this.mPrimaryMeta + 16000); - tX = pRandom.nextInt(16) + pChunkX + 2; - tZ = pRandom.nextInt(16) + pChunkZ + 2; - tY = pRandom.nextInt(160) + 10; // Y height can vary from 10 to 170 for small ores. - if (this.mSecondaryMeta > 0) GT_TileEntity_Ores_Space - .setOuterSpaceOreBlock(tMDD, pWorld, tX, tY, tZ, this.mSecondaryMeta + 16000); - tX = pRandom.nextInt(16) + pChunkX + 2; - tZ = pRandom.nextInt(16) + pChunkZ + 2; - tY = pRandom.nextInt(160) + 10; // Y height can vary from 10 to 170 for small ores. - if (this.mBetweenMeta > 0) - GT_TileEntity_Ores_Space.setOuterSpaceOreBlock(tMDD, pWorld, tX, tY, tZ, this.mBetweenMeta + 16000); - tX = pRandom.nextInt(16) + pChunkX + 2; - tZ = pRandom.nextInt(16) + pChunkZ + 2; - tY = pRandom.nextInt(190) + 10; // Y height can vary from 10 to 200 for small ores. - if (this.mSporadicMeta > 0) GT_TileEntity_Ores_Space - .setOuterSpaceOreBlock(tMDD, pWorld, tX, tY, tZ, this.mSporadicMeta + 16000); - } - } - - // --------------------------- - if (GalacticGreg.GalacticConfig.ProfileOreGen) { - try { - mProfilingEnd = System.currentTimeMillis(); - long tTotalTime = mProfilingEnd - mProfilingStart; - GalacticGreg.Profiler.AddTimeToList(tMDD, tTotalTime); - GalacticGreg.Logger.debug( - "Done with OreLayer-Worldgen in DimensionType %s. Generation took %d ms", - tMDD.getDimensionName(), - tTotalTime); - } catch (Exception ignored) {} // Silently ignore errors - } - - GalacticGreg.Logger.trace("Leaving executeWorldgen"); - return true; - } - - public int getDensityFromPos(int aX, int aZ, int aSeedX, int aSeedZ) { - if (aX < 0) aX -= 16; - if (aZ < 0) aZ -= 16; - return Math.max( - 1, - this.mDensity - / ((int) Math.sqrt(2 + Math.pow(aX / 16 - aSeedX / 16, 2) + Math.pow(aZ / 16 - aSeedZ / 16, 2)))); - } -} diff --git a/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_SmallPieces_Space.java b/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_SmallPieces_Space.java deleted file mode 100644 index f5def8e0fd..0000000000 --- a/src/main/java/bloodasp/galacticgreg/GT_Worldgen_GT_Ore_SmallPieces_Space.java +++ /dev/null @@ -1,116 +0,0 @@ -package bloodasp.galacticgreg; - -import java.util.HashMap; -import java.util.Map; -import java.util.Random; - -import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; - -import bloodasp.galacticgreg.api.ModContainer; -import bloodasp.galacticgreg.api.ModDimensionDef; -import bloodasp.galacticgreg.registry.GalacticGregRegistry; -import gregtech.api.world.GT_Worldgen; -import gregtech.common.SmallOreBuilder; - -public class GT_Worldgen_GT_Ore_SmallPieces_Space extends GT_Worldgen { - - public final short mMinY; - public final short mMaxY; - public final short mAmount; - public final short mMeta; - - private long mProfilingStart; - private long mProfilingEnd; - private Map allowedDims; - - public GT_Worldgen_GT_Ore_SmallPieces_Space(SmallOreBuilder ore) { - super(ore.smallOreName, GalacticGreg.smallOreWorldgenList, ore.enabledByDefault); - - mMinY = (short) ore.minY; - mMaxY = (short) Math.max(this.mMinY + 1, ore.maxY); - mAmount = (short) Math.max(1, ore.amount); - mMeta = (short) ore.ore.mMetaItemSubID; - - allowedDims = new HashMap<>(); - for (ModContainer mc : GalacticGregRegistry.getModContainers()) { - if (!mc.getEnabled()) continue; - - for (ModDimensionDef mdd : mc.getDimensionList()) { - String tDimIdentifier = mdd.getDimIdentifier(); - if (allowedDims.containsKey(tDimIdentifier)) GalacticGreg.Logger.error( - "Found 2 Dimensions with the same Identifier: %s Dimension will not generate Ores", - tDimIdentifier); - else { - boolean tFlag = ore.dimsEnabled.getOrDefault(mdd.getDimensionName(), false); - allowedDims.put(tDimIdentifier, tFlag); - } - } - } - - GalacticGreg.Logger.trace("Initialized new OreLayer: %s", ore.smallOreName); - } - - /** - * Check if *this* orelayer is enabled for pDimensionDef - * - * @param pDimensionDef the ChunkProvider in question - * @return - */ - public boolean isEnabledForDim(ModDimensionDef pDimensionDef) { - return allowedDims.getOrDefault(pDimensionDef.getDimIdentifier(), false); - } - - @Override - public boolean executeWorldgen(World pWorld, Random pRandom, String pBiome, int pDimensionType, int pChunkX, - int pChunkZ, IChunkProvider pChunkGenerator, IChunkProvider pChunkProvider) { - GalacticGreg.Logger.trace("Entering executeWorldgen for [%s]", mWorldGenName); - ModDimensionDef tMDD = GalacticGregRegistry.getDimensionTypeByChunkGenerator(pChunkGenerator); - if (tMDD == null) { - GalacticGreg.Logger - .trace("Can't find dimension definition for ChunkProvider %s, skipping", pChunkGenerator.toString()); - return false; - } - - if (!isEnabledForDim(tMDD)) { - GalacticGreg.Logger - .trace("OreGen for %s is disallowed in dimension %s, skipping", mWorldGenName, tMDD.getDimensionName()); - return false; - } - - if (GalacticGreg.GalacticConfig.ProfileOreGen) mProfilingStart = System.currentTimeMillis(); - // --------------------------- - - if (this.mMeta > 0) { - int i = 0; - for (int j = Math.max(1, this.mAmount / 2 + pRandom.nextInt(this.mAmount) / 2); i < j; i++) { - GT_TileEntity_Ores_Space.setOuterSpaceOreBlock( - tMDD, - pWorld, - pChunkX + pRandom.nextInt(16), - this.mMinY + pRandom.nextInt(Math.max(1, this.mMaxY - this.mMinY)), - pChunkZ + pRandom.nextInt(16), - this.mMeta + 16000); - } - } - // --------------------------- - if (GalacticGreg.GalacticConfig.ProfileOreGen) { - try { - mProfilingEnd = System.currentTimeMillis(); - long tTotalTime = mProfilingEnd - mProfilingStart; - GalacticGreg.Profiler.AddTimeToList(tMDD, tTotalTime); - GalacticGreg.Logger.debug( - "Done with SmallOre-Worldgen in DimensionType %s. Generation took %d ms", - tMDD.getDimensionName(), - tTotalTime); - } catch (Exception ignored) {} // Silently ignore errors - } - - GalacticGreg.Logger.trace("Leaving executeWorldgen"); - return true; - } - - public boolean isAllowedForHeight(int pTargetHeight) { - return (pTargetHeight >= mMinY && pTargetHeight <= mMaxY); - } -} diff --git a/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java b/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java deleted file mode 100644 index e76bc9bbcc..0000000000 --- a/src/main/java/bloodasp/galacticgreg/GT_Worldgenerator_Space.java +++ /dev/null @@ -1,565 +0,0 @@ -package bloodasp.galacticgreg; - -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.inventory.IInventory; -import net.minecraft.util.Vec3; -import net.minecraft.util.WeightedRandomChestContent; -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.minecraftforge.common.ChestGenHooks; - -import bloodasp.galacticgreg.api.AsteroidBlockComb; -import bloodasp.galacticgreg.api.BlockMetaComb; -import bloodasp.galacticgreg.api.Enums.DimensionType; -import bloodasp.galacticgreg.api.Enums.SpaceObjectType; -import bloodasp.galacticgreg.api.Enums.TargetBlockPosition; -import bloodasp.galacticgreg.api.GTOreTypes; -import bloodasp.galacticgreg.api.ISpaceObjectGenerator; -import bloodasp.galacticgreg.api.ModDimensionDef; -import bloodasp.galacticgreg.api.SpecialBlockComb; -import bloodasp.galacticgreg.api.StructureInformation; -import bloodasp.galacticgreg.auxiliary.GTOreGroup; -import bloodasp.galacticgreg.dynconfig.DynamicDimensionConfig; -import bloodasp.galacticgreg.dynconfig.DynamicDimensionConfig.AsteroidConfig; -import bloodasp.galacticgreg.registry.GalacticGregRegistry; -import cpw.mods.fml.common.IWorldGenerator; -import cpw.mods.fml.common.eventhandler.EventBus; -import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.util.GT_Log; -import gregtech.api.world.GT_Worldgen; -import gregtech.common.GT_Worldgenerator; - -public class GT_Worldgenerator_Space implements IWorldGenerator { - - public static boolean sAsteroids = true; - private final EventBus eventBus = new EventBus(); - private World worldObj; - - private int chunkX; - private int chunkZ; - private int mSize = 100; - - private long mProfilingStart; - private long mProfilingEnd; - - public GT_Worldgenerator_Space() { - GameRegistry.registerWorldGenerator(this, Integer.MAX_VALUE); - } - - public void generate(Random pRandom, int pX, int pZ, World pWorld, IChunkProvider pChunkGenerator, - IChunkProvider pChunkProvider) { - pX *= 16; - pZ *= 16; - - String tBiome = pWorld.getBiomeGenForCoords(pX + 8, pZ + 8).biomeName; - pRandom = new Random(pRandom.nextInt()); - if (tBiome == null) { - tBiome = BiomeGenBase.plains.biomeName; - } - GalacticGreg.Logger - .trace("Triggered generate: [ChunkGenerator %s] [Biome %s]", pChunkGenerator.toString(), tBiome); - - ModDimensionDef tDimDef = GalacticGregRegistry.getDimensionTypeByChunkGenerator(pChunkGenerator); - - if (tDimDef == null) { - GalacticGreg.Logger.trace( - "Ignoring ChunkGenerator type %s as there is no definition for it in the registry", - pChunkGenerator.toString()); - return; - } else { - GalacticGreg.Logger.trace("Selected DimDef: [%s]", tDimDef.getDimIdentifier()); - } - - /* - * In some later addons maybe, not for now. Ignoring Biome-based worldgen String tBiome = - * pWorld.getBiomeGenForCoords(pX + 8, pZ + 8).biomeName; pRandom = new Random(pRandom.nextInt()); if (tBiome == - * null) { tBiome = BiomeGenBase.plains.biomeName; } - */ - - if (tDimDef.getDimensionType() != DimensionType.Planet) { - if (tDimDef.getRandomAsteroidMaterial() == null) GalacticGreg.Logger.error( - "Dimension [%s] is set to Asteroids, but no asteroid material is specified! Nothing will generate", - tDimDef.getDimensionName()); - else Generate_Asteroids(tDimDef, pRandom, pWorld, pX, pZ); - } else if (tDimDef.getDimensionType() != DimensionType.Asteroid) { - Generate_OreVeins(tDimDef, pRandom, pWorld, pX, pZ, "", pChunkGenerator, pChunkProvider); - } - - Chunk tChunk = pWorld.getChunkFromBlockCoords(pX, pZ); - if (tChunk != null) { - tChunk.isModified = true; - } - } - - private void Generate_Asteroids(ModDimensionDef pDimensionDef, Random pRandom, World pWorld, int pX, int pZ) { - GalacticGreg.Logger.trace("Running asteroid-gen in Dim %s", pDimensionDef.getDimIdentifier()); - - AsteroidConfig tAConf = DynamicDimensionConfig.getAsteroidConfig(pDimensionDef); - if (tAConf == null) { - GalacticGreg.Logger.error( - "Dimension %s is set to asteroid, but no config object can be found. Skipping!", - pDimensionDef.getDimIdentifier()); - return; - } else { - GalacticGreg.Logger.trace("Asteroid probability: %d", tAConf.Probability); - } - - if ((tAConf.Probability <= 1) || (pRandom.nextInt(tAConf.Probability) == 0)) { - GalacticGreg.Logger.trace("Generating asteroid NOW"); - // --------------------------- - if (GalacticGreg.GalacticConfig.ProfileOreGen) mProfilingStart = System.currentTimeMillis(); - // ----------------------------- - - // Get Random position - int tX = pX + pRandom.nextInt(16); - int tY = 50 + pRandom.nextInt(200 - 50); - int tZ = pZ + pRandom.nextInt(16); - - // Check if position is free - if ((pWorld.getBlock(tX, tY, tZ) - .isAir(pWorld, tX, tY, tZ))) { - - int tCustomAsteroidOffset = -1; - int tGraniteMeta = 0; - - // Select Random OreGroup and Asteroid Material - GTOreGroup tOreGroup = GT_Worldgen_GT_Ore_Layer_Space.getRandomOreGroup(pDimensionDef, pRandom, true); - AsteroidBlockComb tABComb = pDimensionDef.getRandomAsteroidMaterial(); - if (tABComb == null) return; - - // Fill Vars for random Asteroid - Block tFinalAsteroidBlock = tABComb.getBlock(); - int tFinalAsteroidBlockMeta = tABComb.getMeta(); - int tFinalOreOffset = tABComb.getOreMaterial() - .getOffset(); - int tFinalUpdateMode = tABComb.getOreMaterial() - .getUpdateMode(); - GalacticGreg.Logger.debug( - "Asteroid will be build with: Block: [%s] OreType: [%s]", - Block.blockRegistry.getNameForObject(tABComb.getBlock()), - tABComb.getOreMaterial() - .toString()); - - // get random Ore-asteroid generator from the list of registered generators - ISpaceObjectGenerator aGen = pDimensionDef.getRandomSOGenerator(SpaceObjectType.OreAsteroid); - if (aGen == null) { - GalacticGreg.Logger.ot_error( - "GalacticGreg.Generate_Asteroids.NoSOGenFound", - "No SpaceObjectGenerator has been registered for type ORE_ASTEROID in Dimension %s. Nothing will generate", - pDimensionDef.getDimensionName()); - return; - } - - aGen.reset(); - aGen.setCenterPoint(tX, tY, tZ); - aGen.randomize(tAConf.MinSize, tAConf.MaxSize); // Initialize random values and set size - aGen.calculate(); // Calculate structure - - // Random loot-chest somewhere in the asteroid - Vec3 tChestPosition = Vec3.createVectorHelper(0, 0, 0); - boolean tDoLootChest = false; - int tNumLootItems = 0; - if (tAConf.LootChestChance > 0) { - GalacticGreg.Logger.trace("Random loot chest enabled, flipping the coin"); - int tChance = pRandom.nextInt(100); // Loot chest is 1 in 100 (Was: 1:1000 which actually never - // happend) - if (tAConf.LootChestChance >= tChance) { - GalacticGreg.Logger.debug("We got a match. Preparing to generate the loot chest"); - // Get amount of items for the loot chests, randomize it (1-num) if enabled - if (tAConf.RandomizeNumLootItems) tNumLootItems = pRandom.nextInt(tAConf.NumLootItems - 1) + 1; - else tNumLootItems = tAConf.NumLootItems; - - GalacticGreg.Logger - .debug(String.format("Loot chest random item count will be: %d", tNumLootItems)); - - // try to find any block that is not on the asteroids outer-shell - GalacticGreg.Logger.trace("Starting lookup for valid asteroid-block for the chest"); - for (int x = 0; x < 64; x++) // 64 enough? Should be - { - int tRndBlock = pRandom.nextInt( - aGen.getStructure() - .size()); - StructureInformation tChestSI = aGen.getStructure() - .get(tRndBlock); - if (tChestSI.getBlockPosition() != TargetBlockPosition.AsteroidShell) { - GalacticGreg.Logger.debug( - String.format( - "Chest position found [x:%d y:%d z:%d]", - tChestSI.getX(), - tChestSI.getY(), - tChestSI.getZ())); - // Found valid position "Somewhere" in the asteroid, set position... - tChestPosition = Vec3 - .createVectorHelper(tChestSI.getX(), tChestSI.getY(), tChestSI.getZ()); - // .. and set CreateFlag to true - tDoLootChest = true; - break; - } - } - } - } - - // Now build the structure - GalacticGreg.Logger.trace("Now generating Space-Structure"); - for (StructureInformation si : aGen.getStructure()) { - // Only replace airblocks - if (pWorld.isAirBlock(si.getX(), si.getY(), si.getZ())) { - // === Loot-chest generator >> - if (tDoLootChest) // If gen-lootchest enabled... - { - // Check if current x/y/z is the location where the chest shall be created - if ((int) tChestPosition.xCoord == si.getX() && (int) tChestPosition.yCoord == si.getY() - && (int) tChestPosition.zCoord == si.getZ()) { - GalacticGreg.Logger.trace("Now generating LootChest and contents"); - // Get items for the configured loot-table - WeightedRandomChestContent[] tRandomLoot = ChestGenHooks - .getItems(DynamicDimensionConfig.getLootChestTable(tAConf), pRandom); - - // Get chest-block to spawn - BlockMetaComb tTargetChestType = GalacticGreg.GalacticConfig.CustomLootChest; - - // Place down the chest - if (tTargetChestType.getMeta() > 0) pWorld.setBlock( - si.getX(), - si.getY(), - si.getZ(), - tTargetChestType.getBlock(), - tTargetChestType.getMeta(), - 2); - else pWorld.setBlock(si.getX(), si.getY(), si.getZ(), tTargetChestType.getBlock()); - - // Retrieve the TEs IInventory that should've been created - IInventory entityChestInventory = (IInventory) pWorld - .getTileEntity(si.getX(), si.getY(), si.getZ()); - // If it's not null... - if (entityChestInventory != null) { - // and if we're on the server... - if (!pWorld.isRemote) { - // Fill the chest with stuffz! - WeightedRandomChestContent.generateChestContents( - pRandom, - tRandomLoot, - entityChestInventory, - tNumLootItems); - GalacticGreg.Logger.trace("Loot chest successfully generated"); - } - } else { - // Something made a boo.. - GalacticGreg.Logger.warn( - "Could not create lootchest at X[%d] Y[%d] Z[%d]. getTileEntity() returned null", - si.getX(), - si.getY(), - si.getZ()); - } - // Make sure we never compare coordinates again (for this asteroid/Structure) - tDoLootChest = false; - // Do some debug logging - GalacticGreg.Logger - .debug("Generated LootChest at X[%d] Y[%d] Z[%d]", si.getX(), si.getY(), si.getZ()); - // And skip the rest of this function - continue; - } - } - // << Loot-chest generator === - - // === Ore generator >> - boolean tPlacedOreBlock = false; - // If a valid oregroup has been selected (more than 0 ore-veins are enabled for this dim) - if (tOreGroup != null) { - // GalacticGreg.Logger.trace("tOreGoup is populated, continuing"); - // Choose a number between 0 and 100 - int ranOre = pRandom.nextInt(100); - int tFinalOreMeta = 0; - - // If choosen number is below the configured orechance, do random between and sporadic - if (ranOre < tAConf.OreChance) { - if (pRandom.nextBoolean()) { - // Only take as final value if meta is not zero - if (tOreGroup.SporadicBetweenMeta > 0) - tFinalOreMeta = tOreGroup.SporadicBetweenMeta; - } else { - // Only take as final value if meta is not zero - if (tOreGroup.SporadicAroundMeta > 0) tFinalOreMeta = tOreGroup.SporadicAroundMeta; - } - } - // If choosen number is below the configured orechance, do random primary and secondary - // We use an offset here, so this part is always higher than the first check. - else if (ranOre < tAConf.OreChance + tAConf.OrePrimaryOffset) { - if (pRandom.nextBoolean()) { - // Only take as final value if meta is not zero - if (tOreGroup.PrimaryMeta > 0) tFinalOreMeta = tOreGroup.PrimaryMeta; - } else { - // Only take as final value if meta is not zero - if (tOreGroup.SecondaryMeta > 0) tFinalOreMeta = tOreGroup.SecondaryMeta; - } - } - - // if the final oreMeta has been found... - // GalacticGreg.Logger.info("tFinalOreMeta is %d", tFinalOreMeta); - if (tFinalOreMeta > 0) { - // make sure we obey the configured "HiddenOres" setting (No ores on the shell) - if (tAConf.HiddenOres && (si.getBlockPosition() == TargetBlockPosition.AsteroidShell)) { - // Ore would be placed around the shell, which is disabled (hiddenores) - GalacticGreg.Logger.trace( - "Skipping ore-placement event (HiddenOres=true; TargetBlockPosition=AsteroidShell)"); - } else { - // try to place the ore block. The result is stored in tPlacedOreBlock - tPlacedOreBlock = GT_TileEntity_Ores_Space.setOuterSpaceOreBlock( - pDimensionDef, - pWorld, - si.getX(), - si.getY(), - si.getZ(), - tOreGroup.SecondaryMeta, - true, - tFinalOreOffset); - } - } - } - // << Ore generator === - - // === Additional special blocks >> - // If no ore-block has been placed yet... - if (!tPlacedOreBlock) { - // try to spawn special blocks - boolean tFlag = doGenerateSpecialBlocks( - pDimensionDef, - pRandom, - pWorld, - tAConf, - si.getX(), - si.getY(), - si.getZ(), - si.getBlockPosition()); - - // No special block placed? Try smallores - if (tFlag) tFlag = doGenerateSmallOreBlock( - pDimensionDef, - pRandom, - pWorld, - tAConf, - si.getX(), - si.getY(), - si.getZ(), - tFinalOreOffset); - - // no smallores either? do normal block - if (tFlag) pWorld.setBlock( - si.getX(), - si.getY(), - si.getZ(), - tFinalAsteroidBlock, - tFinalAsteroidBlockMeta, - tFinalUpdateMode); - - } - // << Additional special blocks === - } - } - } - // --------------------------- - // OreGen profiler stuff - if (GalacticGreg.GalacticConfig.ProfileOreGen) { - try { - mProfilingEnd = System.currentTimeMillis(); - long tTotalTime = mProfilingEnd - mProfilingStart; - GalacticGreg.Profiler.AddTimeToList(pDimensionDef, tTotalTime); - GalacticGreg.Logger.debug( - "Done with Asteroid-Worldgen in DimensionType %s. Generation took %d ms", - pDimensionDef.getDimensionName(), - tTotalTime); - } catch (Exception ignored) {} // Silently ignore errors - } - // --------------------------- - } - GalacticGreg.Logger.trace("Leaving asteroid-gen for Dim %s", pDimensionDef.getDimIdentifier()); - } - - /** - * Generate Special Blocks in asteroids if enabled - * - * @param pDimensionDef - * @param pRandom - * @param pWorld - * @param tAConf - * @param eX - * @param eY - * @param eZ - * @return - */ - private boolean doGenerateSpecialBlocks(ModDimensionDef pDimensionDef, Random pRandom, World pWorld, - AsteroidConfig tAConf, int eX, int eY, int eZ, TargetBlockPosition pBlockPosition) { - - boolean tFlag = true; - // Handler to generate special BlockTypes randomly if activated - if (tAConf.SpecialBlockChance > 0) { - if (pRandom.nextInt(100) < tAConf.SpecialBlockChance) { - SpecialBlockComb bmc = pDimensionDef.getRandomSpecialAsteroidBlock(); - if (bmc != null) { - boolean tIsAllowed = false; - - switch (bmc.getBlockPosition()) { - case AsteroidCore: - if (pBlockPosition == TargetBlockPosition.AsteroidCore) tIsAllowed = true; - break; - case AsteroidCoreAndShell: - if (pBlockPosition == TargetBlockPosition.AsteroidCore - || pBlockPosition == TargetBlockPosition.AsteroidShell) tIsAllowed = true; - break; - case AsteroidShell: - if (pBlockPosition == TargetBlockPosition.AsteroidShell) tIsAllowed = true; - break; - case AsteroidInnerCore: - if (pBlockPosition == TargetBlockPosition.AsteroidInnerCore) tIsAllowed = true; - break; - default: - break; - } - - if (tIsAllowed) { - pWorld.setBlock(eX, eY, eZ, bmc.getBlock(), bmc.getMeta(), 2); - tFlag = false; - } - } - } - } - return tFlag; - } - - /** - * Pick a random small-ore block from the list of enabled small ores for this dim - * - * @param pDimDef - * @param pRandom - * @return - */ - private boolean doGenerateSmallOreBlock(ModDimensionDef pDimDef, Random pRandom, World pWorld, - AsteroidConfig pAConf, int pX, int pY, int pZ, int pTargetBlockOffset) { - boolean tFlag = true; - // If smallores are enabled... - if (pAConf.SmallOreChance > 0) { - // ... and we hit the random-chance ... - if (pRandom.nextInt(100) < pAConf.SmallOreChance) { - // Do small ores. - int tRandomWeight; - boolean continueSearch = true; - int tFoundOreMeta = -1; - // First find a small ore... - for (int i = 0; (i < 256) && (continueSearch); i++) { - tRandomWeight = pRandom.nextInt(GT_Worldgen_GT_Ore_Layer_Space.sWeight); - for (GT_Worldgen tWorldGen : GalacticGreg.smallOreWorldgenList) { - - if (!(tWorldGen instanceof GT_Worldgen_GT_Ore_SmallPieces_Space)) { - continue; - } - // That is enabled for *this* dim... - if (!((GT_Worldgen_GT_Ore_SmallPieces_Space) tWorldGen).isEnabledForDim(pDimDef)) continue; - - // And in the correct y-level, of ObeyLimits is true... - if (pAConf.ObeyHeightLimits - && !((GT_Worldgen_GT_Ore_SmallPieces_Space) tWorldGen).isAllowedForHeight(pY)) continue; - - // Care about weight - tRandomWeight -= ((GT_Worldgen_GT_Ore_SmallPieces_Space) tWorldGen).mAmount; - if (tRandomWeight <= 0) { - // And return found ore meta - tFoundOreMeta = ((GT_Worldgen_GT_Ore_SmallPieces_Space) tWorldGen).mMeta; - continueSearch = false; - } - } - } - if (tFoundOreMeta > -1) { - // Make the oreID a small ore with correct type - int tCustomOffset = (GTOreTypes.SmallOres.getOffset() + pTargetBlockOffset); - - // Set the smallOre block - GT_TileEntity_Ores_Space - .setOuterSpaceOreBlock(pDimDef, pWorld, pX, pY, pZ, tFoundOreMeta, true, tCustomOffset); - tFlag = false; - } - } - } - return tFlag; - } - - /** - * Untested! But should work... Comments are todo - * - * @param pDimensionDef - * @param pRandom - * @param pWorld - * @param pX - * @param pZ - * @param pBiome - * @param pChunkGenerator - * @param pChunkProvider - */ - private void Generate_OreVeins(ModDimensionDef pDimensionDef, Random pRandom, World pWorld, int pX, int pZ, - String pBiome, IChunkProvider pChunkGenerator, IChunkProvider pChunkProvider) { - GalacticGreg.Logger.trace("Running orevein-gen in Dim %s", pDimensionDef.getDimIdentifier()); - - if (GT_Worldgenerator.isOreChunk(pX / 16, pZ / 16)) { - if ((GT_Worldgen_GT_Ore_Layer_Space.sWeight > 0) && (GalacticGreg.oreVeinWorldgenList.size() > 0)) { - - boolean temp = true; - int tRandomWeight; - for (int i = 0; (i < 256) && (temp); i++) { - tRandomWeight = pRandom.nextInt(GT_Worldgen_GT_Ore_Layer_Space.sWeight); - for (GT_Worldgen tWorldGen : GalacticGreg.oreVeinWorldgenList) { - if (tWorldGen instanceof GT_Worldgen_GT_Ore_Layer_Space) - tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer_Space) tWorldGen).mWeight; - - if (tRandomWeight <= 0) { - try { - if (tWorldGen.executeWorldgen( - pWorld, - pRandom, - pBiome, - Integer.MIN_VALUE, - pX, - pZ, - pChunkGenerator, - pChunkProvider)) { - temp = false; - } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - break; - } - } - } - } - // Generate Small Ores - - int i = 0; - for (int tX = pX - 16; i < 3; tX += 16) { - int j = 0; - for (int tZ = pZ - 16; j < 3; tZ += 16) { - for (GT_Worldgen tWorldGen : GalacticGreg.smallOreWorldgenList) { - try { - tWorldGen.executeWorldgen( - pWorld, - pRandom, - "", - Integer.MIN_VALUE, - tX, - tZ, - pChunkGenerator, - pChunkProvider); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - j++; - } - i++; - } - } - GalacticGreg.Logger.trace("Leaving orevein-gen for Dim %s", pDimensionDef.getDimIdentifier()); - } -} diff --git a/src/main/java/bloodasp/galacticgreg/GalacticGreg.java b/src/main/java/bloodasp/galacticgreg/GalacticGreg.java deleted file mode 100644 index 2e566dca1d..0000000000 --- a/src/main/java/bloodasp/galacticgreg/GalacticGreg.java +++ /dev/null @@ -1,113 +0,0 @@ -package bloodasp.galacticgreg; - -import static gregtech.api.enums.Mods.AppliedEnergistics2; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import bloodasp.galacticgreg.auxiliary.GalacticGregConfig; -import bloodasp.galacticgreg.auxiliary.LogHelper; -import bloodasp.galacticgreg.auxiliary.ProfilingStorage; -import bloodasp.galacticgreg.command.AEStorageCommand; -import bloodasp.galacticgreg.command.ProfilingCommand; -import bloodasp.galacticgreg.registry.GalacticGregRegistry; -import bloodasp.galacticgreg.schematics.SpaceSchematicHandler; -import cpw.mods.fml.common.Mod;