aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/GT_Client.java3
-rw-r--r--src/main/java/gregtech/common/GT_Proxy.java17
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java234
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java13
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_Stone.java240
-rw-r--r--src/main/java/gregtech/common/GT_Worldgenerator.java344
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Block_Concretes.java15
-rw-r--r--src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java57
-rw-r--r--src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java37
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java8
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java405
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java34
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java46
13 files changed, 1003 insertions, 450 deletions
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java
index f3203bab1e..1091232d38 100644
--- a/src/main/java/gregtech/common/GT_Client.java
+++ b/src/main/java/gregtech/common/GT_Client.java
@@ -34,6 +34,8 @@ import net.minecraft.stats.StatFileWriter;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
+import net.minecraftforge.client.event.EntityViewRenderEvent;
+import net.minecraftforge.event.terraingen.BiomeEvent;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.opengl.GL11;
@@ -146,7 +148,6 @@ public class GT_Client extends GT_Proxy
GL11.glVertex3d(+.25D, .0D, +.50D);
GL11.glVertex3d(-.25D, .0D, -.50D);
GL11.glVertex3d(-.25D, .0D, +.50D);
- GL11.glLineWidth(2.0F);
TileEntity tTile = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ);
if (tTile instanceof BaseMetaPipeEntity) {
int[][] GridSwitchArr = new int[][]{
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java
index 3341721cc2..429bf8830d 100644
--- a/src/main/java/gregtech/common/GT_Proxy.java
+++ b/src/main/java/gregtech/common/GT_Proxy.java
@@ -11,6 +11,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.enums.*;
import gregtech.api.enums.TC_Aspects.TC_AspectStack;
+import gregtech.api.interfaces.IBlockOnWalkOver;
import gregtech.api.interfaces.IProjectileItem;
import gregtech.api.interfaces.internal.IGT_Mod;
import gregtech.api.interfaces.internal.IThaumcraftCompat;
@@ -25,6 +26,7 @@ import gregtech.common.entities.GT_Entity_Arrow;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gregtech.common.items.armor.ModularArmor_Item;
import gregtech.common.items.armor.gui.*;
+import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
@@ -45,6 +47,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
+import net.minecraft.util.MathHelper;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
@@ -53,6 +56,7 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
+import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
@@ -129,6 +133,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
public ArrayList<String> mBufferedPlayerActivity = new ArrayList();
public boolean mHardcoreCables = false;
public boolean mDisableVanillaOres = true;
+ public boolean mHardMachineCasings = true;
public boolean mNerfDustCrafting = true;
public boolean mSortToTheEnd = true;
public boolean mCraftingUnification = true;
@@ -1188,6 +1193,15 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
e.printStackTrace(GT_Log.err);
}
}
+
+ @SubscribeEvent
+ public void onLivingUpdate(LivingUpdateEvent aEvent) {
+ if (aEvent.entityLiving.onGround) {
+ int tX = MathHelper.floor_double(aEvent.entityLiving.posX), tY = MathHelper.floor_double(aEvent.entityLiving.boundingBox.minY-0.001F), tZ = MathHelper.floor_double(aEvent.entityLiving.posZ);
+ Block tBlock = aEvent.entityLiving.worldObj.getBlock(tX, tY, tZ);
+ if (tBlock instanceof IBlockOnWalkOver) ((IBlockOnWalkOver)tBlock).onWalkOver(aEvent.entityLiving, aEvent.entityLiving.worldObj, tX, tY, tZ);
+ }
+ }
@SubscribeEvent
public void onFluidContainerRegistration(FluidContainerRegistry.FluidContainerRegisterEvent aFluidEvent) {
@@ -1263,7 +1277,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
aEvent.player.setGameType(GameType.ADVENTURE);
aEvent.player.capabilities.allowEdit = false;
if (this.mAxeWhenAdventure) {
- GT_Utility.sendChatToPlayer(aEvent.player, "It's dangerous to go alone! Take this.");
+ GT_Utility.sendChatToPlayer(aEvent.player, GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_097", "It's dangerous to go alone! Take this.", false));
aEvent.player.worldObj.spawnEntityInWorld(new EntityItem(aEvent.player.worldObj, aEvent.player.posX, aEvent.player.posY,
aEvent.player.posZ, GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.AXE, 1, Materials.Flint, Materials.Wood, null)));
}
@@ -1790,7 +1804,6 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
return new int[]{LOADED,0,-1,-1};
}
-
@SubscribeEvent
public void handleChunkSaveEvent(ChunkDataEvent.Save event) {//ALWAYS SAVE FROM THE HASH MAP DATA
HashMap<ChunkCoordIntPair,int []> chunkData=dimensionWiseChunkData.get(event.world.provider.dimensionId);
diff --git a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
index dcc256498b..225b85b680 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
@@ -16,7 +16,6 @@ import java.util.ArrayList;
import java.util.Random;
import static gregtech.api.enums.GT_Values.debugOrevein;
-import static gregtech.api.enums.GT_Values.debugWorldGen;
public class GT_Worldgen_GT_Ore_Layer
extends GT_Worldgen {
@@ -37,6 +36,13 @@ public class GT_Worldgen_GT_Ore_Layer
public final boolean mNether;
public final boolean mEnd;
public final boolean mEndAsteroid;
+ public static final int WRONG_BIOME=0;
+ public static final int WRONG_DIMENSION=1;
+ public static final int NO_ORE_IN_BOTTOM_LAYER=2;
+ public static final int NO_OVERLAP=3;
+ public static final int ORE_PLACED=4;
+
+
//public final boolean mMoon;
//public final boolean mMars;
//public final boolean mAsteroid;
@@ -53,14 +59,14 @@ public class GT_Worldgen_GT_Ore_Layer
//this.mAsteroid = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid);
this.mMinY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY));
short mMaxY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY));
- if (mMaxY < (this.mMinY + 7)) {
- GT_Log.out.println(
- "Oremix " + this.mWorldGenName +
- " has invalid Min/Max heights!"
- );
- mMaxY = (short) (this.mMinY + 7);
- }
- this.mMaxY = mMaxY;
+ if (mMaxY < (this.mMinY + 7)) {
+ GT_Log.out.println(
+ "Oremix " + this.mWorldGenName +
+ " has invalid Min/Max heights!"
+ );
+ mMaxY = (short) (this.mMinY + 7);
+ }
+ this.mMaxY = mMaxY;
this.mWeight = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight));
this.mDensity = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity));
this.mSize = ((short) Math.max(1, GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize)));
@@ -82,75 +88,193 @@ public class GT_Worldgen_GT_Ore_Layer
GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd);
sWeight += this.mWeight;
if(GregTech_API.mImmersiveEngineering && GT_Mod.gregtechproxy.mImmersiveEngineeringRecipes){
- blusunrize.immersiveengineering.api.tool.ExcavatorHandler.addMineral(aName.substring(8, 9).toUpperCase()+aName.substring(9), aWeight, 0.2f, new String[]{"ore"+aPrimary.mName,"ore"+aSecondary.mName,"ore"+aBetween.mName,"ore"+aSporadic.mName}, new float[]{.4f,.4f,.15f,.05f});
+ blusunrize.immersiveengineering.api.tool.ExcavatorHandler.addMineral(aName.substring(8, 9).toUpperCase()+aName.substring(9), aWeight, 0.2f, new String[]{"ore"+aPrimary.mName,"ore"+aSecondary.mName,"ore"+aBetween.mName,"ore"+aSporadic.mName}, new float[]{.4f,.4f,.15f,.05f});
}
}
}
- 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
+ public int executeWorldgenChunkified(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, int aSeedX, int aSeedZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
+ if( mWorldGenName.equals("NoOresInVein") ) {
+ if (debugOrevein) GT_Log.out.println(
+ " NoOresInVein"
+ );
+ // This is a special empty orevein
+ return ORE_PLACED;
}
- //if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld)) || ((aDimensionType == 1) && (this.mEnd)) || ((aWorld.provider.getDimensionName().equals("Moon")) && (this.mMoon)) || ((aWorld.provider.getDimensionName().equals("Mars")) && (this.mMars)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) {
if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld)) || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) {
- return false;
+ /* // Debug code, but spams log
+ if (debugOrevein) {
+ GT_Log.out.println(
+ "Wrong dimension"
+ );
+ }
+ */
+ return WRONG_DIMENSION;
+ }
+ if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) {
+ return WRONG_BIOME;
}
- int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5);
+ int[] placeCount=new int[4];
- int cX = aChunkX - aRandom.nextInt(this.mSize);
- int eX = aChunkX + 16 + aRandom.nextInt(this.mSize);
+ int tMinY = mMinY + aRandom.nextInt(mMaxY - mMinY - 5);
+ // Determine West/East ends of orevein
+ int wXVein = aSeedX - aRandom.nextInt(mSize); // West side
+ int eXVein = aSeedX + 16 + aRandom.nextInt(mSize);
+ // Limit Orevein to only blocks present in current chunk
+ int wX = Math.max( wXVein, aChunkX + 2); // Bias placement by 2 blocks to prevent worldgen cascade.
+ int eX = Math.min( eXVein, aChunkX + 2 + 16);
+ if (wX >= eX) { //No overlap between orevein and this chunk exists in X
+ /*
+ if (debugOrevein) {
+ GT_Log.out.println(
+ "No X overlap"
+ );
+ }
+ */
+ return NO_OVERLAP;
+ }
+ // Determine North/Sound ends of orevein
+ int nZVein = aSeedZ - aRandom.nextInt(mSize);
+ int sZVein = aSeedZ + 16 + aRandom.nextInt(mSize);
+
+ int nZ = Math.max(nZVein, aChunkZ + 2); // Bias placement by 2 blocks to prevent worldgen cascade.
+ int sZ = Math.min(sZVein, aChunkZ + 2 + 16);
+ if (nZ >= sZ) { //No overlap between orevein and this chunk exists in Z
+ /*
+ if (debugOrevein) {
+ GT_Log.out.println(
+ "No Z overlap"
+ );
+ }
+ */
+ return NO_OVERLAP;
+ }
+ // Adjust the density down the more chunks we are away from the oreseed. The 5 chunks surrounding the seed should always be max density due to truncation of Math.sqrt().
+ int localDensity = Math.max(1, this.mDensity / ((int)Math.sqrt(2 + Math.pow(aChunkX/16 - aSeedX/16, 2) + Math.pow(aChunkZ/16 - aSeedZ/16, 2))) );
- int[] placeCount=new int[4];
- 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)) {
- if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false))
- placeCount[1]++;
+ // To allow for early exit due to no ore placed in the bottom layer (probably because we are in the sky), unroll 1 pass through the loop
+ // Now we do bottom-level-first oregen, and work our way upwards.
+ int level = tMinY - 1; //Dunno why, but the first layer is actually played one below tMinY. Go figure.
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta > 0) ) {
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) {
+ placeCount[1]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
+ }
+ }
+ if ((placeCount[1]+placeCount[3])==0) {
+ if (debugOrevein) GT_Log.out.println(
+ " No ore in bottom layer"
+ );
+ return NO_ORE_IN_BOTTOM_LAYER; // Exit early, didn't place anything in the bottom layer
+ }
+ for (level = tMinY; level < (tMinY-1+3); level++) {
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta > 0) ) {
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) {
+ placeCount[1]++;
}
}
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
}
- 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))) {
- if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false))
- placeCount[2]++;
+ }
+ }
+ // Low Middle layer is between + sporadic
+ // level should be = tMinY-1+3 from end of for loop
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) {
+ placeCount[2]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
}
- 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)) {
- if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false))
- placeCount[0]++;
+ }
+ // High Middle layer is between + primary + sporadic
+ level++; // Increment level to next layer
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) {
+ placeCount[2]++;
}
}
+ else if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta > 0) ) {
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) {
+ placeCount[0]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
}
- 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))) {
- if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false))
- placeCount[3]++;
+ }
+ // Top two layers are primary + sporadic
+ level++; // Increment level to next layer
+ for( ; level < (tMinY + 6); level++){ // should do two layers
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta > 0) ) {
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) {
+ placeCount[0]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
}
}
- }
+ }
if (debugOrevein) {
- String tDimensionName = aWorld.provider.getDimensionName();
+ String tDimensionName = aWorld.provider.getDimensionName();
GT_Log.out.println(
"Generated Orevein:" + this.mWorldGenName +
- " chunkX="+aChunkX+
- " chunkZ="+aChunkZ+
- " chunkY="+tMinY+
- " Density=" + this.mDensity +
- " Secondary="+placeCount[1]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mSecondaryMeta).getDisplayName()+
- " Between="+placeCount[2]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mBetweenMeta).getDisplayName()+
- " Primary="+placeCount[0]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mPrimaryMeta).getDisplayName()+
- " Sporadic="+placeCount[3]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mSporadicMeta).getDisplayName() +
- " Dimension=" + tDimensionName
+ " Dimension=" + tDimensionName +
+ " mX="+aChunkX/16+
+ " mZ="+aChunkZ/16+
+ " oreseedX="+ aSeedX/16 +
+ " oreseedZ="+ aSeedZ/16 +
+ " cY="+tMinY+
+ " wXVein" + wXVein +
+ " eXVein" + eXVein +
+ " nZVein" + nZVein +
+ " sZVein" + sZVein +
+ " locDen=" + localDensity +
+ " Den=" + this.mDensity +
+ " Sec="+placeCount[1]+
+ " Spo="+placeCount[3]+
+ " Bet="+placeCount[2]+
+ " Pri="+placeCount[0]
);
}
- // Didn't place anything, return false
- if( (placeCount[0] + placeCount[1] + placeCount[2] + placeCount[3]) == 0 )
- return false;
- else
- return true;
+ // Something (at least the bottom layer must have 1 block) must have been placed, return true
+ return ORE_PLACED;
}
}
diff --git a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
index a299698f6d..1bb583908f 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
@@ -47,10 +47,11 @@ public class GT_Worldgen_GT_Ore_SmallPieces
return false;
}
int count=0;
+
if (this.mMeta > 0) {
- int i = 0;
- for (int j = Math.max(1, this.mAmount / 2 + aRandom.nextInt(this.mAmount) / 2); i < j; i++) {
- GT_TileEntity_Ores.setOreBlock(aWorld, aChunkX + aRandom.nextInt(16), this.mMinY + aRandom.nextInt(Math.max(1, this.mMaxY - this.mMinY)), aChunkZ + aRandom.nextInt(16), this.mMeta, true);
+ int j = Math.max(1, this.mAmount / 2 + aRandom.nextInt(this.mAmount) / 2);
+ for ( int i = 0; i < j; i++) {
+ GT_TileEntity_Ores.setOreBlock(aWorld, aChunkX + 8 + aRandom.nextInt(16), this.mMinY + aRandom.nextInt(Math.max(1, this.mMaxY - this.mMinY)), aChunkZ + 8 + aRandom.nextInt(16), this.mMeta, true);
count++;
}
}
@@ -58,9 +59,9 @@ public class GT_Worldgen_GT_Ore_SmallPieces
GT_Log.out.println(
"Small Ore:" + this.mWorldGenName +
" @ dim="+aDimensionType+
- " chunkX="+aChunkX+
- " chunkZ="+aChunkZ+
- " ore="+count+" "+new ItemStack(GregTech_API.sBlockOres1,1,mMeta).getDisplayName()
+ " mX="+aChunkX/16+
+ " mZ="+aChunkZ/16+
+ " ore="+count
);
}
return true;
diff --git a/src/main/java/gregtech/common/GT_Worldgen_Stone.java b/src/main/java/gregtech/common/GT_Worldgen_Stone.java
index c22585d26a..2dc6cb8c10 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_Stone.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_Stone.java
@@ -1,6 +1,8 @@
package gregtech.common;
import gregtech.api.GregTech_API;
+import gregtech.api.objects.XSTR;
+import gregtech.api.util.GT_Log;
import gregtech.api.world.GT_Worldgen_Ore;
import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.blocks.GT_TileEntity_Ores;
@@ -13,78 +15,204 @@ import net.minecraft.world.chunk.IChunkProvider;
import java.util.Collection;
import java.util.Random;
+import java.util.Hashtable;
+import java.util.ArrayList;
+
+import static gregtech.api.enums.GT_Values.debugStones;
public class GT_Worldgen_Stone
extends GT_Worldgen_Ore {
+
+ static final double sizeConversion[] = { 1, 1, 1.333333, 1.333333, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; // Bias the sizes towards skinnier boulders, ie more "shafts" than dikes or sills.
+
+ public Hashtable<Long, StoneSeeds> validStoneSeeds = new Hashtable(1024);
+
+ class StoneSeeds {
+ public boolean mExists;
+
+ StoneSeeds( boolean exists ) {
+ mExists = exists;
+ }
+ };
+
+ class ValidSeeds {
+ public int mX;
+ public int mZ;
+ ValidSeeds( int x, int z) {
+ this.mX = x;
+ this.mZ = z;
+ }
+ };
public GT_Worldgen_Stone(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) {
super(aName, aDefault, aBlock, aBlockMeta, aDimensionType, aAmount, aSize, aProbability, aMinY, aMaxY, aBiomeList, aAllowToGenerateinVoid);
}
public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
- if ((isGenerationAllowed(aWorld, aDimensionType, this.mDimensionType)) && ((this.mBiomeList.isEmpty()) || (this.mBiomeList.contains(aBiome))) && ((this.mProbability <= 1) || (aRandom.nextInt(this.mProbability) == 0))) {
- for (int i = 0; i < this.mAmount; i++) {
- int tX = aChunkX + aRandom.nextInt(16);
- int tY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY);
- int tZ = aChunkZ + aRandom.nextInt(16);
- if ((this.mAllowToGenerateinVoid) || (!aWorld.getBlock(tX, tY, tZ).isAir(aWorld, tX, tY, tZ))) {
- float math_pi = 3.141593F;//FB: CNT - CNT_ROUGH_CONSTANT_VALUE
- float var6 = aRandom.nextFloat() * math_pi;
- float var1d = this.mSize / 8.0F;int var2d = tX + 8;int var3d = tZ + 8;int var4d = tY - 2;
- float mh_s_0 = MathHelper.sin(var6) * var1d;float mh_c_0 = MathHelper.cos(var6) * var1d;
- float var7 = var2d + mh_s_0;
- float var11 = var3d + mh_c_0;
- int var15r = aRandom.nextInt(3);int var17r = aRandom.nextInt(3);
- int var15 = var4d + var15r;
- int mh_n_4=var17r - var15r;
- float mh_n_0 = -2*mh_s_0;float mh_n_1 = -2*mh_c_0;
- for (int var19 = 0; var19 <= this.mSize; var19++) {
- float var5d = var19 / this.mSize;
- float var20 = var7 + mh_n_0 * var5d;
- float var22 = var15 + mh_n_4 * var5d;
- float var24 = var11 + mh_n_1 * var5d;
- float var6d = var19 * math_pi / this.mSize;
- float var26 = aRandom.nextFloat() * this.mSize / 16.0F;
- float var28 = ((MathHelper.sin(var6d) + 1.0F) * var26 + 1.0F) / 2.0F;
- int tMinX = MathHelper.floor_float(var20 - var28);
- int tMinY = MathHelper.floor_float(var22 - var28);
- int tMinZ = MathHelper.floor_float(var24 - var28);
- int tMaxX = MathHelper.floor_float(var20 + var28);
- int tMaxY = MathHelper.floor_float(var22 + var28);
- int tMaxZ = MathHelper.floor_float(var24 + var28);
- for (int eX = tMinX; eX <= tMaxX; eX++) {
- float var39 = (eX + 0.5F - var20) / (var28);
- float var10d = var39 * var39;
- if (var10d < 1.0F) {
- for (int eY = tMinY; eY <= tMaxY; eY++) {
- float var42 = (eY + 0.5F - var22) / (var28);
- float var12d = var10d + var42 * var42;
- if (var12d < 1.0F) {
- for (int eZ = tMinZ; eZ <= tMaxZ; eZ++) {
- float var45 = (eZ + 0.5F - var24) / (var28);
- if (var12d + var45 * var45 < 1.0F) {
- Block tTargetedBlock = aWorld.getBlock(eX, eY, eZ);
- if (tTargetedBlock instanceof GT_Block_Ores_Abstract) {
- TileEntity tTileEntity = aWorld.getTileEntity(eX, eY, eZ);
- if ((tTileEntity instanceof GT_TileEntity_Ores)) {
- if (tTargetedBlock != GregTech_API.sBlockOres1) {
- ((GT_TileEntity_Ores) tTileEntity).convertOreBlock(aWorld, eX, eY, eZ);
- }
- ((GT_TileEntity_Ores)tTileEntity).overrideOreBlockMaterial(this.mBlock, (byte) this.mBlockMeta);
- }
- } else if (((this.mAllowToGenerateinVoid) && (aWorld.getBlock(eX, eY, eZ).isAir(aWorld, eX, eY, eZ))) || ((tTargetedBlock != null) && ((tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, Blocks.stone)) || (tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, Blocks.end_stone)) || (tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, Blocks.netherrack)) || (tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, GregTech_API.sBlockGranites)) || (tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, GregTech_API.sBlockStones))))) {
- aWorld.setBlock(eX, eY, eZ, this.mBlock, this.mBlockMeta, 0);
- }
- }
+ XSTR stoneRNG = new XSTR();
+ ArrayList<ValidSeeds> stones = new ArrayList();
+
+ if ( !isGenerationAllowed(aWorld, aDimensionType, this.mDimensionType)) {
+ return false;
+ }
+ if ( !(this.mBiomeList.isEmpty() || this.mBiomeList.contains(aBiome)) ) {
+ return false;
+ }
+ // I think the real size of the balls is mSize/8, but the original code was difficult to understand.
+ // Overall there will be less GT stones since they aren't spheres any more. /16 since this code uses it as a radius.
+ double realSize = mSize/16;
+ int windowWidth = ((int)realSize)/16 + 1; // Width of chunks to check for a potential stoneseed
+ // Check stone seeds to see if they have been added
+ for( int x = aChunkX/16 - windowWidth; x < (aChunkX/16 + windowWidth + 1); x++ ) {
+ for( int z = aChunkZ/16 - windowWidth; z < (aChunkZ/16 + windowWidth + 1); z++ ) {
+ long hash = ((long)((aWorld.provider.dimensionId & 0xffL)<<56) |( ((long)x & 0x000000000fffffffL) << 28) | ( (long)z & 0x000000000fffffffL ));
+ if( !validStoneSeeds.containsKey(hash) ) {
+ // Determine if RNG says to add stone at this chunk
+ stoneRNG.setSeed((long)aWorld.getSeed() ^ hash + Math.abs(mBlockMeta) + Math.abs(mSize) + ((GregTech_API.sBlockGranites==mBlock)?(32768):(0))); //Don't judge me. Want different values for different block types
+ if ( (this.mProbability <= 1) || (stoneRNG.nextInt(this.mProbability*2) == 0) ) { // Decreased probability of stones by factor of 2
+ // Add stone at this chunk
+ validStoneSeeds.put( hash, new StoneSeeds(true) );
+ // Add to generation list
+ stones.add( new ValidSeeds(x,z) );
+ if (debugStones) GT_Log.out.println(
+ "New stoneseed="+mWorldGenName+
+ " x="+x+
+ " z="+z+
+ " realSize="+realSize
+ );
+ } else {
+ validStoneSeeds.put( hash, new StoneSeeds(false) );
+ }
+ } else {
+ // This chunk has already been checked, check to see if a boulder exists here
+ if( validStoneSeeds.get(hash).mExists ) {
+ // Add to generation list
+ stones.add( new ValidSeeds(x,z) );
+ }
+ }
+ }
+ }
+
+ boolean result = true;
+ if (stones.size() == 0) {
+ result = false;
+ }
+ // Now process each oreseed vs this requested chunk
+ for( ; stones.size() != 0; stones.remove(0) ) {
+ int x = stones.get(0).mX*16;
+ int z = stones.get(0).mZ*16;
+
+ stoneRNG.setSeed((long)aWorld.getSeed() ^ ((long)((aWorld.provider.dimensionId & 0xffL)<<56) |( ((long)x & 0x000000000fffffffL)<< 28) | ( (long)z & 0x000000000fffffffL )) + Math.abs(mBlockMeta) + Math.abs(mSize) + ((GregTech_API.sBlockGranites==mBlock)?(32768):(0))); //Don't judge me
+ for (int i = 0; i < this.mAmount; i++) { // Not sure why you would want more than one in a chunk! Left alone though.
+ // Locate the stoneseed XYZ. Original code would request an isAir at the seed location, causing a chunk generation request.
+ // To reduce potential worldgen cascade, we just always try to place a ball and use the check inside the for loop to prevent
+ // placement instead.
+ int tX = x + stoneRNG.nextInt(16);
+ int tY = mMinY + stoneRNG.nextInt(mMaxY - mMinY);
+ int tZ = z + stoneRNG.nextInt(16);
+
+ //Determine the XYZ sizes of the stoneseed
+ double xSize = sizeConversion[stoneRNG.nextInt(sizeConversion.length)];
+ double ySize = sizeConversion[stoneRNG.nextInt(sizeConversion.length)/2]; // Skew the ySize towards the larger sizes, more long skinny pipes
+ double zSize = sizeConversion[stoneRNG.nextInt(sizeConversion.length)];
+
+ //Equation for an ellipsoid centered around 0,0,0
+ // Sx, Sy, and Sz are size controls (size = 1/S_)
+ // 1 = full size, 1.333 = 75%, 2 = 50%, 4 = 25%
+ // (x * Sx)^2 + (y * Sy)^2 + (z * sZ)^2 <= (mSize)^2
+
+ //So, we setup the intial boundaries to be the size of the boulder plus a block in each direction
+ int tMinX = tX-(int)(realSize/xSize-1.0);
+ int tMaxX = tX+(int)(realSize/xSize+2.0);
+ int tMinY = tY-(int)(realSize/ySize-1.0);
+ int tMaxY = tY+(int)(realSize/ySize+2.0);
+ int tMinZ = tZ-(int)(realSize/zSize-1.0);
+ int tMaxZ = tZ+(int)(realSize/zSize+2.0);
+
+ // If the (tY-ySize) of the stoneseed is air in the current chunk, mark the seed empty and move on.
+ if(aWorld.getBlock(aChunkX + 8, tMinY, aChunkZ + 8).isAir(aWorld, aChunkX + 8, tMinY, aChunkZ + 8)) {
+ if (debugStones) GT_Log.out.println(
+ mWorldGenName +
+ " tX=" + tX +
+ " tY=" + tY +
+ " tZ=" + tZ +
+ " realSize=" + realSize +
+ " xSize=" + realSize/xSize +
+ " ySize=" + realSize/ySize +
+ " zSize=" + realSize/zSize +
+ " tMinY=" + tMinY +
+ " tMaxY=" + tMaxY +
+ " - Skipped because first requesting chunk would not contain this stone"
+ );
+ long hash = ((long)((aWorld.provider.dimensionId & 0xffL)<<56) |( ((long)x & 0x000000000fffffffL) << 28) | ( (long)z & 0x000000000fffffffL ));
+ validStoneSeeds.remove(hash);
+ validStoneSeeds.put( hash, new StoneSeeds(false) );
+ }
+
+ //Chop the boundaries by the parts that intersect with the current chunk
+ int wX = Math.max( tMinX, aChunkX + 8);
+ int eX = Math.min( tMaxX, aChunkX + 8 + 16 );
+
+ int sZ = Math.max( tMinZ, aChunkZ + 8);
+ int nZ = Math.min( tMaxZ, aChunkZ + 8 + 16 );
+
+ if (debugStones) GT_Log.out.println(
+ mWorldGenName +
+ " tX=" + tX +
+ " tY=" + tY +
+ " tZ=" + tZ +
+ " realSize=" + realSize +
+ " xSize=" + realSize/xSize +
+ " ySize=" + realSize/ySize +
+ " zSize=" + realSize/zSize +
+ " wX=" + wX +
+ " eX=" + eX +
+ " tMinY=" + tMinY +
+ " tMaxY=" + tMaxY +
+ " sZ=" + sZ +
+ " nZ=" + nZ
+ );
+
+ double rightHandSide = realSize*realSize + 1; //Precalc the right hand side
+ for( int iY = tMinY; iY < tMaxY; iY++) { // Do placement from the bottom up layer up. Maybe better on cache usage?
+ double yCalc = ( (double)(iY-tY)*ySize );
+ yCalc = yCalc * yCalc; // (y*Sy)^2
+ double leftHandSize = yCalc;
+ if( leftHandSize > rightHandSide ) {
+ continue; // If Y alone is larger than the RHS, skip the rest of the loops
+ }
+ for( int iX = wX; iX < eX; iX++) {
+ double xCalc = ( (double)(iX-tX)*xSize );
+ xCalc = xCalc * xCalc;
+ leftHandSize = yCalc + xCalc;
+ if( leftHandSize > rightHandSide ) { // Again, if X and Y is larger than the RHS, skip to the next value
+ continue;
+ }
+ for( int iZ = sZ; iZ < nZ; iZ++ ) {
+ double zCalc = ( (double)(iZ-tZ)*zSize );
+ zCalc = zCalc * zCalc;
+ leftHandSize = zCalc + xCalc + yCalc;
+ if( leftHandSize > rightHandSide ) {
+ continue;
+ } else {
+ // Yay! We can actually place a block now. (this part copied from original code)
+ Block tTargetedBlock = aWorld.getBlock(iX, iY, iZ);
+ if (tTargetedBlock instanceof GT_Block_Ores_Abstract) {
+ TileEntity tTileEntity = aWorld.getTileEntity(iX, iY, iZ);
+ if ((tTileEntity instanceof GT_TileEntity_Ores)) {
+ if (tTargetedBlock != GregTech_API.sBlockOres1) {
+ ((GT_TileEntity_Ores) tTileEntity).convertOreBlock(aWorld, iX, iY, iZ);
}
+ ((GT_TileEntity_Ores)tTileEntity).overrideOreBlockMaterial(this.mBlock, (byte) this.mBlockMeta);
}
+ } else if (((this.mAllowToGenerateinVoid) && (aWorld.getBlock(iX, iY, iZ).isAir(aWorld, iX, iY, iZ))) || ((tTargetedBlock != null) && ((tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, Blocks.stone)) || (tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, Blocks.end_stone)) || (tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, Blocks.netherrack)) || (tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, GregTech_API.sBlockGranites)) || (tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, GregTech_API.sBlockStones))))) {
+ aWorld.setBlock(iX, iY, iZ, this.mBlock, this.mBlockMeta, 0);
}
}
}
}
}
}
- return true;
}
- return false;
+ return result;
}
}
diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java
index f42bc4ef1b..ce308cecd9 100644
--- a/src/main/java/gregtech/common/GT_Worldgenerator.java
+++ b/src/main/java/gregtech/common/GT_Worldgenerator.java
@@ -20,16 +20,21 @@ import static gregtech.api.enums.GT_Values.oreveinPercentage;
import static gregtech.api.enums.GT_Values.debugWorldGen;
import static gregtech.api.enums.GT_Values.debugOrevein;
import static gregtech.api.enums.GT_Values.oreveinAttempts;
+import static gregtech.api.enums.GT_Values.oreveinMaxPlacementAttempts;
+// Disabled for hardcoded value. import static gregtech.api.enums.GT_Values.oreveinMaxSize;
+import gregtech.api.enums.Materials;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.HashSet;
+import java.util.Hashtable;
import static gregtech.api.enums.GT_Values.D1;
public class GT_Worldgenerator
- implements IWorldGenerator {
+implements IWorldGenerator {
//public static boolean sAsteroids = true;
private static int mEndAsteroidProbability = 300;
//private static int mGCAsteroidProbability = 50;
@@ -39,10 +44,13 @@ public class GT_Worldgenerator
//private static int gcMinSize = 100;
//private static int gcMaxSize = 400;
private static boolean endAsteroids = true;
- public List<Runnable> mList = new ArrayList();
- public HashSet<Long> ProcChunks = new HashSet<Long>();
+ public static List<Runnable> mList = new ArrayList();
+ public static HashSet<Long> ProcChunks = new HashSet<Long>();
+ // This is probably not going to work. Trying to create a fake orevein to put into hashtable when there will be no ores in a vein.
+ public static GT_Worldgen_GT_Ore_Layer noOresInVein = new GT_Worldgen_GT_Ore_Layer( "NoOresInVein", false, 0, 255, 0, 255, 16, false, false, false, false, false, false, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium);
+ public static Hashtable<Long, GT_Worldgen_GT_Ore_Layer> validOreveins = new Hashtable(1024);
public boolean mIsGenerating = false;
- public static final Object listLock = new Object();
+ public static final Object listLock = new Object();
//private static boolean gcAsteroids = true;
@@ -56,42 +64,50 @@ public class GT_Worldgenerator
//gcMaxSize = GregTech_API.sWorldgenFile.get("gcasteroids", "GCAsteroidMaxSize", 400);
//mGCAsteroidProbability = GregTech_API.sWorldgenFile.get("gcasteroids", "GCAsteroidProbability", 300);
GameRegistry.registerWorldGenerator(this, 1073741823);
- if (debugWorldGen) {
- GT_Log.out.println(
- "GT_Worldgenerator created"
- );
- }
+ if (debugWorldGen) {
+ GT_Log.out.println(
+ "GT_Worldgenerator created"
+ );
+ }
}
-
public void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
- this.mList.add(new WorldGenContainer(new XSTR(aRandom.nextInt()), aX * 16, aZ * 16, ((aChunkGenerator instanceof ChunkProviderEnd)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.sky) ? 1 : ((aChunkGenerator instanceof ChunkProviderHell)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.hell) ? -1 : 0, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName));
+ synchronized (listLock)
+ {
+ this.mList.add(new WorldGenContainer(new XSTR(Math.abs(aRandom.nextInt()) +1), aX, aZ, ((aChunkGenerator instanceof ChunkProviderEnd)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.sky) ? 1 : ((aChunkGenerator instanceof ChunkProviderHell)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.hell) ? -1 : 0, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName));
+ if (debugWorldGen) GT_Log.out.println(
+ "ADD WorldSeed:"+aWorld.getSeed() +
+ " DimId" + aWorld.provider.dimensionId +
+ " chunk x:" + aX +
+ " z:" + aZ +
+ " SIZE: " + this.mList.size()
+ );
+ }
+
if (!this.mIsGenerating) {
this.mIsGenerating = true;
int mList_sS=this.mList.size();
+ mList_sS = Math.min(mList_sS, 5); // Run a maximum of 5 chunks at a time through worldgen. Extra chunks get done later.
for (int i = 0; i < mList_sS; i++) {
- ((Runnable) this.mList.get(i)).run();
+ WorldGenContainer toRun = (WorldGenContainer) this.mList.get(0);
+ if (debugWorldGen) GT_Log.out.println(
+ "RUN WorldSeed:"+aWorld.getSeed()+
+ " DimId" + aWorld.provider.dimensionId +
+ " chunk x:" + toRun.mX +
+ " z:" + toRun.mZ +
+ " SIZE: " + this.mList.size() +
+ " i: " + i
+ );
+ synchronized (listLock)
+ {
+ this.mList.remove(0);
+ }
+ toRun.run();
}
- if (debugWorldGen) {
- GT_Log.out.println(
- "Tossing " + (this.mList.size() - mList_sS) +
- " chunks!"
- );
- }
- this.mList.clear();
this.mIsGenerating = false;
}
}
-
- //public synchronized void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {//TODO CHECK???
- // int tempDimensionId = aWorld.provider.dimensionId;
- // if (tempDimensionId != -1 && tempDimensionId != 1 && !aChunkGenerator.getClass().getName().contains("galacticraft")) {
- // tempDimensionId = 0;
- // }
- // new WorldGenContainer(new XSTR(aRandom.nextInt()), aX * 16, aZ * 16, tempDimensionId, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName).run();
- //}
-
public static class WorldGenContainer
implements Runnable {
public final Random mRandom;
@@ -102,7 +118,18 @@ public class GT_Worldgenerator
public final IChunkProvider mChunkGenerator;
public final IChunkProvider mChunkProvider;
public final String mBiome;
+ // Local class to track which orevein seeds must be checked when doing chunkified worldgen
+ class NearbySeeds {
+ public int mX;
+ public int mZ;
+ NearbySeeds( int x, int z) {
+ this.mX = x;
+ this.mZ = z;
+ }
+ };
+ public static ArrayList<NearbySeeds> seedList = new ArrayList();
+ // aX and aZ are now the by-chunk X and Z for the chunk of interest
public WorldGenContainer(Random aRandom, int aX, int aZ, int aDimensionType, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider, String aBiome) {
this.mRandom = aRandom;
this.mX = aX;
@@ -114,97 +141,186 @@ public class GT_Worldgenerator
this.mBiome = aBiome;
}
- public void run() {
- String tDimensionName = "";
- if (debugOrevein) { tDimensionName = this.mWorld.provider.getDimensionName(); }
- long startTime = System.nanoTime();
- if ((Math.abs(this.mX / 16) % 3 == 1) && (Math.abs(this.mZ / 16) % 3 == 1)) {
- int oreveinRNG = this.mRandom.nextInt(100);
- if (( oreveinRNG < oreveinPercentage) && (GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) {
- boolean temp = true;
+ public void worldGenFindVein( int oreseedX, int oreseedZ) {
+ // Explanation of oreveinseed implementation.
+ // (long)this.mWorld.getSeed()<<16) Deep Dark does two oregen passes, one with getSeed set to +1 the original world seed. This pushes that +1 off the low bits of oreseedZ, so that the hashes are far apart for the two passes.
+ // ((this.mWorld.provider.dimensionId & 0xffL)<<56) Puts the dimension in the top bits of the hash, to make sure to get unique hashes per dimension
+ // ((long)oreseedX & 0x000000000fffffffL) << 28) Puts the chunk X in the bits 29-55. Cuts off the top few bits of the chunk so we have bits for dimension.
+ // ( (long)oreseedZ & 0x000000000fffffffL )) Puts the chunk Z in the bits 0-27. Cuts off the top few bits of the chunk so we have bits for dimension.
+ long oreveinSeed = ((long)this.mWorld.getSeed()<<16) ^ ((long)((this.mWorld.provider.dimensionId & 0xffL)<<56) |( ((long)oreseedX & 0x000000000fffffffL) << 28) | ( (long)oreseedZ & 0x000000000fffffffL )); // Use an RNG that is identical every time it is called for this oreseed.
+ XSTR oreveinRNG = new XSTR( oreveinSeed );
+ int oreveinPercentageRoll = oreveinRNG.nextInt(100); // Roll the dice, see if we get an orevein here at all
+ int noOrePlacedCount=0;
+ String tDimensionName = "";
+ if (debugOrevein) { tDimensionName = this.mWorld.provider.getDimensionName(); }
- int tRandomWeight;
- int i;
- for (i = 0; (i < oreveinAttempts) && (temp); i++) {
- tRandomWeight = this.mRandom.nextInt(GT_Worldgen_GT_Ore_Layer.sWeight);
- for (GT_Worldgen tWorldGen : GT_Worldgen_GT_Ore_Layer.sList) {
- tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer) tWorldGen).mWeight;
+ if (debugOrevein) GT_Log.out.println(
+ " Finding oreveins for oreveinSeed="+ oreveinSeed +
+ " mX="+ this.mX +
+ " mZ="+ this.mZ +
+ " oreseedX="+ oreseedX +
+ " oreseedZ="+ oreseedZ +
+ " worldSeed="+this.mWorld.getSeed()
+ );
+
+ // Search for a valid orevein for this dimension
+ if( !validOreveins.containsKey(oreveinSeed) ) {
+ if ( (oreveinPercentageRoll<oreveinPercentage) && (GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) {
+ int placementAttempts = 0;
+ boolean oreveinFound = false;
+ int i;
+ for( i = 0; (i < oreveinAttempts) && (!oreveinFound) && (placementAttempts<oreveinMaxPlacementAttempts); i++ ) {
+ int tRandomWeight = oreveinRNG.nextInt(GT_Worldgen_GT_Ore_Layer.sWeight);
+ for (GT_Worldgen_GT_Ore_Layer tWorldGen : GT_Worldgen_GT_Ore_Layer.sList) {
+ tRandomWeight -= ( tWorldGen).mWeight;
if (tRandomWeight <= 0) {
- try {
- if (tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, this.mX, this.mZ, this.mChunkGenerator, this.mChunkProvider)) {
- temp = false;
+ try {
+ // Adjust the seed so that this layer has a series of unique random numbers. Otherwise multiple attempts at this same oreseed will get the same offset and X/Z values. If an orevein failed, any orevein with the
+ // same minimum heights would fail as well. This prevents that, giving each orevein a unique height each pass through here.
+ int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, new XSTR( oreveinSeed ^ (tWorldGen.mPrimaryMeta)), this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, oreseedX*16, oreseedZ*16, this.mChunkGenerator, this.mChunkProvider);
+ switch(placementResult) {
+ case GT_Worldgen_GT_Ore_Layer.ORE_PLACED:
+ if (debugOrevein) GT_Log.out.println(
+ " Added oreveinSeed=" + oreveinSeed +
+ " tries at oremix=" + i +
+ " placementAttempts=" + placementAttempts +
+ " dimensionName=" + tDimensionName
+ );
+ validOreveins.put(oreveinSeed, tWorldGen);
+ oreveinFound = true;
+ break;
+ case GT_Worldgen_GT_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER:
+ placementAttempts++;
+ // SHould do retry in this case until out of chances
+ break;
+ case GT_Worldgen_GT_Ore_Layer.NO_OVERLAP:
+ // Orevein didn't reach this chunk, can't add it yet to the hash
+ break;
}
- break;
+ break; // Try the next orevein
} catch (Throwable e) {
+ if (debugOrevein) GT_Log.out.println(
+ "Exception occurred on oreVein" + tWorldGen +
+ " oreveinSeed="+ oreveinSeed +
+ " mX="+ this.mX +
+ " mZ="+ this.mZ +
+ " oreseedX="+ oreseedX +
+ " oreseedZ="+ oreseedZ
+ );
e.printStackTrace(GT_Log.err);
}
}
}
}
- if (debugOrevein & temp) {
- GT_Log.out.println(
- "No orevein selected!" +
- " chunkX="+ this.mX +
- " chunkZ="+ this.mZ +
- " oreveinAttemps=" + oreveinAttempts +
- " dimensionName=" + tDimensionName
- );
- } else if (debugOrevein)
- {
- GT_Log.out.println(
- "Orevein took " + i +
- " attempts to find" +
- " dimensionName=" + tDimensionName
- );
- }
-
- }else
+ // Only add an empty orevein if are unable to place a vein at the oreseed chunk.
+ if ((!oreveinFound) && (this.mX == oreseedX) && (this.mZ == oreseedZ)){
+ if (debugOrevein) GT_Log.out.println(
+ " Empty oreveinSeed="+ oreveinSeed +
+ " mX="+ this.mX +
+ " mZ="+ this.mZ +
+ " oreseedX="+ oreseedX +
+ " oreseedZ="+ oreseedZ +
+ " tries at oremix=" + i +
+ " placementAttempts=" + placementAttempts +
+ " dimensionName=" + tDimensionName
+ );
+ validOreveins.put(oreveinSeed, noOresInVein );
+ }
+ } else if(oreveinPercentageRoll >= oreveinPercentage) {
+ if (debugOrevein) GT_Log.out.println(
+ " Skipped oreveinSeed="+ oreveinSeed +
+ " mX="+ this.mX +
+ " mZ="+ this.mZ +
+ " oreseedX=" + oreseedX +
+ " oreseedZ="+ oreseedZ +
+ " RNG=" + oreveinPercentageRoll +
+ " %=" + oreveinPercentage+
+ " dimensionName=" + tDimensionName
+ );
+ validOreveins.put(oreveinSeed, noOresInVein);
+ }
+ }else {
+ // oreseed is located in the previously processed table
+ if (debugOrevein) GT_Log.out.print(
+ " Valid oreveinSeed="+ oreveinSeed +
+ " validOreveins.size()=" + validOreveins.size() + " "
+ );
+ GT_Worldgen_GT_Ore_Layer tWorldGen = validOreveins.get(oreveinSeed);
+ oreveinRNG.setSeed(oreveinSeed ^ (tWorldGen.mPrimaryMeta)); // Reset RNG to only be based on oreseed X/Z and type of vein
+ int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, oreveinRNG, this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, oreseedX*16, oreseedZ*16, this.mChunkGenerator, this.mChunkProvider);
+ switch( placementResult )
{
- if((oreveinRNG >= oreveinPercentage) && (debugOrevein))
- {
- GT_Log.out.println(
- "Skipped orevein in this 3x3 chunk!" +
- " chunkX="+ this.mX +
- " chunkZ="+ this.mZ +
- " RNG=" + oreveinRNG +
- " %=" + oreveinPercentage+
- " dimensionName=" + tDimensionName
- );
- }
+ case GT_Worldgen_GT_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER:
+ if (debugOrevein) GT_Log.out.println(
+ " No ore in bottom layer"
+ );
+ break;
+ case GT_Worldgen_GT_Ore_Layer.NO_OVERLAP:
+ if (debugOrevein) GT_Log.out.println(
+ " No overlap"
+ );
}
-
- int i = 0;
- for (int tX = this.mX - 16; i < 3; tX += 16) {
- int j = 0;
- for (int tZ = this.mZ - 16; j < 3; tZ += 16) {
- String tBiome = this.mWorld.getBiomeGenForCoords(tX + 8, tZ + 8).biomeName;
- //if (tBiome == null) {//TODO NEEDED?
- // tBiome = BiomeGenBase.plains.biomeName;
- //}
- try {
- for (GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) {
- tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, tX, tZ, this.mChunkGenerator, this.mChunkProvider);
- }
- } catch (Throwable e) {
- e.printStackTrace(GT_Log.err);
- }
- j++;
+ }
+ }
+
+ public void run() {
+ long startTime = System.nanoTime();
+ int oreveinMaxSize;
+
+ // Determine bounding box on how far out to check for oreveins affecting this chunk
+ // For now, manually reducing oreveinMaxSize when not in the Underdark for performance
+ if(this.mWorld.provider.getDimensionName().equals("Underdark") ) {
+ oreveinMaxSize=32; // Leave Deep Dark/Underdark max oregen at 32, instead of 64
+ } else {
+ oreveinMaxSize=32;
+ }
+
+ int wXbox = this.mX - (oreveinMaxSize/16);
+ int eXbox = this.mX + (oreveinMaxSize/16 + 1); // Need to add 1 since it is compared using a <
+ int nZbox = this.mZ - (oreveinMaxSize/16);
+ int sZbox = this.mZ + (oreveinMaxSize/16 + 1);
+
+ // Search for orevein seeds and add to the list;
+ for( int x = wXbox; x < eXbox; x++ ) {
+ for( int z = nZbox; z < sZbox; z++ ) {
+ // Determine if this X/Z is an orevein seed
+ if ( ( (Math.abs(x)%3) == 1) && ( (Math.abs(z)%3) == 1 ) ) {
+ if (debugWorldGen) GT_Log.out.println(
+ "Adding seed x="+x+
+ " z="+z
+ );
+ seedList.add( new NearbySeeds(x,z) );
}
- i++;
}
}
- else
- {
- if (debugOrevein) {
- GT_Log.out.println(
- "Skipped chunk, not 3x3 center" +
- " @ dim="+this.mDimensionType+
- " chunkX="+this.mX+
- " chunkZ="+this.mZ+
- " dimensionName=" + tDimensionName
- );
- }
- }
+
+ // Now process each oreseed vs this requested chunk
+ for( ; seedList.size() != 0; seedList.remove(0) ) {
+ if (debugWorldGen) GT_Log.out.println(
+ "Processing seed x="+seedList.get(0).mX+
+ " z="+seedList.get(0).mZ
+ );
+ worldGenFindVein( seedList.get(0).mX, seedList.get(0).mZ );
+ }
+
+ long oregenTime = System.nanoTime();
+
+ // Do leftover worldgen for this chunk (GT_Stones and GT_small_ores)
+ try {
+ for (GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) {
+ /*
+ if (debugWorldGen) GT_Log.out.println(
+ "tWorldGen.mWorldGenName="+tWorldGen.mWorldGenName
+ );
+ */
+ tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, this.mChunkGenerator, this.mChunkProvider);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+
+ long leftOverTime = System.nanoTime();
+
//Asteroid Worldgen
int tDimensionType = this.mWorld.provider.dimensionId;
//String tDimensionName = this.mWorld.provider.getDimensionName();
@@ -316,14 +432,16 @@ public class GT_Worldgenerator
if (tChunk != null) {
tChunk.isModified = true;
}
- long endTime = System.nanoTime();
- long duration = (endTime - startTime);
- if (debugWorldGen) {
- GT_Log.out.println(
- "Oregen took " + duration +
- " nanoseconds"
- );
- }
+ long endTime = System.nanoTime();
+ long duration = (endTime - startTime);
+ if (debugWorldGen) {
+ GT_Log.out.println(
+ " Oregen took " + (oregenTime-startTime)+
+ " Leftover gen took " + (leftOverTime - oregenTime ) +
+ " Worldgen took " + duration +
+ " nanoseconds"
+ );
+ }
}
}
}
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java
index 6f3f80c7df..402f50a484 100644
--- a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java
+++ b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java
@@ -2,6 +2,7 @@ package gregtech.common.blocks;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
+import gregtech.api.interfaces.IBlockOnWalkOver;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_OreDictUnificator;
import net.minecraft.block.Block;
@@ -16,11 +17,11 @@ import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidBlock;
public class GT_Block_Concretes
- extends GT_Block_Stones_Abstract {
+ extends GT_Block_Stones_Abstract implements IBlockOnWalkOver{
public GT_Block_Concretes() {
super(GT_Item_Concretes.class, "gt.blockconcretes");
setResistance(20.0F);
- this.slipperiness = 0.9F;
+ //this.slipperiness = 0.9F;
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Dark Concrete");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Dark Concrete Cobblestone");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mossy Dark Concrete Cobblestone");
@@ -70,6 +71,15 @@ public class GT_Block_Concretes
return gregtech.api.enums.Textures.BlockIcons.CONCRETES[0].getIcon();
}
+ @Override
+ public void onWalkOver(EntityLivingBase aEntity, World aWorld, int aX, int aY, int aZ) {
+ if ((aEntity.motionX != 0 || aEntity.motionZ != 0) && !aEntity.isInWater() && !aEntity.isWet() && !aEntity.isSneaking()) {
+ double tSpeed = (aWorld.getBlock(aX, aY-1, aZ).slipperiness >= 0.8 ? 1.5 : 1.2);
+ aEntity.motionX *= tSpeed; aEntity.motionZ *= tSpeed;
+ }
+ }
+
+ /**
public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) {
Block tBlock = aWorld.getBlock(aX, aY + 1, aZ);
if (((aEntity instanceof EntityLivingBase)) && (!(tBlock instanceof IFluidBlock)) && (!(tBlock instanceof BlockLiquid)) && (aEntity.onGround) && (!aEntity.isInWater()) && (!aEntity.isWet())) {
@@ -92,4 +102,5 @@ public class GT_Block_Concretes
}
return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 0.875D, aZ + 1);
}
+ **/
}
diff --git a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
index c6618dca60..f8b52c8f08 100644
--- a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
+++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java
@@ -31,7 +31,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
public static byte getHarvestData(short aMetaData, int aBaseBlockHarvestLevel) {
Materials aMaterial = GregTech_API.sGeneratedMaterials[(aMetaData % 1000)];
byte tByte = aMaterial == null ? 0 : (byte) Math.max(aBaseBlockHarvestLevel, Math.min(7, aMaterial.mToolQuality - (aMetaData < 16000 ? 0 : 1)));
- if(GT_Mod.gregtechproxy.mChangeHarvestLevels ){
+ if(GT_Mod.gregtechproxy.mChangeHarvestLevels ) {
tByte = aMaterial == null ? 0 : (byte) Math.max(aBaseBlockHarvestLevel, Math.min(GT_Mod.gregtechproxy.mMaxHarvestLevel, GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] - (aMetaData < 16000 ? 0 : 1)));
}
return tByte;
@@ -51,38 +51,9 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
String BlockName = tBlock.getUnlocalizedName();
aMetaData += isSmallOre ? 16000 : 0;
if ((aMetaData > 0) && ((tBlock != Blocks.air) || air)) {
- if (BlockName.equals("tile.igneousStone")) {
- if (GregTech_API.sBlockOresUb1 != null) {
- tOreBlock = GregTech_API.sBlockOresUb1;
- aMetaData += (BlockMeta * 1000);
- //System.out.println("Block changed to UB1");
- }
- } else if (BlockName.equals("tile.metamorphicStone")) {
- if (GregTech_API.sBlockOresUb2 != null) {
- tOreBlock = GregTech_API.sBlockOresUb2;
- aMetaData += (BlockMeta * 1000);
- //System.out.println("Block changed to UB2");
- }
- } else if (BlockName.equals("tile.sedimentaryStone")) {
- if (GregTech_API.sBlockOresUb3 != null) {
- tOreBlock = GregTech_API.sBlockOresUb3;
- aMetaData += (BlockMeta * 1000);
- //System.out.println("Block changed to UB3");
- }
- //} else if (BlockName.equals("tile.moonBlock") && (BlockMeta == 3 || BlockMeta == 4)) {
- // if (GregTech_API.sBlockOresGC != null) {
- // switch (BlockMeta) {
- // case 3: tOreBlock = GregTech_API.sBlockOresGC; break;
- // case 4: aMetaData += 1000; tOreBlock = GregTech_API.sBlockOresGC; break;
- // }
- // }
- //} else if (BlockName.equals("tile.mars") && (BlockMeta == 6 || BlockMeta == 9)) {
- // if (GregTech_API.sBlockOresGC != null) {
- // switch (BlockMeta) {
- // case 6: aMetaData += 2000; tOreBlock = GregTech_API.sBlockOresGC; break;
- // case 9: aMetaData += 3000; tOreBlock = GregTech_API.sBlockOresGC; break;
- // }
- // }
+ if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) {
+ //Do nothing, stone background is default background.
+ //Do this comparison first since stone is most common
} else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) {
aMetaData += 1000;
} else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) {
@@ -107,7 +78,25 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit
} else {
aMetaData += 5000;
}
- } else if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) {
+ } else if (BlockName.equals("tile.igneousStone")) {
+ if (GregTech_API.sBlockOresUb1 != null) {
+ tOreBlock = GregTech_API.sBlockOresUb1;
+ aMetaData += (BlockMeta * 1000);
+ //System.out.println("Block changed to UB1");
+ }
+ } else if (BlockName.equals("tile.metamorphicStone")) {
+ if (GregTech_API.sBlockOresUb2 != null) {
+ tOreBlock = GregTech_API.sBlockOresUb2;
+ aMetaData += (BlockMeta * 1000);
+ //System.out.println("Block changed to UB2");
+ }
+ } else if (BlockName.equals("tile.sedimentaryStone")) {
+ if (GregTech_API.sBlockOresUb3 != null) {
+ tOreBlock = GregTech_API.sBlockOresUb3;
+ aMetaData += (BlockMeta * 1000);
+ //System.out.println("Block changed to UB3");
+ }
+ } else {
return false;
}
//System.out.println(tOreBlock);
diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java
index 6adde2638d..3bc2731d4a 100644
--- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java
+++ b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java
@@ -38,7 +38,7 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B
public static boolean sAllowMultipleEggs = true;
public static GT_MetaTileEntity_MagicalEnergyAbsorber mActiveSiphon = null;
public static int sEnergyPerEnderCrystal = 32;
- public static int sEnergyFromVis = 12800;
+ public static int sEnergyFromVis = 512;
public static int sDragonEggEnergyPerTick = 128;
public static boolean isThaumcraftLoaded;
public int mEfficiency;
@@ -53,7 +53,7 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B
super(aName, aTier, aDescription, aTextures);
onConfigLoad();
}
-
+
public GT_MetaTileEntity_MagicalEnergyAbsorber(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aDescription, aTextures);
onConfigLoad();
@@ -109,34 +109,31 @@ public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_B
// Energyzed node
if (isThaumcraftLoaded) {
try {
+ int multFactor = 2;
World tmpWorld = this.getBaseMetaTileEntity().getWorld();
int tmpX = this.getBaseMetaTileEntity().getXCoord();
int tmpY = this.getBaseMetaTileEntity().getYCoord();
int tmpZ = this.getBaseMetaTileEntity().getZCoord();
- int fire = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.FIRE, 1000);
+ int fire = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.FIRE, 1000); // all of these should be 1000
int earth = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.EARTH, 1000);
int air = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.AIR, 1000);
- int destruction = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.ENTROPY, 1000);
+ int entropy = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.ENTROPY, 1000);
int order = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.ORDER, 1000);
int water = VisNetHandler.drainVis(tmpWorld, tmpX, tmpY, tmpZ, Aspect.WATER, 1000);
- int visEU = (int) (Math.pow(fire, 4) + Math.pow(earth, 4) + Math.pow(air, 4) + Math.pow(destruction, 4) + Math.pow(order, 4) + Math.pow(
- water, 4));
- int mult = 85;
- if (fire > 4)
- mult += 15;
- if (earth > 4)
- mult += 15;
- if (air > 4)
- mult += 15;
- if (destruction > 4)
- mult += 15;
- if (order > 4)
- mult += 15;
- if (water > 4)
- mult += 15;
+ int visEU = (int) (Math.pow(fire, 2) + Math.pow(earth, 2) + Math.pow(air, 2) + Math.pow(entropy, 2) + Math.pow(order, 2) + Math.pow(water, 2));
+ int mult = 0; //this should make it more dependant on how big your node is
+ mult += fire * multFactor;
+ mult += earth * multFactor;
+ mult += air * multFactor;
+ mult += entropy * multFactor;
+ mult += order * multFactor;
+ mult += water * multFactor;
visEU = (visEU * mult) / 100;
- getBaseMetaTileEntity().increaseStoredEnergyUnits(Math.min(maxEUOutput(), visEU * getEfficiency() / this.sEnergyFromVis), false);
+
+ getBaseMetaTileEntity().increaseStoredEnergyUnits(Math.min(maxEUOutput(), visEU * getEfficiency() / sEnergyFromVis), false);
+
} catch (Throwable e) {
+
}
}
// EnderCrystal
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java
index f16ad5a744..4bd5a15af8 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java
@@ -36,15 +36,17 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine {
final static int[] ENERGY = new int[]{8, 8, 32, 128, 512}; //Miner energy consumption per tier
public GT_MetaTileEntity_Miner(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, 1, "Digging ore instead of you", 2, 2, "Miner.png", "", new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM")));
- }
+ super(aID, aName, aNameRegional, aTier, 1, new String[]{"Digging ore instead of you", ENERGY[aTier] + " EU/t, " + SPEED[aTier] / 20 + " sec per block",
+ "Work area " + (RADIUS[aTier] * 2 + 1) + "x" + (RADIUS[aTier] * 2 + 1)}, 2, 2, "Miner.png", "", new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/miner/OVERLAY_BOTTOM")));
+}
public GT_MetaTileEntity_Miner(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) {
super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName);
- }
+}
public GT_MetaTileEntity_Miner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) {
super(aName, aTier, 1, aDescription, aTextures, 2, 2, aGUIName, aNEIName);
+
}
@Override
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
index 73c7d07720..eab1070984 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
@@ -1,5 +1,7 @@
package gregtech.common.tileentities.machines.basic;
+import cpw.mods.fml.common.registry.GameRegistry;
+
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_Container_BasicTank;
import gregtech.api.gui.GT_GUIContainer_BasicTank;
@@ -9,6 +11,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.BaseTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
@@ -24,9 +27,12 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidHandler;
-import java.util.ArrayList;
+import java.util.ArrayDeque;
import java.util.Iterator;
+import java.util.HashSet;
+import java.util.Set;
+import static gregtech.api.enums.GT_Values.D1;
import static gregtech.api.enums.GT_Values.V;
import static gregtech.api.util.GT_Utility.getFakePlayer;
@@ -35,15 +41,26 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
private static final Block MINING_PIPE_BLOCK = GT_Utility.getBlockFromStack(MINING_PIPE);
private static final Block MINING_PIPE_TIP_BLOCK = GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 0));
+ public static int getMaxDistanceForTier(byte aTier) {
+ return (10 * ((int) Math.pow(1.6D, aTier)));
+ }
+
+ public static long getEuUsagePerTier(byte aTier) {
+ return (16 * ((long) Math.pow(4, aTier)));
+ }
- public ArrayList<ChunkPosition> mPumpList = new ArrayList<ChunkPosition>();
+ public ArrayDeque<ChunkPosition> mPumpList = new ArrayDeque<ChunkPosition>();
+ public boolean wasPumping = false;
public int mPumpTimer = 0;
public int mPumpCountBelow = 0;
- public Block mPumpedBlock1 = null;
- public Block mPumpedBlock2 = null;
+ public Block mPrimaryPumpedBlock = null;
+ public Block mSecondaryPumpedBlock = null;
public GT_MetaTileEntity_Pump(int aID, String aName, String aNameRegional, int aTier) {
- super(aID, aName, aNameRegional, aTier, 3, new String[]{"The best way to empty Oceans! Outputs on top", "Pumping Area: " + ((10 * ((int) Math.pow(1.6, aTier))) * 2 + 1) + "x" + ((10 * ((int) Math.pow(1.6, aTier))) * 2 + 1)});
+ super(aID, aName, aNameRegional, aTier, 3,
+ new String[]{"The best way to empty Oceans! Outputs on top",
+ "Pumping Area: " + (GT_MetaTileEntity_Pump.getMaxDistanceForTier((byte)aTier) * 2 + 1) + "x" +
+ (GT_MetaTileEntity_Pump.getMaxDistanceForTier((byte)aTier) * 2 + 1)});
}
public GT_MetaTileEntity_Pump(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
@@ -60,15 +77,26 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
}
public void saveNBTData(NBTTagCompound aNBT) {
+ boolean wasPumping = this.wasPumping || !this.mPumpList.isEmpty();
+ if (D1) {
+ GT_Log.out.println("PUMP: NBT:Save - WasPumping - " + wasPumping + " blocks (" + this.mPrimaryPumpedBlock + ", " + this.mSecondaryPumpedBlock + ")");
+ }
super.saveNBTData(aNBT);
- aNBT.setString("mPumpedBlock1", this.mPumpedBlock1 == null ? "" : this.mPumpedBlock1.getUnlocalizedName());
- aNBT.setString("mPumpedBlock2", this.mPumpedBlock2 == null ? "" : this.mPumpedBlock2.getUnlocalizedName());
+ aNBT.setString("mPumpedBlock1", this.mPrimaryPumpedBlock == null ? "" : Block.blockRegistry.getNameForObject(this.mPrimaryPumpedBlock));
+ aNBT.setString("mPumpedBlock2", this.mSecondaryPumpedBlock == null ? "" : Block.blockRegistry.getNameForObject(this.mSecondaryPumpedBlock));
+ aNBT.setBoolean("wasPumping", wasPumping);
}
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
- this.mPumpedBlock1 = Block.getBlockFromName(aNBT.getString("mPumpedBlock1"));
- this.mPumpedBlock2 = Block.getBlockFromName(aNBT.getString("mPumpedBlock2"));
+ this.wasPumping = aNBT.getBoolean("wasPumping");
+ this.mPrimaryPumpedBlock = Block.getBlockFromName(aNBT.getString("mPumpedBlock1"));
+ this.mSecondaryPumpedBlock = Block.getBlockFromName(aNBT.getString("mPumpedBlock2"));
+
+ if (D1) {
+ GT_Log.out.println("PUMP: NBT:Load - WasPumping - " + this.wasPumping + "(" + aNBT.getString("mPumpedBlock1") + ") " + this.mPrimaryPumpedBlock);
+ }
+
}
@Override
@@ -126,60 +154,105 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
}
this.doTickProfilingInThisTick = true;
this.mPumpCountBelow = 0;
+
IGregTechTileEntity tTileEntity;
- for (int i = 1; (i < 21) && ((tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance((byte) 0, i)) != null)
- && ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Pump)); i++) {
+ for (int i = 1 ;
+ (i < 21) && ((tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance((byte) 0, i)) != null)
+ && ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Pump)) ; i++)
+ {
+ // Apparently someone might stack 21 pumps on top of each other, so let's check for that
getBaseMetaTileEntity().setActive(tTileEntity.isActive());
this.mPumpCountBelow += 1;
+ // The more pumps we have stacked, the faster the ones below go
((GT_MetaTileEntity_Pump) tTileEntity.getMetaTileEntity()).mPumpTimer -= 1;
}
if (this.mPumpCountBelow <= 0) {
- if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().isUniversalEnergyStored(16 * ((long) Math.pow(4, this.mTier))))
+ // Only the bottom most pump does anything
+ if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().isUniversalEnergyStored(this.getEuUsagePerAction()))
&& ((this.mFluid == null) || (this.mFluid.amount + 1000 <= getCapacity()))) {
boolean tMovedOneDown = false;
if ((this.mPumpList.isEmpty()) && (getBaseMetaTileEntity().getTimer() % 100L == 0L)) {
- tMovedOneDown = moveOneDown();
- }
- if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) {
- getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead() - 1, getBaseMetaTileEntity().getZCoord());
- if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) {
- getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead(), getBaseMetaTileEntity().getZCoord() + 1);
- }
- if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) {
- getFluidAt(getBaseMetaTileEntity().getXCoord(), getYOfPumpHead(), getBaseMetaTileEntity().getZCoord() - 1);
+ if (!this.wasPumping){
+ tMovedOneDown = moveOneDown();
+ if (D1) {
+ GT_Log.out.println("PUMP: Moved down");
+ }
+ } else if (D1) {
+ GT_Log.out.println("PUMP: Was pumping, didn't move down");
}
- if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) {
- getFluidAt(getBaseMetaTileEntity().getXCoord() + 1, getYOfPumpHead(), getBaseMetaTileEntity().getZCoord());
+ }
+ int x = getBaseMetaTileEntity().getXCoord(), z = getBaseMetaTileEntity().getZCoord();
+
+ if (!this.hasValidFluid()) {
+ // We don't have a valid block, let's try to find one
+ int y = getYOfPumpHead();
+
+ if (D1 && this.mPrimaryPumpedBlock != null) {
+ GT_Log.out.println("PUMP: Had an invalid pump block. Trying to find a fluid at Y: " + y +
+ " Previous blocks 1: " + this.mPrimaryPumpedBlock + " 2: " + this.mSecondaryPumpedBlock);
}
- if ((GT_Utility.isBlockInvalid(this.mPumpedBlock1)) || (GT_Utility.isBlockInvalid(this.mPumpedBlock2))) {
- getFluidAt(getBaseMetaTileEntity().getXCoord() - 1, getYOfPumpHead(), getBaseMetaTileEntity().getZCoord());
+ // First look down
+ checkForFluidToPump(x, y - 1, z );
+
+ // Then look all around
+ checkForFluidToPump(x, y, z + 1);
+ checkForFluidToPump(x, y, z - 1);
+ checkForFluidToPump(x + 1, y, z );
+ checkForFluidToPump(x - 1, y, z );
+ this.clearQueue(false);
+
+ if(this.hasValidFluid()) {
+ // Don't move down and rebuild the queue if we now have a valid fluid
+ this.wasPumping = true;
}
+
} else if (getYOfPumpHead() < getBaseMetaTileEntity().getYCoord()) {
- if ((tMovedOneDown) || ((this.mPumpList.isEmpty()) && (getBaseMetaTileEntity().getTimer() % 200L == 100L)) || (getBaseMetaTileEntity().getTimer() % 72000L == 100L)) {
- this.mPumpList.clear();
- int y = getBaseMetaTileEntity().getYCoord() - 1;
- for (int yHead = getYOfPumpHead(); (this.mPumpList.isEmpty()) && (y >= yHead); y--) {
- scanForFluid(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), this.mPumpList, getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord(), 10 * ((int) Math.pow(1.6D, this.mTier)));
+ // We didn't just look for a block, and the pump head is below the pump
+ if ((tMovedOneDown) || this.wasPumping ||
+ ((this.mPumpList.isEmpty()) && (getBaseMetaTileEntity().getTimer() % 200L == 100L)) ||
+ (getBaseMetaTileEntity().getTimer() % 72000L == 100L))
+ {
+ // Rebuild the list to pump if any of the following conditions are true:
+ // 1) We just moved down
+ // 2) We were previously pumping (and possibly just reloaded)
+ // 3) We have an empty queue and enough time has passed
+ // 4) A long while has has passed
+ if (D1) {
+ GT_Log.out.println("PUMP: Rebuilding pump list - Size " +
+ this.mPumpList.size() + " WasPumping: " + this.wasPumping + " Timer " + getBaseMetaTileEntity().getTimer());
+ }
+ int yPump = getBaseMetaTileEntity().getYCoord() - 1, yHead = getYOfPumpHead();
+
+ this.rebuildPumpQueue(x, yPump, z, yHead);
+
+ if (D1) {
+ GT_Log.out.println("PUMP: Rebuilt pump list - Size " + this.mPumpList.size());
}
+
}
if ((!tMovedOneDown) && (this.mPumpTimer <= 0)) {
- while ((!this.mPumpList.isEmpty())
- && (!consumeFluid(((ChunkPosition) this.mPumpList.get(this.mPumpList.size() - 1)).chunkPosX,
- ((ChunkPosition) this.mPumpList.get(this.mPumpList.size() - 1)).chunkPosY,
- ((ChunkPosition) this.mPumpList.remove(this.mPumpList.size() - 1)).chunkPosZ))) {
- //Should this be empty?
+ while ((!this.mPumpList.isEmpty())) {
+ ChunkPosition pos = this.mPumpList.pollLast();
+ if (consumeFluid(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) {
+ // Keep trying until we consume something, or the list is empty
+ break;
+ }
}
this.mPumpTimer = GT_Utility.safeInt(160 / (long)Math.pow(2, this.mTier) );
this.mPumpTimer = mPumpTimer==0 ? 1 : mPumpTimer;
}
+ } else {
+ // We somehow have a valid fluid, but the head of the pump isn't below the pump. Perhaps someone broke some pipes
+ // -- Clear the queue and we should try to move down until we can find a valid fluid
+ this.clearQueue(false);
}
}
getBaseMetaTileEntity().setActive(!this.mPumpList.isEmpty());
}
- //auto outputs on top
if (this.mFluid != null && (aTick % 20 == 0)) {
- IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide((byte)1);//1 is up.
+ // auto outputs on top every second or so
+ IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide((byte)1); //1 is up.
if (tTank != null) {
FluidStack tDrained = drain(1000, false);
if (tDrained != null) {
@@ -192,161 +265,213 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
}
}
+ private int getMaxPumpableDistance() {
+ return GT_MetaTileEntity_Pump.getMaxDistanceForTier(this.mTier);
+ }
+
+ private long getEuUsagePerAction() {
+ return GT_MetaTileEntity_Pump.getEuUsagePerTier(this.mTier);
+ }
+
+ private boolean hasValidFluid() {
+ return (!GT_Utility.isBlockInvalid(this.mPrimaryPumpedBlock) && !GT_Utility.isBlockInvalid(this.mSecondaryPumpedBlock));
+ }
+
private boolean moveOneDown() {
- if ((this.mInventory[0] == null) || (this.mInventory[0].stackSize < 1)
- || (!GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE))) {
+ if ((this.mInventory[0] == null) || (this.mInventory[0].stackSize < 1) || (!GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE))) {
+ // No mining pipes
return false;
}
+
int yHead = getYOfPumpHead();
- if (yHead <= 0) {
+ if (yHead <= 1) {
+ // Let's not punch through bedrock
return false;
}
- if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord())) && (!getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()).isAir(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) {
+ int x = getBaseMetaTileEntity().getXCoord(), z = getBaseMetaTileEntity().getZCoord();
+
+ if ((!consumeFluid(x, yHead - 1, z)) && (!getBaseMetaTileEntity().getBlock(x, yHead - 1, z).isAir(getBaseMetaTileEntity().getWorld(), x, yHead - 1, z))) {
+ // Either we didn't consume a fluid, or it's a non Air block
return false;
}
- if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_TIP_BLOCK, 0, false)) {
+ // Try to set the block below us to a a tip
+ if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), x, yHead - 1, z, MINING_PIPE_TIP_BLOCK, 0, false)) {
return false;
}
+ // And change the previous block to a pipe -- as long as it isn't the pump itself!
if (yHead != getBaseMetaTileEntity().getYCoord()) {
- getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_BLOCK);
+ getBaseMetaTileEntity().getWorld().setBlock(x, yHead, z, MINING_PIPE_BLOCK);
}
getBaseMetaTileEntity().decrStackSize(0, 1);
return true;
}
private int getYOfPumpHead() {
- int y = getBaseMetaTileEntity().getYCoord() - 1;
- while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) == MINING_PIPE_BLOCK) {
- y--;
+ // Let's play find the pump head!
+
+ // TODO: Handle pipe|pipe|head|pipe|pipe
+ int y = getBaseMetaTileEntity().getYCoord() - 1, x = getBaseMetaTileEntity().getXCoord(), z = getBaseMetaTileEntity().getZCoord();
+
+ while(y > 0) {
+ Block curBlock = getBaseMetaTileEntity().getBlock(x, y, z);
+ if(curBlock == MINING_PIPE_BLOCK) {
+ y--;
+ } else if (curBlock == MINING_PIPE_TIP_BLOCK) {
+ Block nextBlock = getBaseMetaTileEntity().getBlock(x, y - 1 , z);
+ if (nextBlock == MINING_PIPE_BLOCK || nextBlock == MINING_PIPE_TIP_BLOCK) {
+ // We're running into an existing set of pipes -- Turn this block into a pipe and keep going
+ this.clearQueue(true);
+ getBaseMetaTileEntity().getWorld().setBlock(x, y, z, MINING_PIPE_BLOCK);
+ }
+ y--;
+
+ } else {
+ break;
+ }
}
- if (y == getBaseMetaTileEntity().getYCoord() - 1) {
- if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != MINING_PIPE_TIP_BLOCK) {
- return y + 1;
+
+ if (getBaseMetaTileEntity().getBlock(x, y, z) != MINING_PIPE_TIP_BLOCK) {
+ if (y != getBaseMetaTileEntity().getYCoord() - 1 && getBaseMetaTileEntity().getBlock(x, y + 1, z) == MINING_PIPE_BLOCK) {
+ // We're below the pump at the bottom of the pipes, we haven't found a tip; make the previous pipe a tip!
+ this.clearQueue(true);
+ getBaseMetaTileEntity().getWorld().setBlock(x, y + 1, z, MINING_PIPE_TIP_BLOCK);
}
- } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != MINING_PIPE_TIP_BLOCK
- && this.mInventory[0] != null && this.mInventory[0].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE)) {
- getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_BLOCK);
- getBaseMetaTileEntity().decrStackSize(0, 1);
+ return y + 1;
}
return y;
}
- private void scanForFluid(int aX, int aY, int aZ, ArrayList<ChunkPosition> aList, int mX, int mZ, int mDist) {
+ private void clearQueue(boolean checkPumping) {
+ if(checkPumping) {
+ this.wasPumping = !this.mPumpList.isEmpty();
+ } else {
+ this.wasPumping = false;
+ }
+ this.mPumpList.clear();
+ }
+
+ private void rebuildPumpQueue(int aX, int yStart, int aZ, int yEnd) {
+ int mDist = this.getMaxPumpableDistance();
doTickProfilingInThisTick = false;
- ArrayList tList1 = new ArrayList();
- ArrayList tList2 = new ArrayList();
- tList1.add(new ChunkPosition(aX, aY, aZ));
- while (!tList1.isEmpty()) {
- Iterator i$ = tList1.iterator();
- do {
- if (!i$.hasNext())
- break;
- ChunkPosition tPos = (ChunkPosition) i$.next();
- if (tPos.chunkPosX < mX + mDist)
- addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX + 1, tPos.chunkPosY, tPos.chunkPosZ, tList2, aList);
- if (tPos.chunkPosX > mX - mDist)
- addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX - 1, tPos.chunkPosY, tPos.chunkPosZ, tList2, aList);
- if (tPos.chunkPosZ < mZ + mDist)
- addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ + 1, tList2, aList);
- if (tPos.chunkPosZ > mZ - mDist)
- addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ - 1, tList2, aList);
- addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(tPos.chunkPosX, tPos.chunkPosY + 1, tPos.chunkPosZ, tList2, aList);
- ChunkPosition tCoordinate = new ChunkPosition(aX, aY + 1, aZ);
- if (tPos.chunkPosX == mX && tPos.chunkPosZ == mZ && tPos.chunkPosY < getBaseMetaTileEntity().getYCoord() && !aList.contains(tCoordinate) && !tList2.contains(tCoordinate))
- tList2.add(tCoordinate);
- } while (true);
- aList.addAll(tList2);
- tList1 = tList2;
- tList2 = new ArrayList();
+ ArrayDeque<ChunkPosition> fluidsToSearch = new ArrayDeque<ChunkPosition>();
+ ArrayDeque<ChunkPosition> fluidsFound = new ArrayDeque<ChunkPosition>();
+ Set<ChunkPosition> checked = new HashSet<ChunkPosition>();
+ this.clearQueue(false);
+
+ for (int aY = yStart ; this.mPumpList.isEmpty() && aY >= yEnd ; aY--) {
+ // Start at the top (presumably the block below the pump), and work our way down to the end (presumably the location of the pump Head)
+ // and build up a queue of fluids to pump
+ fluidsToSearch.add(new ChunkPosition(aX, aY, aZ));
+
+ while (!fluidsToSearch.isEmpty()) {
+ Iterator<ChunkPosition> i$ = fluidsToSearch.iterator();
+ while(i$.hasNext()) {
+ ChunkPosition tPos = i$.next();
+
+ // Look all around
+ if (tPos.chunkPosX < aX + mDist) queueFluid(tPos.chunkPosX + 1, tPos.chunkPosY, tPos.chunkPosZ, fluidsFound, checked);
+ if (tPos.chunkPosX > aX - mDist) queueFluid(tPos.chunkPosX - 1, tPos.chunkPosY, tPos.chunkPosZ, fluidsFound, checked);
+ if (tPos.chunkPosZ < aZ + mDist) queueFluid(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ + 1, fluidsFound, checked);
+ if (tPos.chunkPosZ > aZ - mDist) queueFluid(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ - 1, fluidsFound, checked);
+
+ // And then look up
+ queueFluid(tPos.chunkPosX, tPos.chunkPosY + 1, tPos.chunkPosZ, this.mPumpList, checked);
+ }
+ this.mPumpList.addAll(fluidsFound);
+ fluidsToSearch = fluidsFound;
+ fluidsFound = new ArrayDeque<ChunkPosition>();
+ }
+
+ // Make sure we don't have the pipe location in the queue
+ this.mPumpList.remove(new ChunkPosition(aX, aY, aZ));
}
- for (int y = getBaseMetaTileEntity().getYCoord(); y >= aY; y--)
- aList.remove(new ChunkPosition(aX, y, aZ));
}
- private boolean addToFirstListIfFluidAndNotAlreadyAddedToAnyOfTheLists(int aX, int aY, int aZ, ArrayList<ChunkPosition> aList1,
- ArrayList<ChunkPosition> aList2) {
+ private boolean queueFluid(int aX, int aY, int aZ, ArrayDeque<ChunkPosition> fluidsFound, Set<ChunkPosition> checked) {
+ // If we haven't already looked at this coordinate set, and it's not already in the list of fluids found, see if there is
+ // a valid fluid and add it to the fluids found
ChunkPosition tCoordinate = new ChunkPosition(aX, aY, aZ);
- if ((!aList1.contains(tCoordinate)) && (!aList2.contains(tCoordinate))) {
+ if (checked.add(tCoordinate) && !fluidsFound.contains(tCoordinate)) {
Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
- if ((this.mPumpedBlock1 == aBlock) || (this.mPumpedBlock2 == aBlock)) {
- aList1.add(tCoordinate);
+ if ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock)) {
+ fluidsFound.addFirst(tCoordinate);
return true;
}
}
return false;
}
- private void getFluidAt(int aX, int aY, int aZ) {
+ private void checkForFluidToPump(int aX, int aY, int aZ) {
+ // If we don't currently have a valid fluid to pump, try pumping the fluid at the given coordinates
+ if(this.hasValidFluid())
+ return;
+
Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
if (GT_Utility.isBlockValid(aBlock)) {
if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) {
- this.mPumpedBlock1 = Blocks.water;
- this.mPumpedBlock2 = Blocks.flowing_water;
+ this.mPrimaryPumpedBlock = Blocks.water;
+ this.mSecondaryPumpedBlock = Blocks.flowing_water;
return;
}
if ((aBlock == Blocks.lava) || (aBlock == Blocks.flowing_lava)) {
- this.mPumpedBlock1 = Blocks.lava;
- this.mPumpedBlock2 = Blocks.flowing_lava;
+ this.mPrimaryPumpedBlock = Blocks.lava;
+ this.mSecondaryPumpedBlock = Blocks.flowing_lava;
return;
}
if ((aBlock instanceof IFluidBlock)) {
- this.mPumpedBlock1 = aBlock;
- this.mPumpedBlock2 = aBlock;
+ this.mPrimaryPumpedBlock = aBlock;
+ this.mSecondaryPumpedBlock = aBlock;
return;
}
}
- this.mPumpedBlock1 = null;
- this.mPumpedBlock2 = null;
+ this.mPrimaryPumpedBlock = null;
+ this.mSecondaryPumpedBlock = null;
}
private boolean consumeFluid(int aX, int aY, int aZ) {
+ // Try to consume a fluid at a location
+ // Returns true if something was consumed, otherwise false
if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), aX, aY, aZ, true)) return false;
+
Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
- int aMeta = getBaseMetaTileEntity().getMetaID(aX, aY, aZ);
- if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPumpedBlock1 == aBlock) || (this.mPumpedBlock2 == aBlock))) {
- if ((aBlock == Blocks.water) || (aBlock == Blocks.flowing_water)) {
- if (aMeta == 0) {
- if (this.mFluid == null) {
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true);
- this.mFluid = GT_ModHandler.getWater(1000L);
- } else if (GT_ModHandler.isWater(this.mFluid)) {
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true);
- this.mFluid.amount += 1000;
- } else {
- return false;
- }
- } else {
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(4 * ((long) Math.pow(4, this.mTier)), true);
- }
- }
- if ((aBlock == Blocks.lava) || (aBlock == Blocks.flowing_lava)) {
- if (aMeta == 0) {
- if (this.mFluid == null) {
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true);
- this.mFluid = GT_ModHandler.getLava(1000L);
- } else if (GT_ModHandler.isLava(this.mFluid)) {
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true);
- this.mFluid.amount += 1000;
- } else {
- return false;
- }
- } else {
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(4 * ((long) Math.pow(4, this.mTier)), true);
+
+ if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPrimaryPumpedBlock == aBlock) || (this.mSecondaryPumpedBlock == aBlock))) {
+ boolean isWaterOrLava = ((this.mPrimaryPumpedBlock == Blocks.water || this.mPrimaryPumpedBlock == Blocks.lava));
+
+ if (isWaterOrLava && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) != 0) {
+ // Water/Lava that isn't a source block - do nothing here, but set the block to air and consume energy below
+ if (D1) {
+ GT_Log.out.println("PUMP: Water/Lava - Not a source block");
}
- }
- if ((aBlock instanceof IFluidBlock)) {
- if (this.mFluid == null) {
+ } else if (this.mFluid == null) {
+ // The pump has no internal fluid
+ if (this.mPrimaryPumpedBlock == Blocks.water)
+ this.mFluid = GT_ModHandler.getWater(1000L);
+ else if (this.mPrimaryPumpedBlock == Blocks.lava)
+ this.mFluid = GT_ModHandler.getLava(1000L);
+ else {
+ // Not water or lava; try to drain and set to air
this.mFluid = ((IFluidBlock) aBlock).drain(getBaseMetaTileEntity().getWorld(), aX, aY, aZ, true);
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mFluid == null ? 1000 : this.mFluid.amount, true);
- } else if (this.mFluid.isFluidEqual(((IFluidBlock) aBlock).drain(getBaseMetaTileEntity().getWorld(), aX, aY, aZ, false))) {
+ }
+ } else if (GT_ModHandler.isWater(this.mFluid) || GT_ModHandler.isLava(this.mFluid) ||
+ this.mFluid.isFluidEqual(((IFluidBlock) aBlock).drain(getBaseMetaTileEntity().getWorld(), aX, aY, aZ, false)))
+ {
+ if (!isWaterOrLava) {
+ // Only set Block to Air for non lava/water fluids
this.getBaseMetaTileEntity().getWorld().setBlockToAir(aX, aY, aZ);
- this.mFluid.amount += 1000;
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(16 * ((long) Math.pow(4, this.mTier)), true);
- } else {
- return false;
}
+ this.mFluid.amount += 1000;
+
+ } else {
+ if (D1) {
+ GT_Log.out.println("PUMP: Couldn't consume " + aBlock);
+ }
+ // We didn't do anything
+ return false;
}
+
+ getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.getEuUsagePerAction(), true);
getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ, Blocks.air, 0, 2);
return true;
}
@@ -470,10 +595,10 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
}
private FakePlayer mFakePlayer = null;
- protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) {
- if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile);
- mFakePlayer.setWorld(aBaseTile.getWorld());
- mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord());
- return mFakePlayer;
- }
+ protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) {
+ if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile);
+ mFakePlayer.setWorld(aBaseTile.getWorld());
+ mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord());
+ return mFakePlayer;
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
index 955d873da6..a82a538876 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
@@ -45,8 +45,8 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu
"Size(WxHxD): 3x3x3",
"3x3x3 of Chemically Inert Machine Casings (hollow, min 8!)",
"Controller (Front centered)",
- "1x Cupronickel Coil Block (Bottom centered)",
"1x PTFE Pipe Machine Casing (inside the hollow casings)",
+ "1x Cupronickel Coil Block (next to PTFE Pipe Machine Casing)",
"1x Input Bus/Hatch (Any inert casing)",
"1x Output Bus/Hatch (Any inert casing)",
"1x Maintenance Hatch (Any inert casing)",
@@ -151,20 +151,37 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
int casingAmount = 0;
+ boolean hasHeatingCoil = false;
// x=width, z=depth, y=height
for (int x = -1 + xDir; x <= xDir + 1; x++) {
for (int z = -1 + zDir; z <= zDir + 1; z++) {
for (int y = -1; y <= 1; y++) {
+ if (x == 0 && y == 0 && z == 0) {
+ continue;
+ }
IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z);
Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z);
- if (x == xDir && z == zDir && y <= 0) {
- if ((y == -1)
- && (block != GregTech_API.sBlockCasings5 || aBaseMetaTileEntity.getMetaIDOffset(x, y, z) != 0)) {
- return false;
- } else if (y == 0 && (block != GregTech_API.sBlockCasings8 || aBaseMetaTileEntity.getMetaIDOffset(x, y, z) != 1)) {
+ int centerCoords = 0;
+ if (x == xDir) {
+ centerCoords++;
+ }
+ if (y == 0) {
+ centerCoords++;
+ }
+ if (z == zDir) {
+ centerCoords++;
+ }
+ if (centerCoords == 3) {
+ if (block == GregTech_API.sBlockCasings8 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) {
+ continue;
+ } else {
return false;
}
- } else if (x != 0 || y != 0 || z != 0) {
+ }
+ if (centerCoords == 2 && block == GregTech_API.sBlockCasings5 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 0) {
+ hasHeatingCoil = true;
+ continue;
+ }
if (!addInputToMachineList(tileEntity, CASING_INDEX) && !addOutputToMachineList(tileEntity, CASING_INDEX)
&& !addMaintenanceToMachineList(tileEntity, CASING_INDEX)
&& !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) {
@@ -174,13 +191,12 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu
return false;
}
}
- }
}
}
}
- return casingAmount >= 8;
+ return casingAmount >= 8 && hasHeatingCoil;
}
@Override
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java
index 282e8417b0..057ba9e0cc 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java
@@ -38,12 +38,13 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
"Thermally cracks heavy hydrocarbons into lighter fractions",
"Size(WxHxD): 5x3x3 (Hollow), Controller (Front center)",
"Ring of 8 Cupronickel Coils (Each side of Controller)",
- "1x Hydrocarbon Input Bus/Hatch (Any left side casing)",
+ "1x Hydrocarbon Input Bus/Hatch (Any left/right side casing)",
"1x Steam/Hydrogen Input Hatch (Any middle ring casing)",
- "1x Cracked Hydrocarbon Output Hatch (Any right side casing)",
- "1x Maintenance Hatch (Any middle ring casing)",
- "1x Energy Hatch (Any middle ring casing)",
- "Clean Stainless Steel Machine Casings for the rest (18 at least!)"};
+ "1x Cracked Hydrocarbon Output Hatch (Any left/right side casing)",
+ "1x Maintenance Hatch (Any casing)",
+ "1x Energy Hatch (Any casing)",
+ "Clean Stainless Steel Machine Casings for the rest (18 at least!)",
+ "Input/Output Hatches must be on opposite sides"};
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
@@ -95,6 +96,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
int zDir = this.orientation.offsetZ;
int amount = 0;
replaceDeprecatedCoils(aBaseMetaTileEntity);
+ boolean negSideInput = false, negSideOutput = false, posSideInput = false, posSideOutput = false;
if (xDir != 0) {
for (int i = -1; i < 2; i++) {// xDirection
for (int j = -1; j < 2; j++) {// height
@@ -110,8 +112,19 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
}
if (h == 2 || h == -2) {
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir);
- boolean tSide = ((aBaseMetaTileEntity.getBackFacing() == 4 && 2 == h) || (aBaseMetaTileEntity.getBackFacing() == 5 && -2 == h));
- if (tSide ? !addInputToMachineList(tTileEntity, 49) : !addOutputToMachineList(tTileEntity, 49)) {
+ if (addInputToMachineList(tTileEntity, 49)) {
+ if (h == -2) {
+ negSideInput = true;
+ } else {
+ posSideInput = true;
+ }
+ } else if (addOutputToMachineList(tTileEntity, 49)) {
+ if (h == -2) {
+ negSideOutput = true;
+ } else {
+ posSideOutput = true;
+ }
+ } else if (!addEnergyInputToMachineList(tTileEntity, 49) && !addMaintenanceToMachineList(tTileEntity, 49)){
if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4) {
return false;
}
@@ -156,8 +169,19 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
}
if (h == 2 || h == -2) {
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir);
- boolean tSide = (aBaseMetaTileEntity.getBackFacing() == h || (aBaseMetaTileEntity.getBackFacing() == 3 && -2 == h));
- if (tSide ? !addOutputToMachineList(tTileEntity, 49) : !addInputToMachineList(tTileEntity, 49)) {
+ if (addInputToMachineList(tTileEntity, 49)) {
+ if (h == -2) {
+ negSideInput = true;
+ } else {
+ posSideInput = true;
+ }
+ } else if (addOutputToMachineList(tTileEntity, 49)) {
+ if (h == -2) {
+ negSideOutput = true;
+ } else {
+ posSideOutput = true;
+ }
+ } else if (!addEnergyInputToMachineList(tTileEntity, 49) && !addMaintenanceToMachineList(tTileEntity, 49)){
if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings4) {
return false;
}
@@ -188,6 +212,10 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa
}
}
}
+ if ((negSideInput && negSideOutput) || (posSideInput && posSideOutput)
+ || (negSideInput && posSideInput) || (negSideOutput && posSideOutput)) {
+ return false;
+ }
if (amount < 18) return false;
return true;
}