diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
11 files changed, 727 insertions, 70 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 6dfcab91a7..1a5ef735f5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -1,23 +1,36 @@ package gtPlusPlus.xmod.gregtech; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import gregtech.api.GregTech_API; import gregtech.api.util.GT_Config; +import gregtech.api.world.GT_Worldgen; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.RECIPES_LaserEngraver; 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; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.loaders.*; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; +import net.minecraftforge.common.config.Configuration; public class HANDLER_GT { public static GT_Config mMaterialProperties = null; + + public static GTPP_Config sCustomWorldgenFile = null; + public static final List<GTPP_Worldgen> sCustomWorldgenList = new ArrayList<GTPP_Worldgen>(); @SuppressWarnings("unused") public static void preInit(){ new MetaGeneratedGregtechItems(); + if (mMaterialProperties != null){ GT_Materials.init(mMaterialProperties); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java new file mode 100644 index 0000000000..5a5ddd9d53 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GTPP_Config.java @@ -0,0 +1,98 @@ +package gtPlusPlus.xmod.gregtech.api.util; + +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +import static gregtech.api.enums.GT_Values.E; + +public class GTPP_Config implements Runnable { + public static boolean troll = false; + + public static Configuration sConfigFileIDs; + public final Configuration mConfig; + + public GTPP_Config(Configuration aConfig) { + mConfig = aConfig; + mConfig.load(); + mConfig.save(); + } + + public static int addIDConfig(Object aCategory, String aName, int aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = sConfigFileIDs.get(aCategory.toString().replaceAll("\\|", "."), aName.replaceAll("\\|", "."), aDefault); + int rResult = tProperty.getInt(aDefault); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sConfigFileIDs.save(); + return rResult; + } + + public static String getStackConfigName(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return E; + Object rName = GT_OreDictUnificator.getAssociation(aStack); + if (rName != null) return rName.toString(); + try { + if (GT_Utility.isStringValid(rName = aStack.getUnlocalizedName())) return rName.toString(); + } catch (Throwable e) {/*Do nothing*/} + String sName = aStack.getItem().toString(); + String[] tmp = sName.split("@"); + if (tmp.length > 0) sName = tmp[0]; + return sName + "." + aStack.getItemDamage(); + } + + public boolean get(Object aCategory, ItemStack aStack, boolean aDefault) { + String aName = getStackConfigName(aStack); + return get(aCategory, aName, aDefault); + } + + public boolean get(Object aCategory, String aName, boolean aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + boolean rResult = tProperty.getBoolean(aDefault); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + + public int get(Object aCategory, ItemStack aStack, int aDefault) { + return get(aCategory, getStackConfigName(aStack), aDefault); + } + + public int get(Object aCategory, String aName, int aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + int rResult = tProperty.getInt(aDefault); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + + public double get(Object aCategory, ItemStack aStack, double aDefault) { + return get(aCategory, getStackConfigName(aStack), aDefault); + } + + public double get(Object aCategory, String aName, double aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + double rResult = tProperty.getDouble(aDefault); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + + public String get(Object aCategory, ItemStack aStack, String aDefault) { + return get(aCategory, getStackConfigName(aStack), aDefault); + } + + public String get(Object aCategory, String aName, String aDefault) { + if (GT_Utility.isStringInvalid(aName)) return aDefault; + Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault); + String rResult = tProperty.getString(); + if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save(); + return rResult; + } + + @Override + public void run() { + mConfig.save(); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java new file mode 100644 index 0000000000..6b627bd8a8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen.java @@ -0,0 +1,61 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; + +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; + +public abstract class GTPP_Worldgen{ + + public final String mWorldGenName; + public final boolean mEnabled; + private final Map<String, Boolean> mDimensionMap = new ConcurrentHashMap<String, Boolean>(); + + public GTPP_Worldgen(String aName, List aList, boolean aDefault) { + mWorldGenName = aName; + mEnabled = sCustomWorldgenFile.get("worldgen", mWorldGenName, aDefault); + if (mEnabled) aList.add(this); + } + + /** + * @param aWorld The World Object + * @param aRandom The Random Generator to use + * @param aBiome The Name of the Biome (always != null) + * @param aDimensionType The Type of Worldgeneration to add. -1 = Nether, 0 = Overworld, +1 = End + * @param aChunkX xCoord of the Chunk + * @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) { + return false; + } + + /** + * @param aWorld The World Object + * @param aRandom The Random Generator to use + * @param aBiome The Name of the Biome (always != null) + * @param aDimensionType The Type of Worldgeneration to add. -1 = Nether, 0 = Overworld, +1 = End + * @param aChunkX xCoord of the Chunk + * @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) { + return false; + } + + public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { + String aDimName = aWorld.provider.getDimensionName(); + Boolean tAllowed = mDimensionMap.get(aDimName); + if (tAllowed == null) { + 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/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java new file mode 100644 index 0000000000..80bf3ca691 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Boulder.java @@ -0,0 +1,76 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import java.util.Collection; +import java.util.Random; + +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); + } + + @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)) { + for (int i = 0; i < mAmount; i++) { + 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)) { + float math_pi = 3.141593F; + 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 var7 = (var10b + var3b); + float var11 = (var11b + var4b); + int var5b = aRandom.nextInt(3);int var6b = aRandom.nextInt(3);int var7b = var6b - var5b; + float var15 = (tY + var5b - 2); + float var12b = math_pi / mSize; + + for (int var19 = 0; var19 <= mSize; ++var19) { + float var2b = var19 / mSize; + float var20 = var7 + var8b * var2b; + float var22 = var15 + var7b * var2b; + float var24 = var11 + var9b * var2b; + float var26 = aRandom.nextFloat() * mSize / 16.0F; + float var28 = ((MathHelper.sin(var19 * var12b) + 1.0F) * var26 + 1.0F) / 2.0F; + int var32 = MathHelper.floor_float(var20 - var28); + int var33 = MathHelper.floor_float(var22 - var28); + int var34 = MathHelper.floor_float(var24 - var28); + int var35 = MathHelper.floor_float(var20 + var28); + int var36 = MathHelper.floor_float(var22 + var28); + int var37 = MathHelper.floor_float(var24 + var28); + + for (int var38 = var32; var38 <= var35; ++var38) { + float var39 = (var38 + 0.5F - var20) / (var28); + float var13b = var39 * var39; + if (var13b < 1.0F) { + for (int var41 = var33; var41 <= var36; ++var41) { + float var42 = (var41 + 0.5F - var22) / (var28); + float var14b = var13b + var42 * var42; + if (var14b < 1.0F) { + 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)))) { + aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); + } + } + } + } + } + } + } + } + } + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java new file mode 100644 index 0000000000..eb91919686 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_GT_Ore_Layer.java @@ -0,0 +1,127 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.world.GT_Worldgen; +import gregtech.common.blocks.GT_TileEntity_Ores; +import gregtech.loaders.misc.GT_Achievements; +import gtPlusPlus.core.material.Material; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import java.util.ArrayList; +import java.util.Random; + +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."; + + 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"); + + 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"); + + 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 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); + + 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)) { + GT_TileEntity_Ores.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))) { + GT_TileEntity_Ores.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)) { + GT_TileEntity_Ores.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))) { + GT_TileEntity_Ores.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; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java new file mode 100644 index 0000000000..aae3bdd48a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Handler.java @@ -0,0 +1,41 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +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 + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java new file mode 100644 index 0000000000..8f68cb2179 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore.java @@ -0,0 +1,32 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import gtPlusPlus.xmod.gregtech.HANDLER_GT; +import net.minecraft.block.Block; + +import static gtPlusPlus.xmod.gregtech.HANDLER_GT.sCustomWorldgenFile; + +import java.util.ArrayList; +import java.util.Collection; + +public abstract class GTPP_Worldgen_Ore extends GTPP_Worldgen { + public final int mBlockMeta, mAmount, mSize, mMinY, mMaxY, mProbability, mDimensionType; + public final Block mBlock; + public final Collection<String> mBiomeList; + public final boolean mAllowToGenerateinVoid; + private final String aTextWorldgen = "worldgen."; + + public GTPP_Worldgen_Ore(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, HANDLER_GT.sCustomWorldgenList, aDefault); + mDimensionType = aDimensionType; + mBlock = aBlock; + mBlockMeta = Math.min(Math.max(aBlockMeta, 0), 15); + mProbability = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "Probability", aProbability); + mAmount = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "Amount", aAmount); + mSize = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "Size", aSize); + mMinY = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "MinHeight", aMinY); + mMaxY = sCustomWorldgenFile.get(aTextWorldgen + mWorldGenName, "MaxHeight", aMaxY); + if (aBiomeList == null) mBiomeList = new ArrayList<String>(); + else mBiomeList = aBiomeList; + mAllowToGenerateinVoid = aAllowToGenerateinVoid; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java new file mode 100644 index 0000000000..78d414fc4b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GTPP_Worldgen_Ore_Normal.java @@ -0,0 +1,74 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +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; + +import java.util.Collection; +import java.util.Random; + +public class GTPP_Worldgen_Ore_Normal extends GTPP_Worldgen_Ore { + public GTPP_Worldgen_Ore_Normal(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)) { + for (int i = 0; i < mAmount; i++) { + int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); + if (mAllowToGenerateinVoid || aWorld.getBlock(tX, tY, tZ).isAir(aWorld, tX, tY, tZ)) { + float math_pi = 3.141593F;float var1b = mSize / 8.0F; + float var6 = aRandom.nextFloat() * math_pi; + 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; + float var15 = (tY + var5b - 2); + float var12b = math_pi / mSize; + + for (int var19 = 0; var19 <= mSize; ++var19) { + float var2b = var19 / mSize; + float var20 = var7 + var8b * var2b; + float var22 = var15 + var7b * var2b; + float var24 = var11 + var9b * var2b; + float var26 = aRandom.nextFloat() * mSize / 16.0F; + float var28 = ((MathHelper.sin(var19 * var12b) + 1.0F) * var26 + 1.0F) / 2.0F; + int var32 = MathHelper.floor_float(var20 - var28); + int var33 = MathHelper.floor_float(var22 - var28); + int var34 = MathHelper.floor_float(var24 - var28); + int var35 = MathHelper.floor_float(var20 + var28); + int var36 = MathHelper.floor_float(var22 + var28); + int var37 = MathHelper.floor_float(var24 + var28); + + for (int var38 = var32; var38 <= var35; ++var38) { + float var39 = (var38 + 0.5F - var20) / (var28); + float var13b = var39 * var39; + if (var13b < 1.0F) { + for (int var41 = var33; var41 <= var36; ++var41) { + float var42 = (var41 + 0.5F - var22) / (var28); + float var14b = var13b + var42 * var42; + if (var14b < 1.0F) { + 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.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.end_stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.netherrack))))) { + aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); + } + } + } + } + } + } + } + } + } + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java new file mode 100644 index 0000000000..770083fee8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/GT_OreVein_Object.java @@ -0,0 +1,31 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import gtPlusPlus.core.material.Material; + +public class GT_OreVein_Object { + + final String mOreMixName; //String aName, + final int minY, maxY; //int aMinY, int aMaxY, + final int weight; //int aWeight, + final int density; //int aDensity, + final int size; //int aSize, + final Material aPrimary; //Materials aPrimary, + final Material aSecondary; //Materials aSecondary, + final Material aBetween; //Materials aBetween, + final Material aSporadic; //Materials aSporadic + + GT_OreVein_Object(String mOreMixName, int minY, int maxY, int weight, int density, int size, + Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ + this.mOreMixName = mOreMixName; + this.minY = minY; + this.maxY = maxY; + this.weight = weight; + this.density = density; + this.size = size; + this.aPrimary = aPrimary; + this.aSecondary = aSecondary; + this.aBetween = aBetween; + this.aSporadic = aSporadic; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java b/src/Java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java new file mode 100644 index 0000000000..fd0738596a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/world/WorldGenUtils.java @@ -0,0 +1,23 @@ +package gtPlusPlus.xmod.gregtech.api.world; + +import java.util.ArrayList; +import java.util.List; + +import gtPlusPlus.core.material.Material; + +public class WorldGenUtils { + + static List<GT_OreVein_Object> mOresToRegister = new ArrayList<GT_OreVein_Object>(); + + public static final void addNewOreMixForWorldgen(GT_OreVein_Object newVein){ + mOresToRegister.add(newVein); + } + + public static boolean generateNewOreVeinObject(String mOreMixName, int minY, int maxY, int weight, int density, int size, + Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic){ + GT_OreVein_Object newVein = new GT_OreVein_Object(mOreMixName, minY, maxY, weight, density, size, aPrimary, aSecondary, aBetween, aSporadic); + addNewOreMixForWorldgen(newVein); + return true; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java index 09fa9dc2c3..11ac10db69 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java @@ -10,6 +10,13 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; @@ -21,6 +28,7 @@ import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.material.nuclear.NUCLIDE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import net.minecraft.entity.player.InventoryPlayer; @@ -35,7 +43,6 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase protected int fuelConsumption = 0; protected int fuelValue = 0; protected int fuelRemaining = 0; - protected double realOptFlow = 0; protected boolean boostEu = false; protected boolean heliumSparging = false; @@ -78,13 +85,15 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase "Liquid Fluoride Thorium Reactor", tRunning, tMaintainance, - "Current Output: "+((this.mEUt*this.mEfficiency)/10000)+" EU/t", + "Current Output: "+this.mEUt+" EU/t", "Fuel Consumption: "+this.fuelConsumption+"L/t", "Fuel Value: "+this.fuelValue+" EU/L", "Fuel Remaining: "+this.fuelRemaining+" Litres", - "Current Efficiency: "+(this.mEfficiency/100)+"%", - "Optimal Fuel Flow: "+(int)this.realOptFlow+" L/t", - "Current Speed: "+(this.mEfficiency/100)+"%",}; + "Current Efficiency: "+(this.mEfficiency/5)+"%", + "Current Efficiency (Raw): "+(this.mEfficiency), + "Boosted Output: "+this.boostEu+".", + "Boosted Output gives 4x EU/t for double fuel usage.", + "It requires you to have 100% Efficiency."}; } @Override @@ -99,11 +108,22 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(12)], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR)}; + if (!aBaseMetaTileEntity.isActive() || this.mEfficiency < 500){ + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(12)], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(12)]}; + } + else if(aBaseMetaTileEntity.isActive() && this.mEfficiency >= 500){ + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(13)], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_REPLICATOR)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(13)]}; } return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(12)]}; + } @Override @@ -147,14 +167,14 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase if ((h == 0) || (h == 3)) { //If not a hatch, continue, else add hatch and continue. - if ((!this.addMufflerToMachineList(tTileEntity, 70)) && (!this.addOutputToMachineList(tTileEntity, 70)) && (!this.addDynamoToMachineList(tTileEntity, 70))) { + if ((!this.addMufflerToMachineList(tTileEntity, TAE.GTPP_INDEX(12))) && (!this.addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(12))) && (!this.addDynamoToMachineList(tTileEntity, TAE.GTPP_INDEX(12)))) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("LFTR Casing(s) Missing from one of the top layers inner 3x3."); + Utils.LOG_INFO("Hastelloy-N Reactor Casing(s) Missing from one of the top layers inner 3x3."); Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO("LFTR Casing(s) Missing from one of the top layers inner 3x3. Wrong Meta for Casing."); + Utils.LOG_INFO("Hastelloy-N Reactor Casing(s) Missing from one of the top layers inner 3x3. Wrong Meta for Casing."); return false; } } @@ -176,12 +196,12 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase /* else { //carbon moderation rods are at 1,1 & -1,-1 & 1,-1 & -1,1 if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("LFTR Casing(s) Missing from one of the top layers inner 3x3."); - Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + Utils.LOG_WARNING("LFTR Casing(s) Missing from one of the top layers inner 3x3."); + Utils.LOG_WARNING("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO("LFTR Casing(s) Missing from one of the top layers inner 3x3."); + Utils.LOG_WARNING("LFTR Casing(s) Missing from one of the top layers inner 3x3."); return false; } }*/ @@ -194,12 +214,12 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase //Deal with all 4 sides (Reactor walls) if ((h == 1) || (h == 2)) { if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); + Utils.LOG_INFO("Reactor Shielding Missing from somewhere in the second layer."); Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 13) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); + Utils.LOG_INFO("Reactor Shielding Missing from somewhere in the second layer."); Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } @@ -211,12 +231,12 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase if (((xDir + i) != 0) || ((zDir + j) != 0)) {//no controller if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("LFTR Casing(s) Missing from one of the edges on the top layer."); + Utils.LOG_INFO("Hastelloy-N Reactor Casing(s) Missing from one of the edges on the top layer."); Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO("LFTR Casing(s) Missing from one of the edges on the top layer. "+h); + Utils.LOG_INFO("Hastelloy-N Reactor Casing(s) Missing from one of the edges on the top layer. "+h); Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); if (h ==0){ if (tTileEntity instanceof GregtechMTE_NuclearReactor){ @@ -235,14 +255,11 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } } - if (this.mMufflerHatches.size() != 4){ - Utils.LOG_INFO("You require EXACTLY 4 muffler hatches on top. FOUR."); - return false; - } - if (this.mEnergyHatches != null) { - for (int i = 0; i < this.mEnergyHatches.size(); i++) { - if (this.mEnergyHatches.get(i).mTier < 5){ - Utils.LOG_INFO("You require at LEAST V tier Energy Hatches."); + + if (this.mDynamoHatches != null) { + for (int i = 0; i < this.mDynamoHatches.size(); i++) { + if (this.mDynamoHatches.get(i).mTier < 5){ + Utils.LOG_INFO("You require at LEAST IV tier Dynamo Hatches."); Utils.LOG_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); return false; } @@ -252,7 +269,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase for (int i = 0; i < this.mOutputHatches.size(); i++) { if ((this.mOutputHatches.get(i).mTier < 5) && (this.mOutputHatches.get(i).getBaseMetaTileEntity() instanceof GregtechMTE_NuclearReactor)){ - Utils.LOG_INFO("You require at LEAST V tier Output Hatches."); + Utils.LOG_INFO("You require at LEAST IV tier Output Hatches."); Utils.LOG_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); Utils.LOG_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName()); return false; @@ -262,20 +279,40 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase if (this.mInputHatches != null) { for (int i = 0; i < this.mInputHatches.size(); i++) { if (this.mInputHatches.get(i).mTier < 5){ - Utils.LOG_INFO("You require at LEAST V tier Input Hatches."); + Utils.LOG_INFO("You require at LEAST IV tier Input Hatches."); Utils.LOG_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); Utils.LOG_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName()); return false; } } } + if (this.mMufflerHatches.size() != 4){ + Utils.LOG_INFO("You require EXACTLY 4 muffler hatches on top. FOUR. You have "+this.mMufflerHatches.size()); + return false; + } + if (this.mInputHatches.size() < 4){ + Utils.LOG_INFO("You require 4 or more input hatches. You have "+this.mInputHatches.size()); + return false; + } + if (this.mOutputHatches.size() < 10){ + Utils.LOG_INFO("You require 10 or more output hatches. You have "+this.mOutputHatches.size()); + return false; + } + if (this.mDynamoHatches.size() != 4){ + Utils.LOG_INFO("You require EXACTLY 4 dynamo hatches. FOUR. You have "+this.mDynamoHatches.size()); + return false; + } + if (this.mMaintenanceHatches.size() != 2){ + Utils.LOG_INFO("You require EXACTLY 2 muffler hatches. TWO. You have "+this.mMaintenanceHatches.size()); + return false; + } this.mWrench = true; this.mScrewdriver = true; this.mSoftHammer = true; this.mHardHammer = true; this.mSolderingTool = true; this.mCrowbar = true; - this.turnCasingActive(true); + this.turnCasingActive(false); Utils.LOG_INFO("Multiblock Formed."); return true; } @@ -292,7 +329,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase @Override public int getPollutionPerTick(final ItemStack aStack) { - return 5; + return this.boostEu ? 8 : 4; } @Override @@ -316,36 +353,31 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase public boolean turnCasingActive(final boolean status) { //TODO - /*if (this.mDynamoHatches != null) { + if (this.mDynamoHatches != null) { for (final GT_MetaTileEntity_Hatch_Dynamo hatch : this.mDynamoHatches) { - hatch.mMachineBlock = status ? (byte) 70 : (byte) 71; + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); } } if (this.mMufflerHatches != null) { for (final GT_MetaTileEntity_Hatch_Muffler hatch : this.mMufflerHatches) { - hatch.mMachineBlock = status ? (byte) 70 : (byte) 71; + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); } } if (this.mOutputHatches != null) { for (final GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { - hatch.mMachineBlock = status ? (byte) 70 : (byte) 71; + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); } } if (this.mInputHatches != null) { for (final GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { - hatch.mMachineBlock = status ? (byte) 70 : (byte) 71; + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); } } - if (this.mOutputBusses != null) { - for (final GT_MetaTileEntity_Hatch_OutputBus hatch : this.mOutputBusses) { - hatch.mMachineBlock = status ? (byte) 70 : (byte) 71; + if (this.mMaintenanceHatches != null) { + for (final GT_MetaTileEntity_Hatch_Maintenance hatch : this.mMaintenanceHatches) { + hatch.mMachineBlock = status ? (byte) TAE.GTPP_INDEX(13) : (byte) TAE.GTPP_INDEX(12); } } - if (this.mInputBusses != null) { - for (final GT_MetaTileEntity_Hatch_InputBus hatch : this.mInputBusses) { - hatch.mMachineBlock = status ? (byte) 70 : (byte) 71; - } - }*/ return true; } @@ -356,23 +388,18 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase final ArrayList<FluidStack> tFluids = this.getStoredFluids(); final Collection<GT_Recipe> tRecipeList = Recipe_GT.Gregtech_Recipe_Map.sLiquidFluorineThoriumReactorRecipes.mRecipeList; if((tFluids.size() > 0) && (tRecipeList != null)) { //Does input hatch have a LFTR fuel? - Utils.LOG_INFO("Found more than one input fluid and a list of valid recipes."); - final boolean containsFLIBE = false; - final boolean containsPrimarySalt = false; + Utils.LOG_WARNING("Found more than one input fluid and a list of valid recipes."); for (final FluidStack hatchFluid1 : tFluids) { //Loops through hatches - Utils.LOG_INFO("Looping through Input hatches - Found "+hatchFluid1.getLocalizedName()); + Utils.LOG_WARNING("Looping through Input hatches - Found "+hatchFluid1.getLocalizedName()); for(final GT_Recipe aFuel : tRecipeList) { //Loops through LFTR fuel recipes - Utils.LOG_INFO("Looping through Recipes. "+aFuel.mSpecialValue); + Utils.LOG_WARNING("Looping through Recipes. "+aFuel.mSpecialValue); FluidStack tLiquid; final FluidStack testStack = aFuel.mFluidInputs[1]; if ((tLiquid = testStack) != null) { //Create fluidstack from current recipe - Utils.LOG_INFO("Creating a fluidstack from the current recipe. "+testStack.getLocalizedName()); + Utils.LOG_WARNING("Creating a fluidstack from the current recipe. "+testStack.getLocalizedName()); if (hatchFluid1.isFluidEqual(tLiquid)) { //Has a LFTR fluid this.fuelConsumption = this.boostEu ? (aFuel.mSpecialValue/4096) : (aFuel.mSpecialValue/2048); //Calc fuel consumption - Utils.LOG_INFO("Input hatch contains some FLiBe Fuel, using "+this.fuelConsumption); - if(this.depleteInput(tLiquid)) { //Deplete that amount - Utils.LOG_INFO("Depleted some FLiBe fluid"); - + this.mMaxProgresstime = 500; if(tFluids.contains(NUCLIDE.LiFBeF2ThF4UF4.getFluid(1)) || @@ -383,18 +410,39 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase //U235 fuel is 10x less efficient than UF4 with Thorium, UF4 with Zirconium is only 2x less efficient than UF4 with Thorium. //Most Efficient if(tFluids.contains(NUCLIDE.LiFBeF2ThF4UF4.getFluid(2))){ + + FluidStack depletionStack = FluidUtils.getFluidStack(tLiquid, (this.boostEu ? (aFuel.mSpecialValue/4096) : (aFuel.mSpecialValue/2048))); + Utils.LOG_WARNING("Input hatch contains some FLiBe Fuel, using "+this.fuelConsumption+" | "+aFuel.mSpecialValue+" | "+depletionStack.amount); + if(this.depleteInput(depletionStack)) { //Deplete that amount + Utils.LOG_WARNING("Depleted some FLiBe fluid"); + } + this.depleteInput(NUCLIDE.LiFBeF2ThF4UF4.getFluid(this.boostEu ? 2 : 1)); - Utils.LOG_INFO("Depleted "+(this.boostEu ? 2 : 1)+"L of LiFBeF2ThF4UF4 fluid"); + Utils.LOG_WARNING("Depleted "+(this.boostEu ? 2 : 1)+"L of LiFBeF2ThF4UF4 fluid"); } //1/2 as Efficient if (tFluids.contains(NUCLIDE.LiFBeF2ZrF4UF4.getFluid(4))){ + + FluidStack depletionStack = FluidUtils.getFluidStack(tLiquid, (this.boostEu ? (aFuel.mSpecialValue/4096) : (aFuel.mSpecialValue/2048))); + Utils.LOG_WARNING("Input hatch contains some FLiBe Fuel, using "+this.fuelConsumption+" | "+aFuel.mSpecialValue+" | "+depletionStack.amount); + if(this.depleteInput(depletionStack)) { //Deplete that amount + Utils.LOG_WARNING("Depleted some FLiBe fluid"); + } + this.depleteInput(NUCLIDE.LiFBeF2ZrF4UF4.getFluid(this.boostEu ? 4 : 2)); - Utils.LOG_INFO("Depleted "+(this.boostEu ? 4 : 2)+"L of LiFBeF2ZrF4UF4 fluid"); + Utils.LOG_WARNING("Depleted "+(this.boostEu ? 4 : 2)+"L of LiFBeF2ZrF4UF4 fluid"); } //10x less Efficient. if (tFluids.contains(NUCLIDE.LiFBeF2ZrF4U235.getFluid(20))) { + + FluidStack depletionStack = FluidUtils.getFluidStack(tLiquid, (this.boostEu ? (aFuel.mSpecialValue/4096) : (aFuel.mSpecialValue/2048))); + Utils.LOG_WARNING("Input hatch contains some FLiBe Fuel, using "+this.fuelConsumption+" | "+aFuel.mSpecialValue+" | "+depletionStack.amount); + if(this.depleteInput(depletionStack)) { //Deplete that amount + Utils.LOG_WARNING("Depleted some FLiBe fluid"); + } + this.depleteInput(NUCLIDE.LiFBeF2ZrF4U235.getFluid(this.boostEu ? 20 : 10)); - Utils.LOG_INFO("Depleted "+(this.boostEu ? 20 : 10)+"L of LiFBeF2ZrF4U235 fluid"); + Utils.LOG_WARNING("Depleted "+(this.boostEu ? 20 : 10)+"L of LiFBeF2ZrF4U235 fluid"); } } } else { @@ -407,7 +455,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase if (this.depleteInput(Materials.Helium.getGas(1000L))){ //Make an empty fluid stack for possible sparging output FluidStack[] spargeOutput = new FluidStack[]{}; - Utils.LOG_INFO("Doing a Sparge with Helium - "+this.heliumSparging); + Utils.LOG_WARNING("Doing a Sparge with Helium - "+this.heliumSparging); this.heliumSparging = false; spargeOutput = this.getByproductsOfSparge(Materials.Helium.getGas(1000L)); @@ -415,7 +463,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase try { if (spargeOutput.length >= 1){ for (final FluidStack F : spargeOutput){ - Utils.LOG_INFO("Adding Sparge Output - "+F.getLocalizedName()); + Utils.LOG_WARNING("Adding Sparge Output - "+F.getLocalizedName()); this.addOutput(F); } } @@ -427,13 +475,13 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase if (this.depleteInput(Materials.Fluorine.getGas(100L))){ //Make an empty fluid stack for possible sparging output FluidStack[] spargeOutput = new FluidStack[]{}; - Utils.LOG_INFO("Doing a Sparge with Fluorine"); + Utils.LOG_WARNING("Doing a Sparge with Fluorine"); spargeOutput = this.getByproductsOfSparge(Materials.Fluorine.getGas(100L)); this.heliumSparging = true; //If Sparging occurred, try add the outputs to the output hatches. if (spargeOutput.length > 0){ for (final FluidStack F : spargeOutput){ - Utils.LOG_INFO("Adding Sparge Output - "+F.getLocalizedName()); + Utils.LOG_WARNING("Adding Sparge Output - "+F.getLocalizedName()); this.addOutput(F); } } @@ -442,7 +490,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase if (aFuel != null){ - //Utils.LOG_INFO("Saving previous Recipe."); + //Utils.LOG_WARNING("Saving previous Recipe."); //this.mLastRecipe = aFuel; } @@ -460,11 +508,11 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase else if (this.mEfficiency > 500){ this.mEfficiency = 500; } - Utils.LOG_INFO("Efficiency == "+this.mEfficiency); - - this.mEUt = (this.mEfficiency < 500 ? 2048 : (8196*4)); //Output 0 if startup is less than 20% - Utils.LOG_INFO("Generating "+this.mEUt+"EU/t @ an efficiency level of "+this.mEfficiency); + Utils.LOG_WARNING("Efficiency == "+this.mEfficiency); + this.mEUt = (this.mEfficiency < 500 ? 2048 : (8196)); //Output 0 if startup is less than 20% + Utils.LOG_WARNING("Generating "+this.mEUt+"EU/t @ an efficiency level of "+this.mEfficiency); + this.mProgresstime = 1; this.mMaxProgresstime = 1; this.mEfficiencyIncrease = 15; @@ -476,8 +524,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } } } - } - } + } } this.mEUt = 0; this.mEfficiency = 0; @@ -487,7 +534,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase public int getAmountOfOutputs() { - return 1; + return 10; } @Override @@ -543,7 +590,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase MathUtils.roundToClosestInt(MathUtils.randInt(10, 100)/10) }; final int heliumContent = (1000-outputChances[0]-outputChances[1]-outputChances[2]-outputChances[3]-outputChances[4]); - Utils.LOG_INFO("Helium remaining: "+heliumContent); + Utils.LOG_WARNING("Helium remaining: "+heliumContent); outputArrayOfGases = new FluidStack[]{ ELEMENT.getInstance().XENON.getFluid(outputChances[0]), ELEMENT.getInstance().NEON.getFluid(outputChances[1]), @@ -561,7 +608,7 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase MathUtils.roundToClosestInt(MathUtils.randDouble(1, 50)/10) }; final int fluorineContent = (100-outputChances[0]-outputChances[1]-outputChances[2]-outputChances[3]); - Utils.LOG_INFO("Fluorine remaining: "+fluorineContent); + Utils.LOG_WARNING("Fluorine remaining: "+fluorineContent); outputArrayOfGases = new FluidStack[]{ FLUORIDES.LITHIUM_FLUORIDE.getFluid(outputChances[0]), FLUORIDES.NEPTUNIUM_HEXAFLUORIDE.getFluid(outputChances[1]), @@ -574,4 +621,38 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase return outputArrayOfGases; } + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + //Add Power if active + if (aBaseMetaTileEntity.isActive()){ + //this.getBaseMetaTileEntity().increaseStoredEnergyUnits(this.mEUt, false); + + if (this.mEfficiency >= 500){ + this.boostEu = true; + this.turnCasingActive(true); + } + else { + this.boostEu = false; + this.turnCasingActive(false); + } + + + if (this.mDynamoHatches != null) { + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : this.mDynamoHatches) { + if (tHatch.mTier >= 5){ + if (isValidMetaTileEntity(tHatch)){ + tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(this.mEUt, false); + //Utils.LOG_WARNING("Adding "+this.mEUt+"eu to internal storage of dynamo "+hatchNo+"."); + } + } + } + } + + } + else { + this.turnCasingActive(false); + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + }
\ No newline at end of file |