aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities
diff options
context:
space:
mode:
authorAlkalus <Draknyte1@hotmail.com>2020-04-11 22:40:18 +0100
committerAlkalus <Draknyte1@hotmail.com>2020-04-11 22:40:18 +0100
commitbaf1f6ff533b9ada00aeb7de98dd0bdaf5c28e10 (patch)
tree9cf8c1f5d0519345680569c0863eb7afe54ebb6b /src/Java/gtPlusPlus/xmod/gregtech/common/tileentities
parent2a5ab9b1fce054e25af438c550328d7c18680a17 (diff)
downloadGT5-Unofficial-baf1f6ff533b9ada00aeb7de98dd0bdaf5c28e10.tar.gz
GT5-Unofficial-baf1f6ff533b9ada00aeb7de98dd0bdaf5c28e10.tar.bz2
GT5-Unofficial-baf1f6ff533b9ada00aeb7de98dd0bdaf5c28e10.zip
+ Added more milled materials.
+ Added proper structure for Flotation Cells. + Added all milled materials to flotation cell recipes. + Added Human meat drops for dead players. + Added Slicing mode for ICM. % Changed getVoltageForTier to be a switch case. % Stopped download of cape list in dev environment. $ Adjusted how Fusion MK4 injects power, it now pulls the voltage of the hatch. $ Fixed Fake Player Handling.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java38
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java93
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java501
3 files changed, 359 insertions, 273 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java
index 6a154051d5..31c9636cac 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java
@@ -1,25 +1,28 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing;
-import net.minecraft.block.Block;
-import net.minecraft.item.ItemStack;
-
import gregtech.api.enums.TAE;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
-import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
public class GregtechMetaTileEntity_IndustrialCuttingMachine
extends GregtechMeta_MultiBlockBase {
+
+ private boolean mCuttingMode = true;
+
public GregtechMetaTileEntity_IndustrialCuttingMachine(final int aID, final String aName, final String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -35,7 +38,7 @@ extends GregtechMeta_MultiBlockBase {
@Override
public String getMachineType() {
- return "Cutting Machine";
+ return "Cutting Machine / Slicing Machine";
}
@Override
@@ -74,7 +77,7 @@ extends GregtechMeta_MultiBlockBase {
@Override
public GT_Recipe.GT_Recipe_Map getRecipeMap() {
- return GT_Recipe.GT_Recipe_Map.sCutterRecipes;
+ return mCuttingMode ? GT_Recipe.GT_Recipe_Map.sCutterRecipes : GT_Recipe.GT_Recipe_Map.sSlicerRecipes;
}
@Override
@@ -202,11 +205,22 @@ extends GregtechMeta_MultiBlockBase {
return (byte) TAE.GTPP_INDEX(29);
}
- private boolean addToMachineList(final IGregTechTileEntity tTileEntity) {
- return ((this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex())));
+ @Override
+ public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ mCuttingMode = Utils.invertBoolean(mCuttingMode);
+ String aMode = mCuttingMode ? "Cutting" : "Slicing";
+ PlayerUtils.messagePlayer(aPlayer, "Mode: "+aMode);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("mCuttingMode", mCuttingMode);
}
- private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) {
- return ((this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex())));
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ mCuttingMode = aNBT.getBoolean("mCuttingMode");
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java
index aad16d3a56..f6cc06059b 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java
@@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.a
import java.lang.reflect.Method;
+import gregtech.GT_Mod;
import gregtech.api.enums.Dyes;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.TAE;
@@ -25,6 +26,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.FluidStack;
public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_FusionComputer {
@@ -282,5 +284,96 @@ public class GregtechMetaTileEntity_Adv_Fusion_MK4 extends GT_MetaTileEntity_Fus
private boolean isFusionCoil(int aX, int aY, int aZ) {
return (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getFusionCoil() && (getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getFusionCoilMeta()));
}
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ if (aBaseMetaTileEntity.isServerSide()) {
+ if (mEfficiency < 0)
+ mEfficiency = 0;
+ if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) {
+ this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU();
+ checkRecipe(mInventory[1]);
+ }
+ if (--mUpdate == 0 || --mStartUpCheck == 0) {
+ mInputHatches.clear();
+ mInputBusses.clear();
+ mOutputHatches.clear();
+ mOutputBusses.clear();
+ mDynamoHatches.clear();
+ mEnergyHatches.clear();
+ mMufflerHatches.clear();
+ mMaintenanceHatches.clear();
+ mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]);
+ }
+ if (mStartUpCheck < 0) {
+ if (mMachine) {
+ if (this.mEnergyHatches != null) {
+ for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches)
+ if (isValidMetaTileEntity(tHatch)) {
+ long aVoltage = GT_Values.V[tHatch.mTier];
+ if (aBaseMetaTileEntity.getStoredEU() + (aVoltage) < maxEUStore()
+ && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aVoltage, false)) {
+ aBaseMetaTileEntity.increaseStoredEnergyUnits(aVoltage, true);
+ }
+ }
+ }
+ if (this.mEUStore <= 0 && mMaxProgresstime > 0) {
+ stopMachine();
+ }
+ if (getRepairStatus() > 0) {
+ if (mMaxProgresstime > 0) {
+ this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true);
+ if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) {
+ if (mOutputItems != null)
+ for (ItemStack tStack : mOutputItems) if (tStack != null) addOutput(tStack);
+ if (mOutputFluids != null)
+ for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack);
+ mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000)));
+ mOutputItems = null;
+ mProgresstime = 0;
+ mMaxProgresstime = 0;
+ mEfficiencyIncrease = 0;
+ if (mOutputFluids != null && mOutputFluids.length > 0) {
+ try {
+ GT_Mod.instance.achievements.issueAchivementHatchFluid(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), mOutputFluids[0]);
+ } catch (Exception e) {
+ }
+ }
+ this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU();
+ if (aBaseMetaTileEntity.isAllowedToWork())
+ checkRecipe(mInventory[1]);
+ }
+ } else {
+ if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) {
+ turnCasingActive(mMaxProgresstime > 0);
+ if (aBaseMetaTileEntity.isAllowedToWork()) {
+ this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU();
+ if (checkRecipe(mInventory[1])) {
+ if (this.mEUStore < this.mLastRecipe.mSpecialValue) {
+ mMaxProgresstime = 0;
+ turnCasingActive(false);
+ }
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true);
+ }
+ }
+ if (mMaxProgresstime <= 0)
+ mEfficiency = Math.max(0, mEfficiency - 1000);
+ }
+ }
+ } else {
+ this.mLastRecipe = null;
+ stopMachine();
+ }
+ } else {
+ turnCasingActive(false);
+ this.mLastRecipe = null;
+ stopMachine();
+ }
+ }
+ aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8)
+ | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64));
+ aBaseMetaTileEntity.setActive(mMaxProgresstime > 0);
+ }
+ }
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java
index 74047e5ecc..1ceb6bd93f 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java
@@ -16,26 +16,29 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
+import gregtech.api.util.Recipe_GT;
+import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.item.chemistry.AgriculturalChem;
import gtPlusPlus.core.util.minecraft.FluidUtils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler;
import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm;
import ic2.core.init.BlocksItems;
import ic2.core.init.InternalName;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase {
- private int mLevel = -1;
-
public GregtechMTE_FrothFlotationCell(final int aID, final String aName, final String aNameRegional) {
super(aID, aName, aNameRegional);
}
@@ -57,22 +60,7 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
@Override
public String[] getTooltip() {
return new String[] {
- "Grows Algae!",
- "Controller Block for the Algae Farm",
- "Provide compost to boost production by one tier",
- "Size: 9x3x9 [WxHxL] (open)",
- "X X",
- "X X",
- "XXXXXXXXX",
- "Machine Casings (all bottom layer)",
- "Sterile Farm Casings (rest)",
- "Controller (front centered)",
- "All hatches must be on the bottom layer",
- "All hulls must be the same tier, this dictates machine speed",
- "Does not require power or maintenance",
- "1x Output Bus",
- "1x Input Bus (optional)",
- "1x Input Hatch (fill with water)",
+ "Process that milled ore!",
};
}
@@ -84,15 +72,15 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
@Override
public boolean isFacingValid(final byte aFacing) {
- Logger.INFO("Facing: "+aFacing);
- return aFacing == 1;
+ if (aFacing == 0 || aFacing > 1) {
+ return false;
+ }
+ return true;
}
@Override
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
-
int aID = TAE.getIndexFromPage(2, 1);
-
if (aSide == aFacing) {
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[aID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)};
}
@@ -106,12 +94,12 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
@Override
public GT_Recipe.GT_Recipe_Map getRecipeMap() {
- return null;
+ return Recipe_GT.Gregtech_Recipe_Map.sFlotationCellRecipes;
}
@Override
public int getMaxParallelRecipes() {
- return 2;
+ return 1;
}
@Override
@@ -121,187 +109,126 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
@Override
public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) {
-
-
- this.mLevel = 0;
- if (this.mLevel == 0) {
- return false;
+ Block aCasing1 = ModBlocks.blockCasings3Misc;
+ int aCasingMeta1 = 1;
+ Block aCasing2 = ModBlocks.blockSpecialMultiCasings;
+ int aCasingMeta2 = 9;
+ int aCasingCount1 = 0;
+ int aCasingCount2 = 0;
+ int aControllerY = aBaseMetaTileEntity.getYCoord();
+ // Check adjacent blocks
+ for (byte side = 2; side < 6; side++) {
+ Block aBlock = aBaseMetaTileEntity.getBlockAtSide(side);
+ int aMeta = aBaseMetaTileEntity.getMetaIDAtSide(side);
+ if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing1, aCasingMeta1)) {
+ aCasingCount1++;
+ }
+ else {
+ log("Bad block at Y:"+(aControllerY));
+ return false;
+ }
}
+ // Check first layer
+ aControllerY--;
+ for (int x = -2; x < 3; x++) {
+ for (int z = -2; z < 3; z++) {
- // Get Facing direction
- int mCurrentDirectionX;
- int mCurrentDirectionZ;
-
- int mOffsetX_Lower = 0;
- int mOffsetX_Upper = 0;
- int mOffsetZ_Lower = 0;
- int mOffsetZ_Upper = 0;
-
- mCurrentDirectionX = 4;
- mCurrentDirectionZ = 4;
-
- mOffsetX_Lower = -4;
- mOffsetX_Upper = 4;
- mOffsetZ_Lower = -4;
- mOffsetZ_Upper = 4;
-
- final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX
- * mCurrentDirectionX;
- final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ
- * mCurrentDirectionZ;
-
- // Get Expected Tier
-// Block aCasingBlock = aBaseMetaTileEntity.getBlockAtSide((byte) 3);
-// int aCasingMeta = aBaseMetaTileEntity.getMetaIDAtSide((byte) 3);
-//
-// // Bad Casings
-// if ((aCasingBlock != GregTech_API.sBlockCasings1) || aCasingMeta > 9) {
-// Logger.INFO("is false");
-// return false;
-// }
-// else {
- mLevel = this.getCasingTier();
- //}
- int aID = TAE.getIndexFromPage(1, 15);
- int tAmount = 0;
- check : for (int i = mOffsetX_Lower; i <= mOffsetX_Upper; ++i) {
- for (int j = mOffsetZ_Lower; j <= mOffsetZ_Upper; ++j) {
- for (int h = -1; h < 2; ++h) {
- if ((h != 0) || ((((xDir + i != 0) || (zDir + j != 0))) && (((i != 0) || (j != 0))))) {
- IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j);
-
- Logger.INFO("X: " + i + " | Z: " + j+" | Tier: "+aID);
- if (h == -1 && tTileEntity != null && addToMachineList(tTileEntity, aID)) {
- continue;
- }
- else if (h != -1 && tTileEntity != null) {
- Logger.INFO("Found hatch in wrong place, expected casing.");
- return false;
- }
-
- Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
- byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j);
+ int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x;
+ int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z;
- if ((h >= 0) && (tBlock == ModBlocks.blockCasings2Misc) && (tMeta == 15) ) {
- ++tAmount;
- }
- else if ((h == -1) && (tBlock == GregTech_API.sBlockCasings1) && (tMeta == mLevel) ) {
- ++tAmount;
- }
- else if ((h == -1) && (tBlock == GregTech_API.sBlockCasings1) && (tMeta != mLevel) ) {
- Logger.INFO("Found wrong tiered casing.");
- return false;
+ // Don't check air
+ if ((x == -2 && z != 0) || (x == 2 && z != 0) || (z == -2 && x != 0) || (z == 2 && x != 0) || (x == 0 && z == 0)) {
+ continue;
+ }
+ else {
+ Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, aControllerY, aWorldOffsetZ);
+ int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, aControllerY, aWorldOffsetZ);
+ if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing2, aCasingMeta2)) {
+ aCasingCount2++;
+ }
+ else {
+ log("Bad block at Y:"+(aControllerY)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ);
+ aBaseMetaTileEntity.getWorld().setBlock(aWorldOffsetX, aControllerY, aWorldOffsetZ, Blocks.bookshelf);
+ return false;
+ }
+ }
+ }
+ }
+ // Check circular tower
+ aControllerY--;
+ for (int y = aControllerY; y > (aControllerY-5); y--) {
+ for (int x = -2; x < 3; x++) {
+ for (int z = -2; z < 3; z++) {
+
+ int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x;
+ int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z;
+
+ // Don't check air
+ if ((x == -2 && z != 0) || (x == 2 && z != 0) || (z == -2 && x != 0) || (z == 2 && x != 0) || (x == 0 && z == 0)) {
+ continue;
+ }
+ // Don't check air
+ else if ((x == -1 && z == 0) || (x == 1 && z == 0) || (z == -1 && x == 0) || (z == 1 && x == 0) || (x == 0 && z == 0)) {
+ continue;
+ }
+ else {
+ Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, y, aWorldOffsetZ);
+ int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, y, aWorldOffsetZ);
+ if (this.isValidBlockForStructure(null, 0, false, aBlock, aMeta, aCasing2, aCasingMeta2)) {
+ aCasingCount2++;
}
else {
- if ((i != mOffsetX_Lower && j != mOffsetZ_Lower && i != mOffsetX_Upper
- && j != mOffsetZ_Upper) && (h == 0 || h == 1)) {
- continue;
- } else {
- if (tBlock.getLocalizedName().contains("gt.blockmachines") || tBlock == Blocks.water
- || tBlock == Blocks.flowing_water
- || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) {
- continue;
-
- } else {
- Logger.INFO("[x] Did not form - Found: " + tBlock.getLocalizedName() + " | "
- + tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(),
- aBaseMetaTileEntity.getXCoord() + i,
- aBaseMetaTileEntity.getYCoord(),
- aBaseMetaTileEntity.getZCoord() + j)
- + " | Special Meta: "
- + (tTileEntity == null ? "0" : tTileEntity.getMetaTileID()));
- Logger.INFO("[x] Did not form - Found: "
- + (aBaseMetaTileEntity.getXCoord() + xDir + i) + " | "
- + aBaseMetaTileEntity.getYCoord() + " | "
- + (aBaseMetaTileEntity.getZCoord() + zDir + j));
- break check;
- }
- }
-
+ log("Bad block at Y:"+(y)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ);
+ return false;
}
-
- }
- }
+ }
+ }
}
}
- if ((tAmount >= 64)) {
- Logger.INFO("Made structure.");
- this.getBaseMetaTileEntity().getWorld().markBlockForUpdate(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord());
- } else {
- Logger.INFO("Did not make structure.");
- }
- return (tAmount >= 64);
- }
-
- public boolean checkForWater() {
-
- // Get Facing direction
- IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity();
- int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
- int mCurrentDirectionX;
- int mCurrentDirectionZ;
- int mOffsetX_Lower = 0;
- int mOffsetX_Upper = 0;
- int mOffsetZ_Lower = 0;
- int mOffsetZ_Upper = 0;
-
- mCurrentDirectionX = 4;
- mCurrentDirectionZ = 4;
-
- mOffsetX_Lower = -4;
- mOffsetX_Upper = 4;
- mOffsetZ_Lower = -4;
- mOffsetZ_Upper = 4;
-
- // if (aBaseMetaTileEntity.fac)
-
- final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX
- * mCurrentDirectionX;
- final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ
- * mCurrentDirectionZ;
-
- int tAmount = 0;
- for (int i = mOffsetX_Lower + 1; i <= mOffsetX_Upper - 1; ++i) {
- for (int j = mOffsetZ_Lower + 1; j <= mOffsetZ_Upper - 1; ++j) {
- for (int h = 0; h < 2; h++) {
- Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
- // byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j);
- if (tBlock == Blocks.air || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) {
- if (this.getStoredFluids() != null) {
- for (FluidStack stored : this.getStoredFluids()) {
- if (stored.isFluidEqual(FluidUtils.getFluidStack("water", 1))) {
- if (stored.amount >= 1000) {
- // Utils.LOG_WARNING("Going to try swap an air block for water from inut bus.");
- stored.amount -= 1000;
- Block fluidUsed = Blocks.water;
- aBaseMetaTileEntity.getWorld().setBlock(
- aBaseMetaTileEntity.getXCoord() + xDir + i,
- aBaseMetaTileEntity.getYCoord() + h,
- aBaseMetaTileEntity.getZCoord() + zDir + j, fluidUsed);
-
- }
- }
+ // Check Base
+ aControllerY -= 5;
+ for (int y = aControllerY; y > (aControllerY-2); y--) {
+ for (int x = -3; x < 4; x++) {
+ for (int z = -3; z < 4; z++) {
+ int aWorldOffsetX = aBaseMetaTileEntity.getXCoord() + x;
+ int aWorldOffsetZ = aBaseMetaTileEntity.getZCoord() + z;
+ if ((x == -3 && z == -3) || (x == 3 && z == 3) || (x == -3 && z == 3) || (x == 3 && z == -3)) {
+ continue;
+ }
+ else if ((x == -3 && z == -2) || (x == -2 && z == -3) || (x == 3 && z == 2) || (x == 2 && z == 3)) {
+ continue;
+ }
+ else if ((x == -2 && z == 3) || (x == -3 && z == 2) || (x == 3 && z == -2) || (x == 2 && z == -3)) {
+ continue;
+ }
+ else {
+ Block aBlock = aBaseMetaTileEntity.getBlock(aWorldOffsetX, y, aWorldOffsetZ);
+ int aMeta = aBaseMetaTileEntity.getMetaID(aWorldOffsetX, y, aWorldOffsetZ);
+ IGregTechTileEntity aTile = aBaseMetaTileEntity.getIGregTechTileEntity(aWorldOffsetX, y, aWorldOffsetZ);
+ if (this.isValidBlockForStructure(aTile, TAE.getIndexFromPage(2, 1), true, aBlock, aMeta, aCasing1, aCasingMeta1)) {
+ if (aTile == null) {
+ aCasingCount1++;
}
}
- }
- tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j);
- if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) {
- ++tAmount;
- // Logger.INFO("Found Water");
- }
- }
+ else {
+ log("Bad block at Y:"+(y)+", X:"+aWorldOffsetX+", Z:"+aWorldOffsetZ);
+ return false;
+ }
+ }
+ }
}
}
-
- boolean isValidWater = tAmount >= 60;
-
- if (isValidWater) {
- Logger.INFO("Filled structure.");
- return true;
- }
- else {
+ if (aCasingCount1 < 68) {
+ log("Inconel Casings found: "+aCasingCount1);
+ log("Inconel Casings required: 68");
return false;
}
+ if (aCasingCount2 < 52) {
+ log("Flotation Casings found: "+aCasingCount2);
+ log("Flotation Casings required: 52");
+ return false;
+ }
+ return true;
}
@Override
@@ -336,34 +263,24 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
@Override
public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
- super.onPreTick(aBaseMetaTileEntity, aTick);
- this.fixAllMaintenanceIssue();
- // Silly Client Syncing
- if (aBaseMetaTileEntity.isClientSide()) {
- this.mLevel = getCasingTier();
+ super.onPreTick(aBaseMetaTileEntity, aTick);
+ // Fix GT bug
+ if (this.getBaseMetaTileEntity().getFrontFacing() == 0 && this.getBaseMetaTileEntity().getBackFacing() == 1) {
+ log("Fixing Bad Facing. (GT Bug)");
+ this.getBaseMetaTileEntity().setFrontFacing((byte) 1);
}
-
}
@Override
- public boolean checkRecipe(final ItemStack aStack) {
- return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0);
+ public boolean checkRecipe(ItemStack arg0) {
+ return super.checkRecipeGeneric();
}
-
+
public boolean checkRecipeGeneric(
ItemStack[] aItemInputs, FluidStack[] aFluidInputs,
int aMaxParallelRecipes, int aEUPercent,
int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) {
-
- if (this.mLevel < 0) {
- Logger.INFO("Bad Tier.");
- return false;
- }
-
- if (!checkForWater()) {
- Logger.INFO("Not enough Water.");
- return false;
- }
+ // Based on the Processing Array. A bit overkill, but very flexible.
// Reset outputs and progress stats
this.mEUt = 0;
@@ -371,35 +288,111 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
this.mOutputItems = new ItemStack[]{};
this.mOutputFluids = new FluidStack[]{};
- Logger.INFO("Running checkRecipeGeneric(0)");
-
- GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs));
-
+ long tVoltage = getMaxInputVoltage();
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ long tEnergy = getMaxInputEnergy();
+ log("Running checkRecipeGeneric(0)");
+
+ GT_Recipe tRecipe = findRecipe(
+ getBaseMetaTileEntity(), mLastRecipe, false,
+ gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);
+
+ log("Running checkRecipeGeneric(1)");
+ // Remember last recipe - an optimization for findRecipe()
this.mLastRecipe = tRecipe;
if (tRecipe == null) {
+ log("BAD RETURN - 1");
return false;
}
-
+
+ /*
+ *
+ * Material Hash checks
+ * Makes sure we can only ever use one type of material in this flotation cell.
+ *
+ */
+ int aExpectedMaterialHash;
+ // Set the hash of expected material type
+ if (mLockedOreType == -1) {
+ mLockedOreType = FlotationRecipeHandler.getHashForMaterial(FlotationRecipeHandler.getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(aRecipe)));
+ }
+ // Set the hash for this recipe check
+ aExpectedMaterialHash = mLockedOreType;
+
+ // Compute hash of current inputs
+ int aFoundMaterialHash = FlotationRecipeHandler.getHashForMaterial(FlotationRecipeHandler.getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(aItemInputs)));
+
+ // Check hashes match
+ if (aExpectedMaterialHash != aFoundMaterialHash) {
+ log("Did not find the correct milled type.");
+ log("Found: "+aFoundMaterialHash);
+ log("Expected: "+mLockedOreType);
+ return false;
+ }
+
aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes);
if (aMaxParallelRecipes == 0) {
+ log("BAD RETURN - 2");
return false;
}
- if (tRecipe.mInputs.length > 0) {
- for (ItemStack aInputToConsume : tRecipe.mInputs) {
- this.depleteInput(aInputToConsume);
+
+ // EU discount
+ float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f;
+ float tTotalEUt = 0.0f;
+
+ int parallelRecipes = 0;
+
+ 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 < (tEnergy - tRecipeEUt); parallelRecipes++) {
+ if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) {
+ log("Broke at "+parallelRecipes+".");
+ break;
}
+ log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+".");
+ tTotalEUt += tRecipeEUt;
}
+ if (parallelRecipes == 0) {
+ log("BAD RETURN - 3");
+ return false;
+ }
// -- Try not to fail after this point - inputs have already been consumed! --
- this.mMaxProgresstime = (int)(tRecipe.mDuration);
- this.mEUt = 0;
+
+ // Convert speed bonus to duration multiplier
+ // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration.
+ aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent);
+ float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent);
+ this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor);
+
+ this.mEUt = (int)Math.ceil(tTotalEUt);
+
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
- this.mEfficiencyIncrease = 10000;
- Logger.INFO("Recipe time: "+this.mMaxProgresstime);
+ this.mEfficiencyIncrease = 10000;
+
+ // Overclock
+ if (this.mEUt <= 16) {
+ this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1));
+ this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1));
+ } else {
+ while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
+ this.mEUt *= 4;
+ this.mMaxProgresstime /= 2;
+ }
+ }
+
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
+ }
+
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
// Collect fluid outputs
@@ -407,7 +400,7 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) {
if (tRecipe.getFluidOutput(h) != null) {
tOutputFluids[h] = tRecipe.getFluidOutput(h).copy();
- tOutputFluids[h].amount *= aMaxParallelRecipes;
+ tOutputFluids[h].amount *= parallelRecipes;
}
}
@@ -423,7 +416,7 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
// Set output item stack sizes (taking output chance into account)
for (int f = 0; f < tOutputItems.length; f++) {
if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) {
- for (int g = 0; g < aMaxParallelRecipes; g++) {
+ for (int g = 0; g < parallelRecipes; g++) {
if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f))
tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize;
}
@@ -464,50 +457,36 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase
// Play sounds (GT++ addition - GT multiblocks play no sounds)
startProcess();
- Logger.INFO("GOOD RETURN - 1");
+ log("GOOD RETURN - 1");
return true;
-
}
+
+ /*
+ * Handle NBT
+ */
- private boolean isUsingCompost(ItemStack[] aItemInputs) {
- ItemStack aCompost = ItemUtils.getSimpleStack(AgriculturalChem.mCompost, 1);
- for (ItemStack i : aItemInputs) {
- if (GT_Utility.areStacksEqual(aCompost, i)) {
- if (i.stackSize >= 8) {
- return true;
- }
- else {
- continue;
- }
- }
+ private int mLockedOreType = -1;
+
+ @Override
+ public void setItemNBT(NBTTagCompound aNBT) {
+ if (mLockedOreType != -1) {
+ aNBT.setInteger("mLockedOreType", mLockedOreType);
}
- return false;
+ super.setItemNBT(aNBT);
}
-
- private final int getCasingTier() {
- if (this == null || this.getBaseMetaTileEntity().getWorld() == null) {
- return 0;
- }
- try {
- Block aInitStructureCheck;
- int aInitStructureCheckMeta;
- IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity();
- int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
- int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
- aInitStructureCheck = aBaseMetaTileEntity.getBlockOffset(xDir, -1, zDir);
- aInitStructureCheckMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, zDir);
- if (aInitStructureCheck == GregTech_API.sBlockCasings1) {
- return aInitStructureCheckMeta;
- }
- return 0;
- }
- catch (Throwable t) {
- t.printStackTrace();
- return 0;
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ if (mLockedOreType != -1) {
+ aNBT.setInteger("mLockedOreType", mLockedOreType);
}
}
-
-
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ mLockedOreType = aNBT.getInteger("mLockedOreType");
+ }
+
}