aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java7
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java49
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java53
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java2
-rw-r--r--src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java7
5 files changed, 82 insertions, 36 deletions
diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java
new file mode 100644
index 0000000000..9306ef28f3
--- /dev/null
+++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java
@@ -0,0 +1,7 @@
+package gregtech.api.interfaces.metatileentity;
+
+public interface IMachineCallback<Machinetype extends IMetaTileEntity> {
+ Machinetype getCallbackBase();
+ void setCallbackBase(Machinetype callback);
+ Class<Machinetype> getType();
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
index 1c5b90f7db..97daa6fc71 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
@@ -7,6 +7,7 @@ import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_Container_BasicMachine;
import gregtech.api.gui.GT_GUIContainer_BasicMachine;
import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMachineCallback;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
@@ -15,6 +16,7 @@ import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -37,7 +39,8 @@ import static gregtech.api.enums.GT_Values.debugCleanroom;
* This is the main construct for my Basic Machines such as the Automatic Extractor
* Extend this class to make a simple Machine
*/
-public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank {
+public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank implements IMachineCallback<GT_MetaTileEntity_Cleanroom> {
+
/**
* return values for checkRecipe()
*/
@@ -51,8 +54,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false;
public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0;
public FluidStack mOutputFluid;
- public String mGUIName = "", mNEIName = "";
- public GT_MetaTileEntity_MultiBlockBase mCleanroom;
+ public String mGUIName, mNEIName;
+
+
+ @Deprecated
+ public GT_MetaTileEntity_Cleanroom mCleanroom;
/**
* Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered
*/
@@ -126,6 +132,21 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
}
@Override
+ public GT_MetaTileEntity_Cleanroom getCallbackBase() {
+ return this.mCleanroom;
+ }
+
+ @Override
+ public void setCallbackBase(GT_MetaTileEntity_Cleanroom callback) {
+ this.mCleanroom = callback;
+ }
+
+ @Override
+ public Class<GT_MetaTileEntity_Cleanroom> getType() {
+ return GT_MetaTileEntity_Cleanroom.class;
+ }
+
+ @Override
public ITexture[][][] getTextureSet(ITexture[] aTextures) {
ITexture[][][] rTextures = new ITexture[14][17][];
aTextures = Arrays.copyOf(aTextures, 14);
@@ -449,7 +470,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy());
else if (mOutputFluid.isFluidEqual(getDrainableStack()))
getDrainableStack().amount += mOutputFluid.amount;
- for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null;
+ Arrays.fill(mOutputItems, null);
mOutputFluid = null;
mEUt = 0;
mProgresstime = 0;
@@ -518,7 +539,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
startProcess();
} else {
mMaxProgresstime = 0;
- for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null;
+ Arrays.fill(mOutputItems, null);
mOutputFluid = null;
}
}
@@ -584,7 +605,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
//Long EUt calculation
long xEUt=aEUt;
//Isnt too low EUt check?
- long tempEUt = xEUt<V[1] ? V[1] : xEUt;
+ long tempEUt = Math.max(xEUt, V[1]);
mMaxProgresstime = aDuration;
@@ -652,7 +673,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
protected boolean isOutputEmpty() {
boolean rIsEmpty = true;
- for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false;
+ for (ItemStack tOutputSlotContent : getAllOutputs())
+ if (tOutputSlotContent != null) {
+ rIsEmpty = false;
+ break;
+ }
return rIsEmpty;
}
@@ -816,7 +841,9 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
/**
*
* @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method...
- * @return
+ * @return DID_NOT_FIND_RECIPE = 0,
+ * FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1,
+ * FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2;
*/
public int checkRecipe(boolean skipOC){
GT_Recipe_Map tMap = getRecipeList();
@@ -832,7 +859,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mOutputBlocked++;
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
}
- if (tRecipe.mSpecialValue == -200 && (mCleanroom == null || mCleanroom.mEfficiency == 0))
+ if (tRecipe.mSpecialValue == -200 && (getCallbackBase() == null || getCallbackBase().mEfficiency == 0))
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs()))
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
@@ -841,12 +868,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mOutputItems[i] = tRecipe.getOutput(i);
if (tRecipe.mSpecialValue == -200 || tRecipe.mSpecialValue == -300)
for (int i = 0; i < mOutputItems.length; i++)
- if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > mCleanroom.mEfficiency)
+ if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > getCallbackBase().mEfficiency)
{
if (debugCleanroom) {
GT_Log.out.println(
"BasicMachine: Voiding output due to efficiency failure. mEfficiency = " +
- mCleanroom.mEfficiency
+ getCallbackBase().mEfficiency
);
}
mOutputItems[i] = null;
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java
index 6ceebc3877..21a407f6e2 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java
@@ -5,10 +5,10 @@ import gregtech.api.enums.GT_Values;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMachineCallback;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicHull;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Log;
@@ -16,9 +16,9 @@ import gregtech.api.util.GT_Recipe;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
import static gregtech.api.enums.GT_Values.debugCleanroom;
-import static gregtech.api.enums.GT_Values.V;
public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBase {
private int mHeight = -1;
@@ -207,24 +207,8 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas
if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1 || mDoorCount != 2 || mHullCount > 10) {
return false;
}
- for (int dX = -x + 1; dX <= x - 1; dX++) {
- for (int dZ = -z + 1; dZ <= z - 1; dZ++) {
- for (int dY = -1; dY >= y + 1; dY--) {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(dX, dY, dZ);
- if (tTileEntity != null) {
- IMetaTileEntity aMetaTileEntity = tTileEntity.getMetaTileEntity();
- if (aMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine) {
- if (debugCleanroom) {
- GT_Log.out.println(
- "Cleanroom: Machine detected, adding pointer back to cleanroom"
- );
- }
- ((GT_MetaTileEntity_BasicMachine) aMetaTileEntity).mCleanroom = this;
- }
- }
- }
- }
- }
+
+ setCallbacks(x, y, z, aBaseMetaTileEntity);
if (doorState) {
this.mEfficiency = Math.max(0, this.mEfficiency - 200);
@@ -240,7 +224,34 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas
return mPlascreteCount>=20 && mGlassCount < (int) Math.floor(ratio);
}
-
+
+ private void setCallbacks(int x, int y, int z, IGregTechTileEntity aBaseMetaTileEntity){
+ for (int dX = -x + 1; dX <= x - 1; dX++)
+ for (int dZ = -z + 1; dZ <= z - 1; dZ++)
+ for (int dY = -1; dY >= y + 1; dY--) {
+ TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityOffset(dX, dY, dZ);
+
+ if (tTileEntity instanceof IGregTechTileEntity) {
+ IMetaTileEntity iMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
+
+ if (iMetaTileEntity instanceof IMachineCallback<?>)
+ checkAndSetCallback((IMachineCallback<?>) iMetaTileEntity);
+
+ } else if (tTileEntity instanceof IMachineCallback<?>)
+ checkAndSetCallback((IMachineCallback<?>) tTileEntity);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void checkAndSetCallback(IMachineCallback<?> iMachineCallback) {
+ if (debugCleanroom)
+ GT_Log.out.println(
+ "Cleanroom: IMachineCallback detected, checking for cleanroom: " + (iMachineCallback.getType() == this.getClass())
+ );
+ if (iMachineCallback.getType() == this.getClass())
+ ((IMachineCallback<GT_MetaTileEntity_Cleanroom>) iMachineCallback).setCallbackBase(this);
+ }
+
@Override
public boolean allowGeneralRedstoneOutput(){
return true;
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 13764b928e..fad880e5e4 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
@@ -190,7 +190,7 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu
}
}
- return casingAmount >= 8 && hasHeatingCoil;
+ return casingAmount >= 8 && hasHeatingCoil && !mEnergyHatches.isEmpty() && !mMaintenanceHatches.isEmpty();
}
@Override
diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java
index a97e0513d1..9e2dd32349 100644
--- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java
+++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java
@@ -708,8 +708,8 @@ public class GT_MachineRecipeLoader implements Runnable {
//GT_Values.RA.addChemicalRecipe(Materials.Ichorium.getNuggets(4), GT_ModHandler.getModItem("dreamcraft", "item.PrimordialPearlFragment", 1L, 0), Materials.Radon.getGas(16000L), Materials.GrowthMediumRaw.getFluid(16000L), GT_Values.NI, 300, 30720);
//GT_Values.RA.addChemicalRecipe(Materials.BlackPlutonium.getDust(4), Materials.Americium.getDust(4), Materials.Radon.getGas(2000L), Materials.GrowthMediumRaw.getFluid(2000L), GT_Values.NI, 300, 30720);
//GT_Values.RA.addChemicalRecipe(Materials.CosmicNeutronium.getDustTiny(1), Materials.InfinityCatalyst.getDustTiny(1), Materials.Radon.getGas(32000L), Materials.GrowthMediumRaw.getFluid(32000L), GT_Values.NI, 600, 122880);
- GT_Values.RA.addChemicalRecipe(GT_ModHandler.getModItem("GalaxySpace","item.UnknowCrystal",16L), Materials.Osmiridium.getDust(2), Materials.GrowthMediumSterilized.getFluid(1000L), FluidRegistry.getFluidStack("bacterialsludge", 1000), ItemList.Circuit_Chip_Stemcell.get(64L), GT_Values.NI,600, 30720);
- GT_Values.RA.addChemicalRecipe(ItemList.Circuit_Chip_Stemcell.get(16L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.CosmicNeutronium, 2), Materials.BioMediumSterilized.getFluid(1000L), FluidRegistry.getFluidStack("mutagen", 1000), ItemList.Circuit_Chip_Biocell.get(16L), GT_Values.NI,1200, 500000);
+ GT_Values.RA.addChemicalRecipe(GT_ModHandler.getModItem("GalaxySpace","item.UnknowCrystal",4L), Materials.Osmiridium.getDust(2), Materials.GrowthMediumSterilized.getFluid(1000L), FluidRegistry.getFluidStack("bacterialsludge", 1000), ItemList.Circuit_Chip_Stemcell.get(64L), GT_Values.NI,600, 30720);
+ GT_Values.RA.addChemicalRecipe(ItemList.Circuit_Chip_Stemcell.get(32L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.CosmicNeutronium, 4), Materials.BioMediumSterilized.getFluid(2000L), FluidRegistry.getFluidStack("mutagen", 2000), ItemList.Circuit_Chip_Biocell.get(32L), GT_Values.NI,1200, 500000);
//GT_Values.RA.addMixerRecipe(Materials.MysteriousCrystal.getDust(16), Materials.Oriharukon.getDust(16), Materials.CosmicNeutronium.getDust(4), Materials.Infinity.getDustTiny(1), GT_ModHandler.getModItem("dreamcraft", "item.TCetiESeaweedExtract", 16L, 0), GT_Values.NI, Materials.GrowthMediumRaw.getFluid(4000L), Materials.BioMediumRaw.getFluid(4000L), GT_Values.NI, 300, 500000);
GT_Values.RA.addFluidHeaterRecipe(GT_Utility.getIntegratedCircuit(1), Materials.GrowthMediumRaw.getFluid(1000L), Materials.GrowthMediumSterilized.getFluid(1000L), 200, 7680);
GT_Values.RA.addFluidHeaterRecipe(GT_Utility.getIntegratedCircuit(1), Materials.BioMediumRaw.getFluid(1000L), Materials.BioMediumSterilized.getFluid(1000L), 200, 30720);
@@ -2158,7 +2158,8 @@ public class GT_MachineRecipeLoader implements Runnable {
this.addProcess(tCrop, Materials.CassiteriteSand, 100, true);
tCrop = ItemList.Crop_Drop_Plumbilia.get(1);
this.addProcess(tCrop, Materials.Lead, 100, true);
- tCrop = ItemList.Crop_Drop_Ferru.get(1);
+ this.addProcess(tCrop, Materials.Galena, 100, false);//
+ tCrop = ItemList.Crop_Drop_Ferru.get(1);
this.addProcess(tCrop, Materials.Iron, 100, true);
this.addProcess(tCrop, Materials.Magnetite, 100, false);
this.addProcess(tCrop, Materials.BrownLimonite, 100, false);