aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2022-01-06 11:18:05 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2022-01-06 11:18:05 +0000
commit7c02ac0977ee37dda637d21d7d1092835b1d03eb (patch)
tree0e309268d0ffdd56cb1e72dae70dc2c92c887b09 /src
parent1ffbfdf48d9c23712932f6d25f1bc1529202412e (diff)
downloadGT5-Unofficial-7c02ac0977ee37dda637d21d7d1092835b1d03eb.tar.gz
GT5-Unofficial-7c02ac0977ee37dda637d21d7d1092835b1d03eb.tar.bz2
GT5-Unofficial-7c02ac0977ee37dda637d21d7d1092835b1d03eb.zip
Added Asm, Screenshots and World to .gitignore.
Removed some useless classes. Buffed Amazon Packager. Implemented Caching for Amazon Packager. Fixed all GT++ multis getting stuck when input bus contains less than required input of an item. (It will check other inputs for another valid recipe now)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java17
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockBlueprint.java469
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java643
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java108
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java87
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java137
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java11
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java376
8 files changed, 340 insertions, 1508 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
index 42fdc246b4..c8b58ff097 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java
@@ -40,7 +40,6 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEn
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBattery;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBattery;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Steam_BusInput;
-import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -94,7 +93,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En
private static final Method findRecipe09;
public GT_Recipe mLastRecipe;
- private MultiblockRequirements mRequirements;
private boolean mInternalCircuit = false;
protected long mTotalRunTime = 0;
protected boolean mVoidExcess = false;
@@ -355,17 +353,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En
public final static String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION";
public final static String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE";
- public synchronized final MultiblockRequirements getRequirements() {
- return mRequirements;
- }
-
- //public abstract MultiblockRequirements setRequirements();
-
- public synchronized final void setRequirementsInternal() {
- //this.mRequirements = setRequirements();
- this.mRequirements = null;
- }
-
public int getAmountOfOutputs() {
return 1;
}
@@ -970,7 +957,7 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En
log("Running checkRecipeGeneric(0)");
GT_Recipe tRecipe = findRecipe(
- getBaseMetaTileEntity(), mLastRecipe, false,
+ getBaseMetaTileEntity(), mLastRecipe, false, false,
gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);
log("Running checkRecipeGeneric(1)");
@@ -1323,7 +1310,7 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_En
//Bad modify, let's just use the original recipe.
if (!mHasBoostedCurrentRecipe || mBoostedRecipe == null) {
tRecipe = aRecipe != null ? aRecipe : findRecipe(
- getBaseMetaTileEntity(), mLastRecipe, false,
+ getBaseMetaTileEntity(), mLastRecipe, false, false,
gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockBlueprint.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockBlueprint.java
deleted file mode 100644
index 7af6af2ffd..0000000000
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockBlueprint.java
+++ /dev/null
@@ -1,469 +0,0 @@
-package gtPlusPlus.xmod.gregtech.api.objects;
-
-import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.api.objects.data.Pair;
-import gtPlusPlus.api.objects.data.Triplet;
-import gtPlusPlus.api.objects.minecraft.BlockPos;
-import gtPlusPlus.xmod.gregtech.api.objects.MultiblockLayer.LayerBlockData;
-import net.minecraft.block.Block;
-import net.minecraft.init.Blocks;
-import net.minecraftforge.common.util.ForgeDirection;
-
-public abstract class MultiblockBlueprint {
-
- private final MultiblockLayer[] mBlueprintData;
-
- public final int height;
- public final int width;
- public final int depth;
- public final int mMinimumCasingCount;
- public final int mTextureID;
-
- /**
- * Cached Matrix of the Multiblock, which makes future structural checks far quicker.
- */
- private final BlockPos[][][] StructureMatrix;
-
- /**
- * Has {@value StructureMatrix} been set yet?
- */
- @SuppressWarnings("unused")
- private boolean mGeneratedMatrix = false;
-
- /**
- * A detailed class which will contain blueprints for a Multiblock.
- * Values are not relative to the controller, but in total.
- * @param x - Overall width
- * @param y - Overall height
- * @param z - Overall depth
- * @param aMinimumCasings - The lowest amount of casings required
- * @param aTextureID - The texture ID used by hatches.
- */
- public MultiblockBlueprint(final int x, final int y, final int z, final int aMinimumCasings, final int aTextureID) {
- mBlueprintData = new MultiblockLayer[y];
- height = y;
- width = x;
- depth = z;
- mMinimumCasingCount = aMinimumCasings;
- mTextureID = aTextureID;
- StructureMatrix = new BlockPos[width][height][depth];
- //Logger.INFO("Created new Blueprint.");
- }
-
- /**
- *
- * @param aY - The Y level of the layer to return, where 0 is the bottom and N is the top.
- * @return - A {@link MultiblockLayer} object.
- */
- public MultiblockLayer getLayer(int aY) {
- return mBlueprintData[aY];
- }
-
- /**
- *
- * @param aLayer - A {@link MultiblockLayer} object.
- * @param aY - The Y level of the layer, where 0 is the bottom and N is the top.
- *
- */
- public void setLayer(MultiblockLayer aLayer, int aY) {
- mBlueprintData[aY] = aLayer;
- }
-
- public MultiblockLayer getControllerLayer() {
- for (MultiblockLayer u : mBlueprintData) {
- if (u.hasController()) {
- return u;
- }
- }
- return null;
- }
-
- public int getControllerY() {
- int i = 0;
- for (MultiblockLayer u : mBlueprintData) {
- if (u.hasController()) {
- return i;
- }
- i++;
- }
- return 0;
- }
-
- @SuppressWarnings({ "unused", "rawtypes" })
- public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity) {
- //Check for Nulls
- if (aBaseMetaTileEntity == null) {
- return false;
- }
- final IMetaTileEntity aMetaTileEntity = aBaseMetaTileEntity.getMetaTileEntity();
- if (aMetaTileEntity == null) {
- return false;
- }
- GT_MetaTileEntity_MultiBlockBase aControllerObject = null;
- if (aMetaTileEntity instanceof GT_MetaTileEntity_MultiBlockBase) {
- aControllerObject = (GT_MetaTileEntity_MultiBlockBase) aMetaTileEntity;
- }
- if (aControllerObject == null) {
- return false;
- }
-
- //Get some Vars
- int xOffSetMulti = ((this.getControllerLayer().width-1)/2);
- int zOffSetMulti = ((this.getControllerLayer().depth-1)/2);
- final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * xOffSetMulti;
- final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * zOffSetMulti;
- ForgeDirection aDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing());
- int tAmount = 0;
-
- int contX = aControllerObject.getBaseMetaTileEntity().getXCoord(), contY = aControllerObject.getBaseMetaTileEntity().getYCoord(), contZ = aControllerObject.getBaseMetaTileEntity().getZCoord();
-
- Logger.INFO("Controller is located at ["+contX+", "+contY+", "+contZ+"]");
-
- boolean debugCacheDataVisually = true;
-
-
- if (/*!mGeneratedMatrix || StructureMatrix == null*/ true) {
- //Try Fancy Cache Stuff
- BlockPos aPos = getOffsetRelativeToGridPosition(aBaseMetaTileEntity, 0, 0, 0);
- for (int Y = 0; Y < height; Y++) {
- for (int Z = 0; Z < depth; Z++) {
- for (int X = 0; X < width; X++) {
- int offsetX, offsetZ;
- Pair<Integer, Integer> j = MultiblockLayer.rotateOffsetValues(aDir, X, Z);
- offsetX = j.getKey();
- offsetZ = j.getValue();
-
- Logger.INFO("Pre-Rotated Offsets ["+X+", "+(aPos.yPos + Y)+", "+Z+"] | "+aDir.name());
- Logger.INFO("Rotated Offsets ["+offsetX+", "+(aPos.yPos + Y)+", "+offsetZ+"]");
-
- // Resolve Negatives
- int negTestX, negTestZ;
- if (aPos.xPos < 0) {
- int testA = aPos.xPos;
- testA -= -offsetX;
- negTestX = testA;
- } else {
- negTestX = offsetX + aPos.xPos;
- }
- if (aPos.zPos < 0) {
- int testA = aPos.zPos;
- testA -= -offsetZ;
- negTestZ = testA;
- } else {
- negTestZ = offsetZ + aPos.zPos;
- }
- Logger.INFO("Caching With Offset ["+negTestX+", "+(aPos.yPos + Y)+", "+negTestZ+"]");
- StructureMatrix[X][Y][Z] = new BlockPos(negTestX, (aPos.yPos + Y), negTestZ, aPos.world);
-
- if (debugCacheDataVisually) {
- aBaseMetaTileEntity.getWorld().setBlock(negTestX, (aPos.yPos + Y), negTestZ, Blocks.glass);
- }
- }
- }
- }
- Logger.INFO("Cached blueprint matrix.");
- mGeneratedMatrix = true;
- }
- else {
- Logger.INFO("Found cached blueprint matrix.");
- }
-
- if (StructureMatrix == null) {
- Logger.INFO("Error caching blueprint matrix.");
- return false;
- }
-
-
- int a1, a2, a3;
- a1 = StructureMatrix.length;
- a2 = StructureMatrix[0].length;
- a3 = StructureMatrix[0][0].length;
-
- Logger.INFO("Matrix Size ["+a1+", "+a2+", "+a3+"]");
-
- for (int H = 0; H < a2; H++) {
-
- MultiblockLayer currentLayer = this.getLayer(H);
- for (int W = 0; W < a1; W++) {
- for (int D = 0; D < a3; D++) {
-
- BlockPos aToCheck = StructureMatrix[W][H][D];
- if (aToCheck == null) {
- Logger.INFO("Found bad data stored at X: "+W+", Y: "+H+", Z: "+D);
- continue;
- }
- else {
- //Logger.INFO("Found data stored at X: "+W+", Y: "+H+", Z: "+D);
- Logger.INFO("Checking "+aToCheck.getLocationString());
- }
-
- final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntity(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos);
- final Block tBlock = aBaseMetaTileEntity.getBlock(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos);
- final int tMeta = aBaseMetaTileEntity.getMetaID(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos);
-
-
- LayerBlockData g1 = currentLayer.getDataFromCoordsWithDirection(aDir, W, D);
- if (g1 == null) {
- Logger.INFO("Failed to find LayerBlockData. Using AIR_FALLBACK");
- //return false;*/
- g1 = LayerBlockData.FALLBACK_AIR_CHECK;
- }
- else {
- if (g1.isController) {
- Logger.INFO("Controller is at X: "+W+", Y: "+H+", Z: "+D);
- }
- }
-
- boolean isMatch = g1.match(tBlock, tMeta);
-
-
- if (!isMatch) {
- Logger.INFO("Checking ["+aToCheck.xPos+", "+ aToCheck.yPos +", "+ aToCheck.zPos+"]");
- Logger.INFO("Checking Position relative to Grid. X: "+W+", Y: "+H+", Z: "+D);
- Logger.INFO("Found "+tBlock.getLocalizedName()+" : "+tMeta + " | Bad ["+W+", "+D+"]");
-
- LayerBlockData g = currentLayer.getDataFromCoordsWithDirection(aDir, W, D);
-
- if (g == null) {
- Logger.INFO("Expected "+" BAD DATA - Possibly Unset Area in Blueprint.");
-
- }
- else {
- Logger.INFO("Expected "+g.mBlock.getLocalizedName()+" : "+g.mMeta + "");
- }
- aBaseMetaTileEntity.getWorld().setBlock(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos, g.mBlock);
- aBaseMetaTileEntity.getWorld().setBlockMetadataWithNotify(aToCheck.xPos, aToCheck.yPos, aToCheck.zPos, g.mMeta, 4);
- //return false;
- }
- else {
-
- LayerBlockData g = currentLayer.getDataFromCoordsWithDirection(aDir, W, D);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- boolean isHatchValidType = false;
- if (g != null) {
- if (g.canBeHatch && !g.isController && tTileEntity != null) {
- IMetaTileEntity aMetaTileEntity2 = tTileEntity.getMetaTileEntity();
- if (aMetaTileEntity2 != null) {
- if (aMetaTileEntity2 instanceof GT_MetaTileEntity_MultiBlockBase) {
- isHatchValidType = true;
- break;
- }
- else {
- for (Class c : g.mHatchClass) {
- if (c != null) {
- if (c.isInstance(aMetaTileEntity2)) {
- isHatchValidType = true;
- break;
- }
- }
- }
- }
- }
- }
- }
-
- if (!isHatchValidType && !g.isController && tTileEntity != null) {
- Logger.INFO("Checking ["+aToCheck.xPos+", "+ aToCheck.yPos +", "+ aToCheck.zPos+"]");
- Logger.INFO("Hatch Type did not match allowed types. "+tTileEntity.getClass().getSimpleName());
- return false;
- }
- if (!aControllerObject.addToMachineList(tTileEntity, mTextureID)) {
- tAmount++;
- }
-
-
- }
- }
- }
- }
-
- boolean hasCorrectHatches = (
- aControllerObject.mInputBusses.size() >= this.getMinimumInputBus() &&
- aControllerObject.mOutputBusses.size() >= this.getMinimumOutputBus() &&
- aControllerObject.mInputHatches.size() >= this.getMinimumInputHatch() &&
- aControllerObject.mOutputHatches.size() >= this.getMinimumOutputHatch() &&
- aControllerObject.mDynamoHatches.size() >= this.getMinimumOutputEnergy() &&
- aControllerObject.mEnergyHatches.size() >= this.getMinimumInputEnergy() &&
- aControllerObject.mMaintenanceHatches.size() >= this.getMinimumMaintHatch() &&
- aControllerObject.mMufflerHatches.size() >= this.getMinimumMufflers());
-
-
- Logger.INFO("mInputBusses: "+aControllerObject.mInputBusses.size());
- Logger.INFO("mOutputBusses: "+aControllerObject.mOutputBusses.size());
- Logger.INFO("mInputHatches: "+aControllerObject.mInputHatches.size());
- Logger.INFO("mOutputHatches: "+aControllerObject.mOutputHatches.size());
- Logger.INFO("mEnergyHatches: "+aControllerObject.mEnergyHatches.size());
- Logger.INFO("mDynamoHatches: "+aControllerObject.mDynamoHatches.size());
- Logger.INFO("mMaintenanceHatches: "+aControllerObject.mMaintenanceHatches.size());
- Logger.INFO("mMufflerHatches: "+aControllerObject.mMufflerHatches.size());
-
- boolean built = hasCorrectHatches && tAmount >= mMinimumCasingCount;
- Logger.INFO("Built? "+built);
- Logger.INFO("hasCorrectHatches? "+hasCorrectHatches);
- Logger.INFO("tAmount? "+tAmount);
- return built;
- }
-
- public BlockPos getOffsetRelativeToGridPosition(final IGregTechTileEntity aBaseMetaTileEntity, final int x, final int y, final int z) {
-
- if (aBaseMetaTileEntity == null) {
- return null;
- }
-
- int controllerX, controllerY, controllerZ;
- MultiblockLayer layerController = this.getControllerLayer();
-
- if (layerController == null) {
- return null;
- }
-
- int controllerYRelative = this.getControllerY();
- Pair<Integer, Integer> controllerLocationRelativeToGrid = layerController.getControllerLocation();
-
- if (controllerLocationRelativeToGrid == null) {
- return null;
- }
-
- controllerX = aBaseMetaTileEntity.getXCoord();
- controllerY = aBaseMetaTileEntity.getYCoord();
- controllerZ = aBaseMetaTileEntity.getZCoord();
-
- Logger.INFO("Controller is at ["+controllerX+", "+controllerY+", "+controllerZ+"]");
-
- ForgeDirection aDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing());
- Logger.INFO("Controller is facing "+aDir.name());
-
- //Find Bottom Left corner of Structure
- // 0, 0, 0
-
- int offsetX, offsetY, offsetZ;
- int X = controllerLocationRelativeToGrid.getKey(), Z = controllerLocationRelativeToGrid.getValue();
- Logger.INFO("Attempting to translate offsets ["+X+", "+Z+"]");
- if (aDir == ForgeDirection.NORTH) {
- offsetX = -X;
- offsetZ = -Z;
- }
-
- else if (aDir == ForgeDirection.EAST) {
- offsetX = Z;
- offsetZ = -X;
- }
-
- else if (aDir == ForgeDirection.SOUTH) {
- offsetX = X;
- offsetZ = Z;
- }
-
- else if (aDir == ForgeDirection.WEST) {
- offsetX = -Z;
- offsetZ = X;
- }
- else {
- offsetX = -X;
- offsetZ = -Z;
- }
-
- offsetY = -controllerYRelative;
-
- Logger.INFO("Attempting to use offsets ["+offsetX+", "+offsetY+", "+offsetZ+"]");
-
- //Resolve Negatives
- int negTestX, negTestZ;
- if (controllerX < 0) {
- Logger.INFO("Found Negative X Pos.");
- int testA = controllerX;
- testA -= offsetX;
- Logger.INFO("Adding Inverted Offset of "+offsetX+", making "+testA);
- negTestX = testA;
- }
- else {
- negTestX = offsetX + controllerX;
- }
- if (controllerZ < 0) {
- Logger.INFO("Found Negative Z Pos.");
- int testA = controllerZ;
- testA -= -offsetZ;
- Logger.INFO("Adding Inverted Offset of "+offsetZ+", making "+testA);
- negTestZ = testA;
- }
- else {
- negTestZ = offsetZ + controllerZ;
- }
-
-
- //}
- //Bottom left Corner position
- BlockPos p = new BlockPos(negTestX, offsetY+controllerY, negTestZ, aBaseMetaTileEntity.getWorld());
-
- Logger.INFO("World XYZ for Bottom left Corner Block of structure ["+p.xPos+", "+p.yPos+", "+p.zPos+"]");
-
- //Add the xyz relative to the grid.
- BlockPos offsetPos = new BlockPos(p.xPos+x, p.yPos+y, p.zPos+z, aBaseMetaTileEntity.getWorld());
- Logger.INFO("World XYZ for Target Check Block in structure ["+offsetPos.xPos+", "+offsetPos.yPos+", "+offsetPos.zPos+"]");
-
- return p;
- }
-
-
- public IGregTechTileEntity getTileAtOffset(final IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z){
- BlockPos aPos = getOffsetRelativeToGridPosition(aBaseMetaTileEntity, x, y, z);
- final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(aPos.xPos, aPos.yPos, aPos.zPos);
- //aBaseMetaTileEntity.getWorld().setBlock(xh, yh, zh, Blocks.gold_ore);
- return tTileEntity;
- }
-
- public Pair<Block, Integer> getBlockAtOffset(final IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z){
- BlockPos aPos = getOffsetRelativeToGridPosition(aBaseMetaTileEntity, x, y, z);
- final Block tBlock = aBaseMetaTileEntity.getBlockOffset(aPos.xPos, aPos.yPos, aPos.zPos);
- final int tMeta = aBaseMetaTileEntity.getMetaIDOffset(aPos.xPos, aPos.yPos, aPos.zPos);
- return new Pair<Block, Integer>(tBlock, tMeta);
- }
-
- public Triplet<Integer, Integer, Integer> getOffsetFromControllerTo00(){
- MultiblockLayer l = this.getControllerLayer();
- if (l == null) {
- return null;
- }
- int yOffset = this.getControllerY();
- Pair<Integer, Integer> cl = l.getControllerLocation();
-
- if (cl == null) {
- return null;
- }
-
- return new Triplet<Integer, Integer, Integer> (cl.getKey(), yOffset, cl.getValue());
- //return new Triplet<Integer, Integer, Integer> (cl.getKey(), yOffset, cl.getValue());
-
- }
-
- public abstract int getMinimumInputBus();
- public abstract int getMinimumInputHatch();
- public abstract int getMinimumOutputBus();
- public abstract int getMinimumOutputHatch();
- public abstract int getMinimumInputEnergy();
- public abstract int getMinimumOutputEnergy();
- public abstract int getMinimumMaintHatch();
- public abstract int getMinimumMufflers();
-
-}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java
deleted file mode 100644
index c5554a6679..0000000000
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java
+++ /dev/null
@@ -1,643 +0,0 @@
-package gtPlusPlus.xmod.gregtech.api.objects;
-
-import java.util.HashMap;
-
-import gregtech.api.GregTech_API;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
-import gtPlusPlus.api.objects.Logger;
-import gtPlusPlus.api.objects.data.AutoMap;
-import gtPlusPlus.api.objects.data.Pair;
-import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.reflect.ReflectionUtils;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockAir;
-import net.minecraft.init.Blocks;
-import net.minecraftforge.common.util.ForgeDirection;
-
-public class MultiblockLayer {
-
- public final int width;
- public final int depth;
-
- private boolean mFinalised;
-
-
- /**
- * WARNING!! May be {@link null}.
- */
- private Pair<Integer, Integer> mControllerLocation;
-
- /**
- * Holds the North facing Orientation data.
- */
- public final LayerBlockData[][] mLayerData;
- public final AutoMap<LayerBlockData[][]> mVariantOrientations = new AutoMap<LayerBlockData[][]>();
-
- /**
- * A detailed class which will contain a single x/z Layer for a {@link MultiblockBlueprint}.
- * Values are not relative, but in total.
- * @param x - Overall width
- * @param z - Overall depth
- */
- public MultiblockLayer(final int x, final int z) {
- width = x;
- depth = z;
- mLayerData = new LayerBlockData[x][z];
- //Logger.INFO("Created new Blueprint Layer.");
- }
-
- /**
- * A detailed class which will contain a single x/z Layer for a {@link MultiblockBlueprint}.
- * Values are not relative, but in total.
- */
- public MultiblockLayer(final LayerBlockData[][] aData) {
- width = aData.length;
- depth = aData[0].length;
- mLayerData = aData;
- }
-
- /**
- *
- * @param aBlock - The block expected as this location.
- * @param aMeta - The meta for the block above.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @param canBeHatch - is this location able to be substituted for any hatch?
- * @return - Is this data added to the layer data map?
- */
- public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch) {
- return addBlockForPos(aBlock, aMeta, x, z, canBeHatch, new Class[] {});
- }
-
- /**
- *
- * @param aBlock - The block expected as this location.
- * @param aMeta - The meta for the block above.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @param canBeHatch - is this location able to be substituted for a hatch?
- * @param aHatchTypeClass - Specify the class for the hatch if you want it explicit. Use base classes to allow custom hatches which extend.
- * @return - Is this data added to the layer data map?
- */
- public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch, Class aHatchTypeClass) {
- return addBlockForPos(aBlock, aMeta, x, z, canBeHatch, new Class[] {aHatchTypeClass});
- }
-
- /**
- *
- * @param aBlock - The block expected as this location.
- * @param aMeta - The meta for the block above.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @param canBeHatch - is this location able to be substituted for a hatch?
- * @param aHatchTypeClass - Specify the class for the hatch if you want it explicit. Use base classes to allow custom hatches which extend.
- * @return - Is this data added to the layer data map?
- */
- public boolean addBlockForPos(Block aBlock, int aMeta, int x, int z, boolean canBeHatch, Class[] aHatchTypeClass) {
- if (x > width -1) {
- return false;
- }
- if (z > depth - 1) {
- return false;
- }
-
- if (canBeHatch && (aHatchTypeClass == null || aHatchTypeClass.length <= 0)){
-
- if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) {
- aHatchTypeClass = new Class[] {
- GT_MetaTileEntity_Hatch_Dynamo.class,
- GT_MetaTileEntity_Hatch_Energy.class,
- GT_MetaTileEntity_Hatch_Input.class,
- GT_MetaTileEntity_Hatch_InputBus.class,
- GT_MetaTileEntity_Hatch_Maintenance.class,
- GT_MetaTileEntity_Hatch_Muffler.class,
- GT_MetaTileEntity_Hatch_Output.class,
- GT_MetaTileEntity_Hatch_OutputBus.class,
- GT_MetaTileEntity_Hatch.class
- };
- }
- else {
- Class aDataHatch = ReflectionUtils.getClass("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess");
- if (aDataHatch != null) {
- aHatchTypeClass = new Class[] {
- aDataHatch,
- GT_MetaTileEntity_Hatch_Dynamo.class,
- GT_MetaTileEntity_Hatch_Energy.class,
- GT_MetaTileEntity_Hatch_Input.class,
- GT_MetaTileEntity_Hatch_InputBus.class,
- GT_MetaTileEntity_Hatch_Maintenance.class,
- GT_MetaTileEntity_Hatch_Muffler.class,
- GT_MetaTileEntity_Hatch_Output.class,
- GT_MetaTileEntity_Hatch_OutputBus.class,
- GT_MetaTileEntity_Hatch.class
- };
- } else {
- aHatchTypeClass = new Class[] {
- GT_MetaTileEntity_Hatch_Dynamo.class,
- GT_MetaTileEntity_Hatch_Energy.class,
- GT_MetaTileEntity_Hatch_Input.class,
- GT_MetaTileEntity_Hatch_InputBus.class,
- GT_MetaTileEntity_Hatch_Maintenance.class,
- GT_MetaTileEntity_Hatch_Muffler.class,
- GT_MetaTileEntity_Hatch_Output.class,
- GT_MetaTileEntity_Hatch_OutputBus.class,
- GT_MetaTileEntity_Hatch.class
- };
- }
- }
- }
-
-
-
- mLayerData[x][z] = new LayerBlockData(aBlock, aMeta, canBeHatch, aHatchTypeClass);
- return true;
- }
-
- /**
- * Adds a controller to the layer at the designated location, Details about the controller do not need to be specified.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addController(int x, int z) {
- setControllerLocation(new Pair<Integer, Integer>(x, z));
- return addBlockForPos(GregTech_API.sBlockMachines, 0, x, z, true, GT_MetaTileEntity_MultiBlockBase.class);
- }
-
-
- /**
- * Adds a Muffler to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addMuffler(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Muffler.class);
- }
-
-
- /**
- * Adds a Maint Hatch to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addMaintHatch(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Maintenance.class);
- }
-
-
- /**
- * Adds ah Input to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addInputBus(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_InputBus.class);
- }
-
-
- /**
- * Adds an Output to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addOutputBus(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_OutputBus.class);
- }
-
- /**
- * Adds ah Input to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addInputHatch(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Input.class);
- }
-
-
- /**
- * Adds an Output to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addOutputHatch(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Output.class);
- }
-
- /**
- * Adds ah Input to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addInput(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, new Class[] {GT_MetaTileEntity_Hatch_Input.class, GT_MetaTileEntity_Hatch_InputBus.class});
- }
-
-
- /**
- * Adds an Output to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addOutput(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, new Class[] {GT_MetaTileEntity_Hatch_Output.class, GT_MetaTileEntity_Hatch_OutputBus.class});
- }
-
- /**
- * Adds ah Input to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addEnergyInput(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Energy.class);
- }
-
-
- /**
- * Adds an Output to the layer at the designated location.
- * @param x - The X location, where 0 is the top left corner & counts upwards, moving right.
- * @param z - The Z location, where 0 is the top left corner & counts upwards, moving down.
- * @return - Is this controller added to the layer data map?
- */
- public boolean addEnergyOutput(Block aBlock, int aMeta, int x, int z) {
- return addBlockForPos(aBlock, aMeta, x, z, true, GT_MetaTileEntity_Hatch_Dynamo.class);
- }
-
- /**
- *
- * @param aBlock - The block you expect.
- * @param aMeta - The meta you expect.
- * @param x - the non-relative x location you expect it.
- * @param z - the non-relative z location you expect it.
- * @param aDir - The direction the controller is facing.
- * @return - True if the correct Block was found. May also return true if a hatch is found when allowed or it's the controller.
- */
- public boolean getBlockForPos(Block aBlock, int aMeta, int x, int z, ForgeDirection aDir) {
- //Logger.INFO("Grid Index X: "+x+" | Z: "+z + " | "+aDir.name());
- LayerBlockData g;
- if (aDir == ForgeDirection.SOUTH) {
- g = mVariantOrientations.get(2)[x][z];
- }
- else if (aDir == ForgeDirection.WEST) {
- g = mVariantOrientations.get(3)[x][z];
- }
- else if (aDir == ForgeDirection.NORTH) {
- LayerBlockData[][] aData = mVariantOrientations.get(0);
- if (aData != null) {
- //Logger.INFO("Found Valid Orientation Data. "+aData.length + ", "+aData[0].length);
- g = aData[x][z];
- }
- else {
- //Logger.INFO("Did not find valid orientation data.");
- g = null;
- }
- }
- else if (aDir == ForgeDirection.EAST) {
- g = mVariantOrientations.get(1)[x][z];
- }
- else {
- g = mLayerData[x][z];
- }
- if (g == null) {
- Logger.INFO("Failed to find LayerBlockData. Using AIR_FALLBACK");
- //return false;*/
- g = LayerBlockData.FALLBACK_AIR_CHECK;
- }
-
- return g.match(aBlock, aMeta);
- }
-
-
-
- /**
- * Is this layer final?
- * @return - If true, layer data cannot be edited.
- */
- public final boolean isLocked() {
- return mFinalised;
- }
-
- /**
- * Used to finalize the layer, after which all four Orientations are then generated.
- * Cannot be set to false, useful for not locking the layer if an error occurs.
- * @param lockData
- */
- public final void lock(boolean lockData) {
- if (!lockData) {
- Logger.INFO("Failed to lock layer");
- return;
- }
- //Logger.INFO("Trying to lock layer");
- this.mFinalised = true;
- generateOrientations();
- //Logger.INFO("Trying to Build Blueprint Layer [Constructed orietations & finalized]");
- }
-
- private void generateOrientations() {
- try {
-
- //Logger.INFO("Trying to gen orients for layer");
- //North
- mVariantOrientations.put(mLayerData);
- LayerBlockData[][] val;
- //Logger.INFO("1 done");
- //East
- val = rotateArrayClockwise(mLayerData);
- mVariantOrientations.put((LayerBlockData[][]) val);
- //Logger.INFO("2 done");
- //South
- val = rotateArrayClockwise(mLayerData);
- mVariantOrientations.put((LayerBlockData[][]) val);
- //Logger.INFO("3 done");
- //West
- val = rotateArrayClockwise(mLayerData);
- mVariantOrientations.put((LayerBlockData[][]) val);
- //Logger.INFO("4 done");
-
- }
- catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- public static LayerBlockData[][] rotateArrayClockwise(LayerBlockData[][] mat) {
- //Logger.INFO("Rotating Layer 90' Clockwise");
- try {
- final int M = mat.length;
- final int N = mat[0].length;
- //Logger.INFO("Dimension X: "+M);
- //Logger.INFO("Dimension Z: "+N);
- LayerBlockData[][] ret = new LayerBlockData[N][M];
- for (int r = 0; r < M; r++) {
- for (int c = 0; c < N; c++) {
- ret[c][M-1-r] = mat[r][c];
- }
- }
- //Logger.INFO("Returning Rotated Layer");
- return ret;
- }
- catch (Throwable t) {
- t.printStackTrace();
- return null;
- }
- }
-
- public boolean hasController() {
- if (getControllerLocation() == null) {
- return false;
- }
- return true;
- }
-
- public Pair<Integer, Integer> getControllerLocation() {
- return mControllerLocation;
- }
-
- public void setControllerLocation(Pair<Integer, Integer> mControllerLocation) {
- if (hasController()) {
- return;
- }
- this.mControllerLocation = mControllerLocation;
- }
-
- public LayerBlockData getDataFromCoordsWithDirection(ForgeDirection aDir, int W, int D) {
- LayerBlockData g;
- if (aDir == ForgeDirection.SOUTH) {
- g = this.mVariantOrientations.get(2)[W][D];
- }
- else if (aDir == ForgeDirection.WEST) {
- g = this.mVariantOrientations.get(3)[W][D];
- }
- else if (aDir == ForgeDirection.NORTH) {
- g = this.mVariantOrientations.get(0)[W][D];
- }
- else if (aDir == ForgeDirection.EAST) {
- g = this.mVariantOrientations.get(1)[W][D];
- }
- else {
- g = this.mLayerData[W][D];
- }
- return g;
- }
-
- public static Pair<Integer, Integer> rotateOffsetValues(ForgeDirection aDir, int X, int Z) {
- int offsetX, offsetZ;
-
- if (aDir == ForgeDirection.NORTH) {
- offsetX = X;
- offsetZ = Z;
- }
-
- else if (aDir == ForgeDirection.EAST) {
- offsetX = -X;
- offsetZ = Z;
- }
-
- else if (aDir == ForgeDirection.SOUTH) {
- offsetX = -X;
- offsetZ = -Z;
- }
-
- else if (aDir == ForgeDirection.WEST) {
- offsetX = X;
- offsetZ = -Z;
- }
- else {
- offsetX = X;
- offsetZ = Z;
- }
-
- return new Pair<Integer, Integer>(offsetX, offsetZ);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /**
- * Generates a complete {@link MultiblockLayer} from String data.
- * @param aDataMap - A {@link HashMap} containing single character {@link String}s, which map to {@link Pair}<{@link Block}, {@link Integer}>s contains pairs of Blocks & Meta.
- * @param aHorizontalStringRows - The horizontal rows used to map blocks to a grid. Each array slot is one vertical row going downwards as the index increases.
- * @return
- */
- public static MultiblockLayer generateLayerFromData(HashMap<String, Pair<Block, Integer>> aDataMap, String[] aHorizontalStringRows) {
- AutoMap<Pair<String, Pair<Block, Integer>>> x = new AutoMap<Pair<String, Pair<Block, Integer>>>();
-
- for (String u : aDataMap.keySet()) {
- Pair<Block, Integer> r = aDataMap.get(u);
- if (r != null) {
- x.put(new Pair<String, Pair<Block, Integer>>(u, r));
- }
- }
-
- //String aFreeLetters = "abdefgijklmnopqrstuvwxyz";
- /*for (Pair<Block, Integer> h : aDataMap.values()) {
- String y = aFreeLetters.substring(0, 0);
- aFreeLetters = aFreeLetters.replace(y.toLowerCase(), "");
- Pair<String, Pair<Block, Integer>> t = new Pair<String, Pair<Block, Integer>>(y, h);
- x.put(t);
- }*/
- return generateLayerFromData(x, aHorizontalStringRows);
- }
-
-
- /**
- * Generates a complete {@link MultiblockLayer} from String data.
- * @param aDataMap - An {@link AutoMap} which contains {@link Pair}s. These Pairs hold a single character {@link String} and another Pair. This inner pair holds a {@link Block} and an {@link Integer}.
- * @param aHorizontalStringRows - An array which holds the horizontal (X/Width) string data for the layer.
- * @return A complete Multiblock Layer.
- */
- public static MultiblockLayer generateLayerFromData(AutoMap<Pair<String, Pair<Block, Integer>>> aDataMap, String[] aHorizontalStringRows) {
- int width = aHorizontalStringRows[0].length();
- int depth = aHorizontalStringRows.length;
- MultiblockLayer L = new MultiblockLayer(width, depth);
- HashMap<String, Pair<Block, Integer>> K = new HashMap<String, Pair<Block, Integer>>();
-
- //24 Free Letters
- //C = Controller
- //H = Hatch
- String aFreeLetters = "abdefgijklmnopqrstuvwxyz";
- AutoMap<Pair<String, Pair<Block, Integer>>> j = new AutoMap<Pair<String, Pair<Block, Integer>>>();
-
- //Map the keys to a Hashmap
- for (Pair<String, Pair<Block, Integer>> t : aDataMap) {
- String aKeyTemp = t.getKey();
- if (aKeyTemp.toUpperCase().equals("C")){
- j.put(t);
- }
- else if (aKeyTemp.toUpperCase().equals("H")){
- j.put(t);
- }
- else {
- K.put(aKeyTemp.toLowerCase(), t.getValue());
- aFreeLetters.replace(aKeyTemp.toLowerCase(), "");
- }
- }
-
- //Map any Invalid Characters to new ones, in case someone uses C/H.
- if (j.size() > 0) {
- for (Pair<String, Pair<Block, Integer>> h : j) {
- String newKey = aFreeLetters.substring(0, 0);
- K.put(newKey.toLowerCase(), h.getValue());
- aFreeLetters.replace(newKey.toLowerCase(), "");
- }
- }
-
- int xPos = 0;
- int zPos = 0;
-
- //Vertical Iterator
- for (String s : aHorizontalStringRows) {
- //Horizontal Iterator
- for (int q = 0; q < s.length(); q++) {
- //Get char as a String at index q.
- String c = s.substring(q, q);
- //if the character at c matches the character in this row, we add it to the map.
- if (c.toLowerCase().equals(s.toLowerCase())) {
- Pair<Block, Integer> p = K.get(c);
- if (c.toLowerCase().equals("c")) {
- L.addController(xPos, zPos);
- }
- else if (c.toLowerCase().equals("h")) {
- L.addBlockForPos(p.getKey(), p.getValue(), xPos, zPos, true);
- }
- else {
- L.addBlockForPos(p.getKey(), p.getValue(), xPos, zPos, false);
- }
- }
- xPos++;
- }
- xPos = 0;
- zPos++;
- }
- L.lock(true);
- return L;
- }
-
-
-
-
- public static class LayerBlockData{
-
- public static final LayerBlockData FALLBACK_AIR_CHECK = new LayerBlockData(Blocks.air, 0, false);
-
- public final Block mBlock;
- public final int mMeta;
- public final boolean canBeHatch;
- public final Class[] mHatchClass;
-
- public final boolean isController;
-
-
- public LayerBlockData(Block aBlock, int aMeta, boolean aHatch) {
- this(aBlock, aMeta, aHatch, new Class[] {});
- }
-
- public LayerBlockData(Block aBlock, int aMeta, boolean aHatch, Class clazz) {
- this(aBlock, aMeta, aHatch, new Class[] {clazz});
- }
-
- public LayerBlockData(Block aBlock, int aMeta, boolean aHatch, Class[] clazz) {
- mBlock = aBlock;
- mMeta = aMeta;
- canBeHatch = aHatch;
- mHatchClass = clazz;
- if (clazz != null && clazz.length > 0 && clazz[0].equals(GT_MetaTileEntity_MultiBlockBase.class)) {
- isController = true;
- }
- else {
- isController = false;
- }
- }
-
- public boolean match(Block blockToTest, int metaToTest) {
-
- //If Both are some kind of Air Block, good enough.
- if (blockToTest instanceof BlockAir && mBlock instanceof BlockAir) {
- return true;
- }
-
- if (isController && blockToTest == GregTech_API.sBlockMachines) {
- return true;
- }
-
- if (canBeHatch && blockToTest == GregTech_API.sBlockMachines) {
- return true;
- }
-
- if (blockToTest == mBlock && metaToTest == mMeta) {
- return true;
- }
-
- return false;
- }
- }
-
-}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java
deleted file mode 100644
index 10909081d1..0000000000
--- a/src/main/java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockRequirements.java
+++ /dev/null
@@ -1,108 +0,0 @@
-package gtPlusPlus.xmod.gregtech.api.objects;
-
-public class MultiblockRequirements {
-
- public int mInputBusMinimum = 0;
- public int mInputHatchMinimum = 0;
-
- public int mOutputBusMinimum = 0;
- public int mOutputHatchMinimum = 0;
-
- public int mMaintMinimum = 1;
-
- public int mEnergyHatchMinimum = 1;
- public int mDynamoHatchMinimum = 0;
-
- public final int mMinimumCasingCount;
-
- public final MultiblockBlueprint mBlueprint;
-
- //public static final int mControlCoreMinimum = 1;
- /**
- *
- * @param aInputBusses
- * @param aOutputBusses
- * @param aInputHatches
- * @param aOutputHatches
- * @param aEnergyHatches
- * @param aDynamoHatches
- * @param aMaintHatches
- * @param aBlueprint - A data object containing the structural data for this Multiblock
- */
- public MultiblockRequirements(int aCasingCount, MultiblockBlueprint aBlueprint) {
- mMinimumCasingCount = aCasingCount;
- mBlueprint = aBlueprint;
- }
-
- public final int getInputBusMinimum() {
- return this.mInputBusMinimum;
- }
-
- public final MultiblockRequirements setInputBusMinimum(int mInputBusMinimum) {
- this.mInputBusMinimum = mInputBusMinimum;
- return this;
- }
-
- public final int getInputHatchMinimum() {
- return this.mInputHatchMinimum;
- }
-
- public final MultiblockRequirements setInputHatchMinimum(int mInputHatchMinimum) {
- this.mInputHatchMinimum = mInputHatchMinimum;
- return this;
- }
-
- public final int getOutputBusMinimum() {
- return this.mOutputBusMinimum;
- }
-
- public final MultiblockRequirements setOutputBusMinimum(int mOutputBusMinimum) {
- this.mOutputBusMinimum = mOutputBusMinimum;
- return this;
- }
-
- public final int getOutputHatchMinimum() {
- return this.mOutputHatchMinimum;
- }
-
- public final MultiblockRequirements setOutputHatchMinimum(int mOutputHatchMinimum) {
- this.mOutputHatchMinimum = mOutputHatchMinimum;
- return this;
- }
-
- public final int getMaintMinimum() {
- return this.mMaintMinimum;
- }
-
- public final MultiblockRequirements setMaintMinimum(int mMaintMinimum) {
- this.mMaintMinimum = mMaintMinimum;
- return this;
- }
-
- public final int getEnergyHatchMinimum() {
- return this.mEnergyHatchMinimum;
- }
-
- public final MultiblockRequirements setEnergyHatchMinimum(int mEnergyHatchMinimum) {
- this.mEnergyHatchMinimum = mEnergyHatchMinimum;
- return this;
- }
-
- public final int getDynamoHatchMinimum() {
- return this.mDynamoHatchMinimum;
- }
-
- public final MultiblockRequirements setDynamoHatchMinimum(int mDynamoHatchMinimum) {
- this.mDynamoHatchMinimum = mDynamoHatchMinimum;
- return this;
- }
-
- public final MultiblockBlueprint getBlueprint() {
- return this.mBlueprint;
- }
-
- public final int getMinimumCasingCount() {
- return this.mMinimumCasingCount;
- }
-
-}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java
deleted file mode 100644
index ca7cbca5f8..0000000000
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_Generic_3x3.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package gtPlusPlus.xmod.gregtech.common.blueprint;
-
-import gtPlusPlus.api.objects.data.Pair;
-import gtPlusPlus.xmod.gregtech.api.objects.MultiblockBlueprint;
-import gtPlusPlus.xmod.gregtech.api.objects.MultiblockLayer;
-import net.minecraft.block.Block;
-import net.minecraft.init.Blocks;
-
-public class Blueprint_Generic_3x3 extends MultiblockBlueprint {
-
- public Blueprint_Generic_3x3(Pair<Block, Integer> aCasing, int aTextureID) {
- super(3, 3, 3, 10, aTextureID);
-
- // Top/Bottom
- MultiblockLayer a0 = new MultiblockLayer(3, 3);
- Block aCasingBlock_1 = aCasing.getKey();
- int aMeta = aCasing.getValue();
- a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 0, true);
- a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 1, true);
- a0.addBlockForPos(aCasingBlock_1, aMeta, 0, 2, true);
- a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 0, true);
- a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 1, true);
- a0.addBlockForPos(aCasingBlock_1, aMeta, 1, 2, true);
- a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 0, true);
- a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 1, true);
- a0.addBlockForPos(aCasingBlock_1, aMeta, 2, 2, true);
- a0.lock(true);
-
- //Layer one
- MultiblockLayer a1 = new MultiblockLayer(3, 3);
- a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 0, true);
- a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 1, true);
- a1.addBlockForPos(aCasingBlock_1, aMeta, 0, 2, true);
- a1.addBlockForPos(aCasingBlock_1, aMeta, 1, 0, true);
- a1.addBlockForPos(Blocks.air, 0, 1, 1, true);
- a1.addController(1, 2);
- a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 0, true);
- a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 1, true);
- a1.addBlockForPos(aCasingBlock_1, aMeta, 2, 2, true);
- a1.lock(true);
-
- this.setLayer(a0, 0);
- this.setLayer(a1, 1);
- this.setLayer(a0, 2);
- }
-
- @Override
- public int getMinimumInputBus() {
- return 0;
- }
-
- @Override
- public int getMinimumInputHatch() {
- return 0;
- }
-
- @Override
- public int getMinimumOutputBus() {
- return 0;
- }
-
- @Override
- public int getMinimumOutputHatch() {
- return 0;
- }
-
- @Override
- public int getMinimumInputEnergy() {
- return 1;
- }
-
- @Override
- public int getMinimumOutputEnergy() {
- return 0;
- }
-
- @Override
- public int getMinimumMaintHatch() {
- return 1;
- }
-
- @Override
- public int getMinimumMufflers() {
- return 1;
- }
-
-}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java
deleted file mode 100644
index 3551172904..0000000000
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blueprint/Blueprint_LFTR.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package gtPlusPlus.xmod.gregtech.common.blueprint;
-
-import gregtech.api.enums.TAE;
-import gtPlusPlus.core.block.ModBlocks;
-import gtPlusPlus.xmod.gregtech.api.objects.MultiblockBlueprint;
-import gtPlusPlus.xmod.gregtech.api.objects.MultiblockLayer;
-import net.minecraft.block.Block;
-
-public class Blueprint_LFTR extends MultiblockBlueprint {
-
- public Blueprint_LFTR() {
- super(7, 4, 7, 10, TAE.GTPP_INDEX(12));
-
-
- Block aCasingMain = ModBlocks.blockCasingsMisc;
- int aMetaCasingMain = 12;
- int aMetaCasingSecondary = 13;
-
-
-
- /**
- * First Layer (All edges can be Hatches, controller is centered in the front)
- */
-
- MultiblockLayer a0 = new MultiblockLayer(7, 7);
- for (int i = 0; i < 7; i++) {
- a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, 0, true);
- }
- for (int i = 0; i < 7; i++) {
- for (int u = 1; u < 6; u++) {
- a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, u, i == 0 ? true : i == 6 ? true : false);
- }
- }
- for (int i = 0; i < 7; i++) {
- if (i != 3) {
- a0.addBlockForPos(aCasingMain, aMetaCasingMain, i, 6, true);
- }
- else {
- a0.addController(i, 6);
- }
- }
- a0.lock(true);
-
-
-
-
- /**
- * Middle Layer(s)
- */
-
- MultiblockLayer a1 = new MultiblockLayer(7, 7);
- for (int i = 0; i < 7; i++) {
- a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, 0, false);
- }
- for (int i = 0; i < 7; i++) {
- for (int u = 1; u < 6; u++) {
- if (i == 0 || i == 6)
- a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, u, false);
- }
- }
- for (int i = 0; i < 7; i++) {
- a1.addBlockForPos(aCasingMain, aMetaCasingSecondary, i, 6, false);
-
- }
- a1.lock(true);
-
-
- /**
- * Top Layer (All edges can be Hatches, Mufflers required in inner 3x3)
- */
-
- MultiblockLayer a2 = new MultiblockLayer(7, 7);
- for (int i = 0; i < 7; i++) {
- a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, 0, true);
- }
- for (int i = 0; i < 7; i++) {
- for (int u = 1; u < 6; u++) {
- if ((i == 2 || i == 3 || i == 4) && (u == 2 || u ==3 || u == 4)) {
- a2.addMuffler(aCasingMain, aMetaCasingMain, i, u);
- }
- else {
- a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, u, true);
- }
- }
- }
- for (int i = 0; i < 7; i++) {
- a2.addBlockForPos(aCasingMain, aMetaCasingMain, i, 6, true);
- }
- a2.lock(true);
-
- this.setLayer(a0, 0);
- this.setLayer(a1, 1);
- this.setLayer(a1, 2);
- this.setLayer(a2, 3);
- }
-
- @Override
- public int getMinimumInputBus() {
- return 0;
- }
-
- @Override
- public int getMinimumInputHatch() {
- return 4;
- }
-
- @Override
- public int getMinimumOutputBus() {
- return 0;
- }
-
- @Override
- public int getMinimumOutputHatch() {
- return 4;
- }
-
- @Override
- public int getMinimumInputEnergy() {
- return 0;
- }
-
- @Override
- public int getMinimumOutputEnergy() {
- return 4;
- }
-
- @Override
- public int getMinimumMaintHatch() {
- return 1;
- }
-
- @Override
- public int getMinimumMufflers() {
- return 4;
- }
-
-}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java
deleted file mode 100644
index e53a7e4738..0000000000
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/requirements/RequirementsBasicCubic.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package gtPlusPlus.xmod.gregtech.common.requirements;
-
-import gtPlusPlus.xmod.gregtech.api.objects.MultiblockRequirements;
-
-public class RequirementsBasicCubic extends MultiblockRequirements {
-
- public RequirementsBasicCubic( ) {
- super(0, null);
- }
-
-}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java
index b8f24d6c5e..7e7ecfa390 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java
@@ -1,16 +1,36 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
+import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls;
+
import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.ArrayUtils;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
-import gregtech.api.enums.*;
+
+import gregtech.api.enums.GT_Values;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.OrePrefixes;
+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.interfaces.tileentity.IHasWorldObjectAndCoords;
-import gregtech.api.metatileentity.implementations.*;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GTPP_Recipe;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
@@ -19,19 +39,23 @@ import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.api.objects.minecraft.ItemStackData;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.lib.CORE;
+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 net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
-import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
-import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
-
-public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase {
+public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase<GMTE_AmazonPackager> {
private long mVoltage;
private byte mTier;
private int mCasing;
+
+ private ItemStack mSchematicCache;;
+ private ItemStack mInputCache;
+ private ItemStack mOutputCache;
+ private GT_Recipe mCachedRecipe;
+
private IStructureDefinition<GMTE_AmazonPackager> STRUCTURE_DEFINITION = null;
@Override
@@ -67,24 +91,24 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase {
if (STRUCTURE_DEFINITION == null) {
STRUCTURE_DEFINITION = StructureDefinition.<GMTE_AmazonPackager>builder()
.addShape(mName, transpose(new String[][]{
- {"CCC", "CCC", "CCC"},
- {"C~C", "C-C", "CCC"},
- {"CCC", "CCC", "CCC"},
+ {"CCC", "CCC", "CCC"},
+ {"C~C", "C-C", "CCC"},
+ {"CCC", "CCC", "CCC"},
}))
.addElement(
'C',
ofChain(
ofHatchAdder(
GMTE_AmazonPackager::addAmazonPackagerList, TAE.getIndexFromPage(2, 9), 1
- ),
+ ),
onElementPass(
x -> ++x.mCasing,
ofBlock(
ModBlocks.blockCasings3Misc, 9
+ )
)
)
)
- )
.build();
}
return STRUCTURE_DEFINITION;
@@ -116,25 +140,25 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase {
protected GT_Multiblock_Tooltip_Builder createTooltip() {
GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
tt.addMachineType(getMachineType())
- .addInfo("Controller Block for the Amazon Warehouse")
- .addInfo("This Multiblock is used for EXTREME packaging requirements")
- .addInfo("Dust Schematics are inserted into the input busses")
- .addInfo("If inserted into the controller, it is shared across all busses")
- .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot")
- .addInfo("Uncomparably fast compared to a single packager of the same tier")
- .addInfo("Only uses 75% of the eu/t normally required")
- .addInfo("Processes five items per voltage tier")
- .addPollutionAmount(getPollutionPerSecond(null))
- .addSeparator()
- .beginStructureBlock(3, 3, 3, true)
- .addController("Front center")
- .addCasingInfo("Supply Depot Casings", 10)
- .addInputBus("Any casing", 1)
- .addOutputBus("Any casing", 1)
- .addEnergyHatch("Any casing", 1)
- .addMaintenanceHatch("Any casing", 1)
- .addMufflerHatch("Any casing", 1)
- .toolTipFinisher("GT++");
+ .addInfo("Controller Block for the Amazon Warehouse")
+ .addInfo("This Multiblock is used for EXTREME packaging requirements")
+ .addInfo("Dust Schematics are inserted into the input busses")
+ .addInfo("If inserted into the controller, it is shared across all busses")
+ .addInfo("1x, 2x, 3x & Other Schematics are to be placed into the controller GUI slot")
+ .addInfo("Uncomparably fast compared to a single packager of the same tier")
+ .addInfo("Only uses 75% of the eu/t normally required")
+ .addInfo("Processes 16 items per voltage tier")
+ .addPollutionAmount(getPollutionPerSecond(null))
+ .addSeparator()
+ .beginStructureBlock(3, 3, 3, true)
+ .addController("Front center")
+ .addCasingInfo("Supply Depot Casings", 10)
+ .addInputBus("Any casing", 1)
+ .addOutputBus("Any casing", 1)
+ .addEnergyHatch("Any casing", 1)
+ .addMaintenanceHatch("Any casing", 1)
+ .addMufflerHatch("Any casing", 1)
+ .toolTipFinisher("GT++");
return tt;
}
@@ -146,9 +170,9 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase {
@Override
public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
if (aSide == aFacing) {
- return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 1)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)};
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 9)), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)};
}
- return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 1))};
+ return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(TAE.getIndexFromPage(2, 9))};
}
@@ -164,20 +188,20 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase {
}
}
+ private static final FluidStack[] sNoFluids = new FluidStack[] {};
+
@Override
public boolean checkRecipe(ItemStack aStack) {
-
+
//Just the best place to check this~
initFields();
-
+
ArrayList<ItemStack> tItems = getStoredInputs();
if (this.getGUIItemStack() != null) {
tItems.add(this.getGUIItemStack());
}
- ArrayList<FluidStack> tFluids = getStoredFluids();
ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]);
- FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]);
- boolean state = checkRecipeGeneric(tItemInputs, tFluidInputs, 5 * GT_Utility.getTier(this.getMaxInputVoltage()), 75, 500, 10000);
+ boolean state = checkRecipeGeneric(tItemInputs, sNoFluids, 16 * GT_Utility.getTier(this.getMaxInputVoltage()), 75, 500, 10000);
if (state) {
@@ -204,7 +228,7 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase {
}
}
}
-
+
return mCompleted != null && mCompleted.size() > 0;
}
}
@@ -262,6 +286,282 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase {
return false;
}
+ private ItemStack getSchematic(ItemStack[] aInputs) {
+ for (ItemStack aStack : aInputs) {
+ if (ItemList.Schematic_Dust.isStackEqual(aStack) || ItemList.Schematic_1by1.isStackEqual(aStack) || ItemList.Schematic_2by2.isStackEqual(aStack) || ItemList.Schematic_3by3.isStackEqual(aStack)) {
+ return aStack;
+ }
+ }
+ return null;
+ }
+
+ private ItemStack getRecipeInput(ItemStack[] aInputs) {
+ for (ItemStack aStack : aInputs) {
+ if (!ItemList.Schematic_Dust.isStackEqual(aStack) && !ItemList.Schematic_1by1.isStackEqual(aStack) && !ItemList.Schematic_2by2.isStackEqual(aStack) && !ItemList.Schematic_3by3.isStackEqual(aStack)) {
+ return aStack;
+ }
+ }
+ return null;
+ }
+
+ private boolean hasValidCache(ItemStack aStack, ItemStack aSchematic, boolean aClearOnFailure) {
+ if (mSchematicCache != null && mInputCache != null && mOutputCache != null && mCachedRecipe != null) {
+ if (GT_Utility.areStacksEqual(aStack, mInputCache) && GT_Utility.areStacksEqual(aSchematic, mSchematicCache)) {
+ return true;
+ }
+ }
+ // clear cache if it was invalid
+ if (aClearOnFailure) {
+ mSchematicCache = null;
+ mInputCache = null;
+ mOutputCache = null;
+ mCachedRecipe = null;
+ }
+ return false;
+ }
+
+ private void cacheItem(ItemStack aSchematic, ItemStack aInputItem, ItemStack aOutputItem, GT_Recipe aRecipe) {
+ mSchematicCache = aSchematic.copy();
+ mInputCache = aInputItem.copy();
+ mOutputCache = aOutputItem.copy();
+ mCachedRecipe = aRecipe;
+ }
+
+ private GT_Recipe generatePackageRecipe(ItemStack aSchematic, ItemStack aInput) {
+ boolean tIsCached = hasValidCache(aInput, aSchematic, true);
+ if (tIsCached) {
+ ItemStack tOutput = mOutputCache.copy();
+ if (tOutput != null) {
+ if (mCachedRecipe != null && GT_Utility.areStacksEqual(aInput, mInputCache) && GT_Utility.areStacksEqual(tOutput, mOutputCache)) {
+ int aRequiredInputSize = 0;
+ if (ItemList.Schematic_Dust.isStackEqual(aSchematic)) {
+ if (OrePrefixes.dustTiny.contains(aInput)) {
+ aRequiredInputSize = 9;
+ }
+ if (OrePrefixes.dustSmall.contains(aInput)) {
+ aRequiredInputSize = 4;
+ }
+ if (OrePrefixes.dust.contains(aInput)) {
+ aRequiredInputSize = 1;
+ }
+ }
+ if (ItemList.Schematic_1by1.isStackEqual(aSchematic)) {
+ aRequiredInputSize = 1;
+ }
+ if (ItemList.Schematic_2by2.isStackEqual(aSchematic)) {
+ aRequiredInputSize = 4;
+ }
+ if (ItemList.Schematic_3by3.isStackEqual(aSchematic)) {
+ aRequiredInputSize = 9;
+ }
+ if (aInput.stackSize >= aRequiredInputSize) {
+ log("Using Cached Recipe. Require: "+aRequiredInputSize+", Found: "+aInput.stackSize);
+ return mCachedRecipe;
+ }
+ else {
+ log("Not enough input");
+ }
+ }
+ }
+ }
+ // We can package this
+ GT_Recipe aRecipe = lookupRecipe();
+ log("Looking up new recipe");
+ if (aRecipe != null) {
+ // Cache it
+ aInput = aInput != null ? aInput : getRecipeInput(aRecipe.mInputs);
+ cacheItem(aSchematic, aInput, aRecipe.mOutputs[0], aRecipe);
+ if (hasValidCache(aInput, aSchematic, false)) {
+ log("Caching Recipe");
+ return aRecipe;
+ }
+ }
+ return null;
+ }
+
+ private GT_Recipe lookupRecipe() {
+ ArrayList<ItemStack> aItems = getStoredInputs();
+ if (this.getGUIItemStack() != null) {
+ aItems.add(this.getGUIItemStack());
+ }
+ ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]);
+ GT_Recipe tRecipe = findRecipe(
+ getBaseMetaTileEntity(), mLastRecipe, false, false,
+ gregtech.api.enums.GT_Values.V[mTier], sNoFluids, aItemInputs);
+
+ if (tRecipe != null) {
+ return tRecipe;
+ }
+ return null;
+ }
+
+
+
+
+
+ public boolean checkRecipeGeneric(
+ ItemStack[] aItemInputs, FluidStack[] aFluidInputs,
+ int aMaxParallelRecipes, int aEUPercent,
+ int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe, boolean isPerpectOC) {
+ // Based on the Processing Array. A bit overkill, but very flexible.
+
+ // Reset outputs and progress stats
+ this.mEUt = 0;
+ this.mMaxProgresstime = 0;
+ this.mOutputItems = new ItemStack[]{};
+ this.mOutputFluids = new FluidStack[]{};
+
+ long tVoltage = getMaxInputVoltage();
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ long tEnergy = getMaxInputEnergy();
+ log("Running checkRecipeGeneric(0)");
+
+ ItemStack aInput = getRecipeInput(aItemInputs);
+ ItemStack aSchematic = getSchematic(aItemInputs);
+ GT_Recipe tRecipe = generatePackageRecipe(aSchematic, aInput);
+
+ ItemStack[] aRealInputs = new ItemStack[] {aSchematic, aInput};
+ log("Running checkRecipeGeneric(1)");
+ // Remember last recipe - an optimization for findRecipe()
+ this.mLastRecipe = tRecipe;
+
+ if (tRecipe == null) {
+ log("BAD RETURN - 1");
+ return false;
+ }
+
+ aMaxParallelRecipes = this.canBufferOutputs(tRecipe, aMaxParallelRecipes);
+ if (aMaxParallelRecipes == 0) {
+ log("BAD RETURN - 2");
+ return false;
+ }
+
+ // 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, sNoFluids, aItemInputs)) {
+ log("Broke at "+parallelRecipes+".");
+ break;
+ }
+ log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+".");
+ tTotalEUt += tRecipeEUt;
+ }
+
+ if (parallelRecipes == 0) {
+ mCachedRecipe = null;
+ log("BAD RETURN - 3 - Reset Cached Recipe");
+ return false;
+ }
+
+ // -- Try not to fail after this point - inputs have already been consumed! --
+
+
+
+ // 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;
+
+ // 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;
+ if (isPerpectOC) this.mMaxProgresstime /= 4;
+ else this.mMaxProgresstime /= 2;
+ }
+ }
+
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
+ }
+
+ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
+
+ // Collect fluid outputs
+ FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length];
+ for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) {
+ if (tRecipe.getFluidOutput(h) != null) {
+ tOutputFluids[h] = tRecipe.getFluidOutput(h).copy();
+ tOutputFluids[h].amount *= parallelRecipes;
+ }
+ }
+
+ // Collect output item types
+ ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length];
+ for (int h = 0; h < tRecipe.mOutputs.length; h++) {
+ if (tRecipe.getOutput(h) != null) {
+ tOutputItems[h] = tRecipe.getOutput(h).copy();
+ tOutputItems[h].stackSize = 0;
+ }
+ }
+
+ // 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 < parallelRecipes; g++) {
+ if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f))
+ tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize;
+ }
+ }
+ }
+
+ tOutputItems = removeNulls(tOutputItems);
+
+ // Sanitize item stack size, splitting any stacks greater than max stack size
+ List<ItemStack> splitStacks = new ArrayList<ItemStack>();
+ for (ItemStack tItem : tOutputItems) {
+ while (tItem.getMaxStackSize() < tItem.stackSize) {
+ ItemStack tmp = tItem.copy();
+ tmp.stackSize = tmp.getMaxStackSize();
+ tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize();
+ splitStacks.add(tmp);
+ }
+ }
+
+ if (splitStacks.size() > 0) {
+ ItemStack[] tmp = new ItemStack[splitStacks.size()];
+ tmp = splitStacks.toArray(tmp);
+ tOutputItems = ArrayUtils.addAll(tOutputItems, tmp);
+ }
+
+ // Strip empty stacks
+ List<ItemStack> tSList = new ArrayList<ItemStack>();
+ for (ItemStack tS : tOutputItems) {
+ if (tS.stackSize > 0) tSList.add(tS);
+ }
+ tOutputItems = tSList.toArray(new ItemStack[tSList.size()]);
+
+ // Commit outputs
+ this.mOutputItems = tOutputItems;
+ this.mOutputFluids = tOutputFluids;
+ updateSlots();
+
+ // Play sounds (GT++ addition - GT multiblocks play no sounds)
+ startProcess();
+
+ log("GOOD RETURN - 1");
+ return true;
+ }
+
public boolean allowPutStack(final ItemStack aStack, ItemStack schematicStack) {
//If Schematic Static is not 1x1, 2x2, 3x3
if (!ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) && !ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) && !ItemList.Schematic_3by3.isStackEqual((Object) schematicStack)) {