aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java235
1 files changed, 135 insertions, 100 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index 372db7da10..0401d7e15a 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -242,6 +242,32 @@ GT_MetaTileEntity_MultiBlockBase {
return true;
}
+ /**
+ * A Static {@link Method} object which holds the current status of logging.
+ */
+ Method aLogger = null;
+
+ public void log(String s) {
+ boolean isDebugLogging = false;
+ boolean reset = false;
+ if (aLogger == null || reset) {
+ if (isDebugLogging) {
+ try {
+ aLogger = Logger.class.getMethod("INFO", String.class);
+ } catch (NoSuchMethodException | SecurityException e) {}
+ }
+ else {
+ try {
+ aLogger = Logger.class.getMethod("MACHINE_INFO", String.class);
+ } catch (NoSuchMethodException | SecurityException e) {}
+ }
+ }
+ try {
+ aLogger.invoke(null, s);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {}
+
+ }
+
public boolean checkRecipeGeneric() {
return checkRecipeGeneric(1, 100, 0);
}
@@ -264,6 +290,9 @@ GT_MetaTileEntity_MultiBlockBase {
int aSpeedBonusPercent, int aOutputChanceRoll) {
// Based on the Processing Array. A bit overkill, but very flexible.
+
+
+
// Reset outputs and progress stats
this.mEUt = 0;
this.mMaxProgresstime = 0;
@@ -272,24 +301,24 @@ GT_MetaTileEntity_MultiBlockBase {
long tVoltage = getMaxInputVoltage();
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
- Logger.MACHINE_INFO("Running checkRecipeGeneric(0)");
+ log("Running checkRecipeGeneric(0)");
GT_Recipe tRecipe = findRecipe(
getBaseMetaTileEntity(), mLastRecipe, false,
gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);
- Logger.MACHINE_INFO("Running checkRecipeGeneric(1)");
+ log("Running checkRecipeGeneric(1)");
// Remember last recipe - an optimization for findRecipe()
this.mLastRecipe = tRecipe;
if (tRecipe == null) {
- Logger.MACHINE_INFO("BAD RETURN - 1");
+ log("BAD RETURN - 1");
return false;
}
if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) {
- Logger.MACHINE_INFO("BAD RETURN - 2");
+ log("BAD RETURN - 2");
return false;
}
@@ -299,23 +328,23 @@ GT_MetaTileEntity_MultiBlockBase {
int parallelRecipes = 0;
- Logger.MACHINE_INFO("parallelRecipes: "+parallelRecipes);
- Logger.MACHINE_INFO("aMaxParallelRecipes: "+aMaxParallelRecipes);
- Logger.MACHINE_INFO("tTotalEUt: "+tTotalEUt);
- Logger.MACHINE_INFO("tVoltage: "+tVoltage);
- Logger.MACHINE_INFO("tRecipeEUt: "+tRecipeEUt);
+ log("parallelRecipes: "+parallelRecipes);
+ log("aMaxParallelRecipes: "+aMaxParallelRecipes);
+ log("tTotalEUt: "+tTotalEUt);
+ log("tVoltage: "+tVoltage);
+ log("tRecipeEUt: "+tRecipeEUt);
// Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits
for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) {
if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) {
- Logger.MACHINE_INFO("Broke at "+parallelRecipes+".");
+ log("Broke at "+parallelRecipes+".");
break;
}
- Logger.MACHINE_INFO("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+".");
+ log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+".");
tTotalEUt += tRecipeEUt;
}
if (parallelRecipes == 0) {
- Logger.MACHINE_INFO("BAD RETURN - 3");
+ log("BAD RETURN - 3");
return false;
}
@@ -412,7 +441,7 @@ GT_MetaTileEntity_MultiBlockBase {
// Play sounds (GT++ addition - GT multiblocks play no sounds)
startProcess();
- Logger.MACHINE_INFO("GOOD RETURN - 1");
+ log("GOOD RETURN - 1");
return true;
}
@@ -438,16 +467,16 @@ GT_MetaTileEntity_MultiBlockBase {
(100 - percentage));
cloneRecipe.mDuration = tempTime;
if (cloneRecipe.mDuration < originalTime) {
- Logger.MACHINE_INFO("Generated recipe with a smaller time. | "
+ log("Generated recipe with a smaller time. | "
+ originalTime + " | " + cloneRecipe.mDuration + " |");
return cloneRecipe;
} else {
- Logger.MACHINE_INFO("Did not generate recipe with a smaller time. | "
+ log("Did not generate recipe with a smaller time. | "
+ originalTime + " | " + cloneRecipe.mDuration + " |");
return tRecipe;
}
}
- Logger.MACHINE_INFO("Error generating recipe, returning null.");
+ log("Error generating recipe, returning null.");
return null;
}
@@ -807,6 +836,10 @@ GT_MetaTileEntity_MultiBlockBase {
public int getPollutionPerTick(ItemStack arg0) {
return 0;
}
+
+ public String getPollutionTooltip() {
+ return "Causes " + 20 * this.getPollutionPerTick(null) + " Pollution per second";
+ }
@Override
public void saveNBTData(NBTTagCompound aNBT) {
@@ -873,116 +906,118 @@ GT_MetaTileEntity_MultiBlockBase {
final boolean aNotUnificated, final boolean aDontCheckStackSizes, final long aVoltage,
final FluidStack[] aFluids, final ItemStack aSpecialSlot, ItemStack... aInputs) {
if (this.getRecipeMap().mRecipeList.isEmpty()) {
- Logger.MACHINE_INFO("No Recipes in Map to search through.");
+ Logger.INFO("No Recipes in Map to search through.");
return null;
}
GT_Recipe mRecipeResult = null;
try {
- if (GregTech_API.sPostloadFinished) {
- if (this.getRecipeMap().mMinimalInputFluids > 0) {
- if (aFluids == null) {
- Logger.MACHINE_INFO("aFluids == null && minFluids > 0");
- return null;
- }
- int tAmount = 0;
- for (final FluidStack aFluid : aFluids) {
- if (aFluid != null) {
- ++tAmount;
+ if (GregTech_API.sPostloadFinished) {
+ if (this.getRecipeMap().mMinimalInputFluids > 0) {
+ if (aFluids == null) {
+ Logger.INFO("aFluids == null && minFluids > 0");
+ return null;
}
- }
- if (tAmount < this.getRecipeMap().mMinimalInputFluids) {
- Logger.MACHINE_INFO("Not enough fluids?");
- return null;
- }
- }
- if (this.getRecipeMap().mMinimalInputItems > 0) {
- if (aInputs == null) {
- Logger.MACHINE_INFO("No inputs and minItems > 0");
- return null;
- }
- int tAmount = 0;
- for (final ItemStack aInput : aInputs) {
- if (aInput != null) {
- ++tAmount;
+ int tAmount = 0;
+ for (final FluidStack aFluid : aFluids) {
+ if (aFluid != null) {
+ ++tAmount;
+ }
+ }
+ if (tAmount < this.getRecipeMap().mMinimalInputFluids) {
+ Logger.INFO("Not enough fluids?");
+ return null;
}
}
- if (tAmount < this.getRecipeMap().mMinimalInputItems) {
- Logger.MACHINE_INFO("Not enough items?");
- return null;
+ if (this.getRecipeMap().mMinimalInputItems > 0) {
+ if (aInputs == null) {
+ Logger.INFO("No inputs and minItems > 0");
+ return null;
+ }
+ int tAmount = 0;
+ for (final ItemStack aInput : aInputs) {
+ if (aInput != null) {
+ ++tAmount;
+ }
+ }
+ if (tAmount < this.getRecipeMap().mMinimalInputItems) {
+ Logger.INFO("Not enough items?");
+ return null;
+ }
}
}
- }
- else {
- Logger.MACHINE_INFO("Game Not Loaded properly for recipe lookup.");
- }
- if (aNotUnificated) {
- aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs);
- }
- if (aRecipe != null && !aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered
- && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) {
- mRecipeResult = (aRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= aRecipe.mEUt*/) ? aRecipe : null;
- Logger.MACHINE_INFO("x) Found Recipe? "+(mRecipeResult != null ? "true" : "false"));
- if (mRecipeResult != null) {
- return mRecipeResult;
+ else {
+ Logger.INFO("Game Not Loaded properly for recipe lookup.");
}
- }
- if (mRecipeResult == null && this.getRecipeMap().mUsualInputCount >= 0 && aInputs != null && aInputs.length > 0) {
- for (final ItemStack tStack : aInputs) {
- if (tStack != null) {
- Collection<GT_Recipe> tRecipes = this.getRecipeMap().mRecipeItemMap.get(new GT_ItemStack(tStack));
- if (tRecipes != null) {
- for (final GT_Recipe tRecipe : tRecipes) {
- if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) {
- mRecipeResult = (tRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/)
- ? tRecipe
- : null;
- Logger.MACHINE_INFO("1) Found Recipe? "+(mRecipeResult != null ? "true" : "false"));
- //return mRecipeResult;
+ if (aNotUnificated) {
+ aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs);
+ }
+ if (aRecipe != null && !aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered
+ && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) {
+ mRecipeResult = (aRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= aRecipe.mEUt*/) ? aRecipe : null;
+ Logger.INFO("x) Found Recipe? "+(mRecipeResult != null ? "true" : "false"));
+ if (mRecipeResult != null) {
+ return mRecipeResult;
+ }
+ }
+ if (mRecipeResult == null && this.getRecipeMap().mUsualInputCount >= 0 && aInputs != null && aInputs.length > 0) {
+ for (final ItemStack tStack : aInputs) {
+ if (tStack != null) {
+ Collection<GT_Recipe> tRecipes = this.getRecipeMap().mRecipeItemMap.get(new GT_ItemStack(tStack));
+ if (tRecipes != null) {
+ for (final GT_Recipe tRecipe : tRecipes) {
+ if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) {
+ mRecipeResult = (tRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/)
+ ? tRecipe
+ : null;
+ Logger.INFO("1) Found Recipe? "+(mRecipeResult != null ? "true" : "false"));
+ //return mRecipeResult;
+ }
}
}
- }
- tRecipes = this.getRecipeMap().mRecipeItemMap
- .get(new GT_ItemStack(GT_Utility.copyMetaData(32767L, new Object[]{tStack})));
- if (tRecipes != null) {
- for (final GT_Recipe tRecipe : tRecipes) {
- if (!tRecipe.mFakeRecipe
- && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) {
- mRecipeResult = (tRecipe.mEnabled && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt)
- ? tRecipe
- : null;
- Logger.MACHINE_INFO("2) Found Recipe? "+(mRecipeResult != null ? "true" : "false"));
- //return mRecipeResult;
+
+ //TODO - Investigate if this requires to be in it's own block
+ tRecipes = this.getRecipeMap().mRecipeItemMap
+ .get(new GT_ItemStack(GT_Utility.copyMetaData(32767L, new Object[]{tStack})));
+ if (tRecipes != null) {
+ for (final GT_Recipe tRecipe : tRecipes) {
+ if (!tRecipe.mFakeRecipe
+ && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) {
+ mRecipeResult = (tRecipe.mEnabled /*&& aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/)
+ ? tRecipe
+ : null;
+ Logger.INFO("2) Found Recipe? "+(mRecipeResult != null ? "true" : "false"));
+ //return mRecipeResult;
+ }
}
}
}
}
}
- }
- if (mRecipeResult == null && this.getRecipeMap().mMinimalInputItems == 0 && aFluids != null && aFluids.length > 0) {
- for (final FluidStack aFluid2 : aFluids) {
- if (aFluid2 != null) {
- final Collection<GT_Recipe> tRecipes = this.getRecipeMap().mRecipeFluidMap.get(aFluid2.getFluid());
- if (tRecipes != null) {
- for (final GT_Recipe tRecipe : tRecipes) {
- if (!tRecipe.mFakeRecipe
- && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) {
- mRecipeResult = (tRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/)
- ? tRecipe
- : null;
- Logger.MACHINE_INFO("3) Found Recipe? "+(mRecipeResult != null ? "true" : "false"));
- //return mRecipeResult;
+ if (mRecipeResult == null && this.getRecipeMap().mMinimalInputItems == 0 && aFluids != null && aFluids.length > 0) {
+ for (final FluidStack aFluid2 : aFluids) {
+ if (aFluid2 != null) {
+ final Collection<GT_Recipe> tRecipes = this.getRecipeMap().mRecipeFluidMap.get(aFluid2.getFluid());
+ if (tRecipes != null) {
+ for (final GT_Recipe tRecipe : tRecipes) {
+ if (!tRecipe.mFakeRecipe
+ && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) {
+ mRecipeResult = (tRecipe.mEnabled/* && aVoltage * this.getRecipeMap().mAmperage >= tRecipe.mEUt*/)
+ ? tRecipe
+ : null;
+ Logger.INFO("3) Found Recipe? "+(mRecipeResult != null ? "true" : "false"));
+ //return mRecipeResult;
+ }
}
}
}
}
}
}
- }
catch (Throwable t) {
- Logger.MACHINE_INFO("Invalid recipe lookup.");
+ Logger.INFO("Invalid recipe lookup.");
}
if (mRecipeResult == null) {
- return this.getRecipeMap().findRecipe(aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, aSpecialSlot, aInputs);
+ return this.getRecipeMap().findRecipe(aTileEntity, aRecipe, aNotUnificated, aDontCheckStackSizes, aVoltage, aFluids, aSpecialSlot, aInputs);
}
else {
return mRecipeResult;