Merge pull request from Antifluxfield/drillers-upgrade

Drillers upgrade
This commit is contained in:
Blood-Asp 2017-09-12 21:09:32 +02:00 committed by GitHub
commit 0d0d8270ee
16 changed files with 3319 additions and 2852 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,84 +1,85 @@
package gregtech.api.gui;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
* The GUI-Container I use for all my Basic Machines
* <p/>
* As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes which extend this class
*/
public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machine {
String mName = "";
public GT_GUIContainer_MultiMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) {
super(new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile));
mName = aName;
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRendererObj.drawString(mName, 10, 8, 16448255);
if (mContainer != null) {
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 1) != 0)
fontRendererObj.drawString(trans("132", "Pipe is loose."), 10, 16, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 2) != 0)
fontRendererObj.drawString(trans("133", "Screws are missing."), 10, 24, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 4) != 0)
fontRendererObj.drawString(trans("134", "Something is stuck."), 10, 32, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 8) != 0)
fontRendererObj.drawString(trans("135", "Platings are dented."), 10, 40, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 16) != 0)
fontRendererObj.drawString(trans("136", "Circuitry burned out."), 10, 48, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 32) != 0)
fontRendererObj.drawString(trans("137", "That doesn't belong there."), 10, 56, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 64) != 0)
fontRendererObj.drawString(trans("138", "Incomplete Structure."), 10, 64, 16448255);
if (((GT_Container_MultiMachine) mContainer).mDisplayErrorCode == 0) {
if (((GT_Container_MultiMachine) mContainer).mActive == 0) {
fontRendererObj.drawString(trans("139", "Hit with Soft Hammer"), 10, 16, 16448255);
fontRendererObj.drawString(trans("140", "to (re-)start the Machine"), 10, 24, 16448255);
fontRendererObj.drawString(trans("141", "if it doesn't start."), 10, 32, 16448255);
} else {
fontRendererObj.drawString(trans("142", "Running perfectly."), 10, 16, 16448255);
}
int id = mContainer.mTileEntity.getMetaTileID();
if (id == 1157 || id == 1158 || id == 1177 || id == 1178 || id == 1179) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if (tItem == null || !GT_Utility.areStacksEqual(tItem, GT_ModHandler.getIC2Item("miningPipe", 1L))) {
fontRendererObj.drawString(trans("143", "Missing Mining Pipe"), 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
}
} else if (id == 1131 || id == 1151 || id == 1152 || id == 1153) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if (tItem == null || !(tItem.getItem() == GT_MetaGenerated_Tool_01.INSTANCE && tItem.getItemDamage() >= 170 && tItem.getItemDamage() <= 177)) {
fontRendererObj.drawString(trans("144", "Missing Turbine Rotor"), 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
}
}
}
}
}
public String trans(String aKey, String aEnglish) {
return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
}
package gregtech.api.gui;
import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase;
import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
* The GUI-Container I use for all my Basic Machines
* <p/>
* As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes which extend this class
*/
public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machine {
String mName = "";
public GT_GUIContainer_MultiMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile) {
super(new GT_Container_MultiMachine(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "multimachines/" + (aTextureFile == null ? "MultiblockDisplay" : aTextureFile));
mName = aName;
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
fontRendererObj.drawString(mName, 10, 8, 16448255);
if (mContainer != null) {
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 1) != 0)
fontRendererObj.drawString(trans("132", "Pipe is loose."), 10, 16, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 2) != 0)
fontRendererObj.drawString(trans("133", "Screws are missing."), 10, 24, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 4) != 0)
fontRendererObj.drawString(trans("134", "Something is stuck."), 10, 32, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 8) != 0)
fontRendererObj.drawString(trans("135", "Platings are dented."), 10, 40, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 16) != 0)
fontRendererObj.drawString(trans("136", "Circuitry burned out."), 10, 48, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 32) != 0)
fontRendererObj.drawString(trans("137", "That doesn't belong there."), 10, 56, 16448255);
if ((((GT_Container_MultiMachine) mContainer).mDisplayErrorCode & 64) != 0)
fontRendererObj.drawString(trans("138", "Incomplete Structure."), 10, 64, 16448255);
if (((GT_Container_MultiMachine) mContainer).mDisplayErrorCode == 0) {
if (((GT_Container_MultiMachine) mContainer).mActive == 0) {
fontRendererObj.drawString(trans("139", "Hit with Soft Hammer"), 10, 16, 16448255);
fontRendererObj.drawString(trans("140", "to (re-)start the Machine"), 10, 24, 16448255);
fontRendererObj.drawString(trans("141", "if it doesn't start."), 10, 32, 16448255);
} else {
fontRendererObj.drawString(trans("142", "Running perfectly."), 10, 16, 16448255);
}
if (mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_DrillerBase) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if (tItem == null || !GT_Utility.areStacksEqual(tItem, GT_ModHandler.getIC2Item("miningPipe", 1L))) {
fontRendererObj.drawString(trans("143", "Missing Mining Pipe"), 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
}
} else if (mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if (tItem == null || !(tItem.getItem() == GT_MetaGenerated_Tool_01.INSTANCE && tItem.getItemDamage() >= 170 && tItem.getItemDamage() <= 177)) {
fontRendererObj.drawString(trans("144", "Missing Turbine Rotor"), 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
}
}
}
}
}
public String trans(String aKey, String aEnglish) {
return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
}

View file

@ -1,101 +1,106 @@
package gregtech.api.metatileentity.implementations;
import gregtech.api.enums.Textures;
import gregtech.api.gui.*;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_DataAccess(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 16, new String[]{
"Data Access for Multiblocks",
"Adds " + (aTier == 4 ? 4 : 16) + " extra slots for Data Sticks"});
}
public GT_MetaTileEntity_Hatch_DataAccess(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aTier == 4 ? 4 : 16, aDescription, aTextures);
}
public GT_MetaTileEntity_Hatch_DataAccess(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aTier == 4 ? 4 : 16, aDescription, aTextures);
}
@Override
public ITexture[] getTexturesActive(ITexture aBaseTexture) {
return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_DATA_ACCESS)};
}
@Override
public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_DATA_ACCESS)};
}
@Override
public boolean isSimpleMachine() {
return true;
}
@Override
public boolean isFacingValid(byte aFacing) {
return true;
}
@Override
public boolean isAccessAllowed(EntityPlayer aPlayer) {
return true;
}
@Override
public boolean isValidSlot(int aIndex) {
return true;
}
@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_Hatch_DataAccess(mName, mTier, mDescriptionArray, mTextures);
}
@Override
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
if (aBaseMetaTileEntity.isClientSide()) return true;
aBaseMetaTileEntity.openGUI(aPlayer);
return true;
}
@Override
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
switch (mTier) {
case 4:
return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity);
default:
return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity);
}
}
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
switch (mTier) {
case 4:
return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess");
case 6:
return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess");
default:
return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess");
}
}
@Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
}
package gregtech.api.metatileentity.implementations;
import gregtech.api.enums.Textures;
import gregtech.api.gui.*;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_DataAccess(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 16, new String[]{
"Data Access for Multiblocks",
"Adds " + (aTier == 4 ? 4 : 16) + " extra slots for Data Sticks"});
}
public GT_MetaTileEntity_Hatch_DataAccess(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aTier == 4 ? 4 : 16, aDescription, aTextures);
}
public GT_MetaTileEntity_Hatch_DataAccess(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
super(aName, aTier, aTier == 4 ? 4 : 16, aDescription, aTextures);
}
@Override
public ITexture[] getTexturesActive(ITexture aBaseTexture) {
return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_DATA_ACCESS)};
}
@Override
public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_DATA_ACCESS)};
}
@Override
public boolean isSimpleMachine() {
return true;
}
@Override
public boolean isFacingValid(byte aFacing) {
return true;
}
@Override
public boolean isAccessAllowed(EntityPlayer aPlayer) {
return true;
}
@Override
public boolean isValidSlot(int aIndex) {
return true;
}
@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_Hatch_DataAccess(mName, mTier, mDescriptionArray, mTextures);
}
@Override
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
if (aBaseMetaTileEntity.isClientSide()) return true;
aBaseMetaTileEntity.openGUI(aPlayer);
return true;
}
@Override
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
switch (mTier) {
case 4:
return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity);
default:
return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity);
}
}
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
switch (mTier) {
case 4:
return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess");
case 6:
return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess");
default:
return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess");
}
}
@Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
@Override
public int getInventoryStackLimit() {
return 1;
}
}

View file

@ -1,377 +1,377 @@
package gregtech.common.tileentities.machines.multi;
import java.util.ArrayList;
import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
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_DataAccess;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
public class GT_MetaTileEntity_AssemblyLine
extends GT_MetaTileEntity_MultiBlockBase {
public ArrayList<GT_MetaTileEntity_Hatch_DataAccess> mDataAccessHatches = new ArrayList<GT_MetaTileEntity_Hatch_DataAccess>();
public GT_MetaTileEntity_AssemblyLine(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_AssemblyLine(String aName) {
super(aName);
}
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_AssemblyLine(this.mName);
}
public String[] getDescription() {
return new String[]{"Assembly Line",
"Size: 3x(5-16)x4, variable length",
"Bottom: Steel Machine Casing(or Maintenance or Input Hatch),",
"Input Bus (Last Output Bus), Steel Machine Casing",
"Middle: Reinforced Glass, Assembly Line, Reinforced Glass",
"UpMiddle: Grate Machine Casing,",
" Assembler Machine Casing,",
" Grate Machine Casing (or Controller or Data Access Hatch)",
"Top: Steel Casing(or Energy Hatch)",
"Up to 16 repeating slices, last is Output Bus",
"Optional 1x Data Access Hatch next to the Controller"};
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing) {
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE)};
}
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16]};
}
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "AssemblyLine.png");
}
public GT_Recipe.GT_Recipe_Map getRecipeMap() {
return null;
}
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
public boolean isFacingValid(byte aFacing) {
return aFacing > 1;
}
public boolean checkRecipe(ItemStack aStack) {
if(GT_Values.D1)System.out.println("Start ALine recipe check");
ArrayList<ItemStack> tDataStickList = getDataItems(2);
if (tDataStickList.size() == 0) return false;
if(GT_Values.D1)System.out.println("Stick accepted, " + tDataStickList.size() + " Data Sticks found");
ItemStack tStack[] = new ItemStack[15];
FluidStack[] tFluids = new FluidStack[4];
boolean recipeNA = false;
boolean findRecipe = false;
for (ItemStack tDataStick : tDataStickList){
recipeNA = false;
NBTTagCompound tTag = tDataStick.getTagCompound();
if (tTag == null) continue;
for (int i = 0; i < 15; i++) {
if (!tTag.hasKey("" + i)) continue;
if (mInputBusses.get(i) == null) {
recipeNA = true;
break;
}
tStack[i] = GT_Utility.loadItem(tTag, "" + i);
if (tStack[i] == null) continue;
if(GT_Values.D1)System.out.println("Item "+i+" : "+tStack[i].getUnlocalizedName());
ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
if (!GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) || tStack[i].stackSize > stackInSlot.stackSize) {
if(GT_Values.D1)System.out.println(i +" not accepted");
recipeNA = true;
break;
}
if(GT_Values.D1)System.out.println(i+" accepted");
}
if (recipeNA) continue;
if(GT_Values.D1)System.out.println("All Items done, start fluid check");
for (int i = 0; i < 4; i++) {
if (!tTag.hasKey("f" + i)) continue;
tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i);
if (tFluids[i] == null) continue;
if(GT_Values.D1)System.out.println("Fluid "+i+" "+tFluids[i].getUnlocalizedName());
if (mInputHatches.get(i) == null) {
recipeNA = true;
break;
}
FluidStack fluidInHatch = mInputHatches.get(i).mFluid;
if (fluidInHatch == null || !GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) {
if(GT_Values.D1)System.out.println(i+" not accepted");
recipeNA = true;
break;
}
if(GT_Values.D1)System.out.println(i+" accepted");
}
if (recipeNA) continue;
if(GT_Values.D1)System.out.println("Input accepted, check other values");
if (!tTag.hasKey("output")) continue;
mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")};
if (mOutputItems[0] == null || !GT_Utility.isStackValid(mOutputItems[0]))
continue;
if (!tTag.hasKey("time")) continue;
mMaxProgresstime = tTag.getInteger("time");
if (mMaxProgresstime <= 0) continue;
if (!tTag.hasKey("eu")) continue;
mEUt = tTag.getInteger("eu");
if(GT_Values.D1)System.out.println("Find avaiable recipe");
findRecipe = true;
break;
}
if (!findRecipe) return false;
if(GT_Values.D1)System.out.println("All checked start consuming inputs");
for (int i = 0; i < 15; i++) {
if (tStack[i] == null) continue;
ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
stackInSlot.stackSize -= tStack[i].stackSize;
}
for (int i = 0; i < 4; i++) {
if (tFluids[i] == null) continue;
mInputHatches.get(i).mFluid.amount -= tFluids[i].amount;
if (mInputHatches.get(i).mFluid.amount <= 0) {
mInputHatches.get(i).mFluid = null;
}
}
if(GT_Values.D1)System.out.println("Check overclock");
byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage()));
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
if (mEUt <= 16) {
this.mEUt = (mEUt * (1 << tTier - 1) * (1 << tTier - 1));
this.mMaxProgresstime = (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);
updateSlots();
if(GT_Values.D1)System.out.println("Recipe sucessfull");
return true;
}
public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {
super.startSoundLoop(aIndex, aX, aY, aZ);
if (aIndex == 20) {
GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ);
}
}
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
if (xDir != 0) {
for (int r = 0; r <= 16; r++) {
int i = r * xDir;
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, 0, i);
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(0, 0, i) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(0, 0, i) == 10)) {
if(r == 1 && !addDataAccessToMachineList(tTileEntity, 16)){
return false;
}
}
if (!aBaseMetaTileEntity.getBlockOffset(0, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, -2, i);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(0, -2, i) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(0, -2, i) != 0) {
return false;
}
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 1, i);
if (!addEnergyInputToMachineList(tTileEntity, 16)) {
if (aBaseMetaTileEntity.getBlockOffset(xDir, 1, i) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(xDir, 1, i) != 0) {
return false;
}
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(xDir, 0, i) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(xDir, 0, i) == 9)) {
return false;
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(xDir, -1, i) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, i) == 5)) {
return false;
}
if (!(aBaseMetaTileEntity.getBlockOffset(xDir * 2, 0, i) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, 0, i) == 10)) {
return false;
}
if (!aBaseMetaTileEntity.getBlockOffset(xDir * 2, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir * 2, -2, i);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(xDir * 2, -2, i) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, -2, i) != 0) {
return false;
}
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, -2, i);
if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) {
return r > 0 && mEnergyHatches.size() > 0;
}
}
} else {
for (int r = 0; r <= 16; r++) {
int i = r * -zDir;
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 0, 0);
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, 0) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0) == 10)) {
if(r == 1 && !addDataAccessToMachineList(tTileEntity, 16)){
return false;
}
}
if (!aBaseMetaTileEntity.getBlockOffset(i, -1, 0).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, 0);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(i, -2, 0) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, 0) != 0) {
return false;
}
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 1, zDir);
if (!addEnergyInputToMachineList(tTileEntity, 16)) {
if (aBaseMetaTileEntity.getBlockOffset(i, 1, zDir) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, 1, zDir) != 0) {
return false;
}
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir) == 9)) {
return false;
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, -1, zDir) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(i, -1, zDir) == 5)) {
return false;
}
if (!(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir * 2) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir * 2) == 10)) {
return false;
}
if (!aBaseMetaTileEntity.getBlockOffset(i, -1, zDir * 2).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir * 2);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(i, -2, zDir * 2) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, zDir * 2) != 0) {
return false;
}
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir);
if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) {
return r > 0 && mEnergyHatches.size() > 0;
}
}
}
return false;
}
/**
* @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
*/
private boolean isCorrectDataItem(ItemStack aStack, int state){
if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, false, true)) return true;
if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true;
if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true;
return false;
}
/**
* @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
*/
public ArrayList<ItemStack> getDataItems(int state) {
ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
if (GT_Utility.isStackValid(mInventory[1]) && isCorrectDataItem(mInventory[1], state)) {
rList.add(mInventory[1]);
}
for (GT_MetaTileEntity_Hatch_DataAccess tHatch : mDataAccessHatches) {
if (isValidMetaTileEntity(tHatch)) {
for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) {
if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null
&& isCorrectDataItem(tHatch.getBaseMetaTileEntity().getStackInSlot(i), state))
rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
}
}
}
return rList;
}
public boolean addDataAccessToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) {
((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity);
}
return false;
}
public int getMaxEfficiency(ItemStack aStack) {
return 10000;
}
public int getPollutionPerTick(ItemStack aStack) {
return 0;
}
public int getDamageToComponent(ItemStack aStack) {
return 0;
}
public boolean explodesOnComponentBreak(ItemStack aStack) {
return false;
}
}
package gregtech.common.tileentities.machines.multi;
import java.util.ArrayList;
import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
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_DataAccess;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
public class GT_MetaTileEntity_AssemblyLine
extends GT_MetaTileEntity_MultiBlockBase {
//public ArrayList<GT_MetaTileEntity_Hatch_DataAccess> mDataAccessHatches = new ArrayList<GT_MetaTileEntity_Hatch_DataAccess>();
public GT_MetaTileEntity_AssemblyLine(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_AssemblyLine(String aName) {
super(aName);
}
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_AssemblyLine(this.mName);
}
public String[] getDescription() {
return new String[]{"Assembly Line",
"Size: 3x(5-16)x4, variable length",
"Bottom: Steel Machine Casing(or Maintenance or Input Hatch),",
"Input Bus (Last Output Bus), Steel Machine Casing",
"Middle: Reinforced Glass, Assembly Line, Reinforced Glass",
"UpMiddle: Grate Machine Casing,",
" Assembler Machine Casing,",
" Grate Machine Casing (or Controller or Data Access Hatch)",
"Top: Steel Casing(or Energy Hatch)",
"Up to 16 repeating slices, last is Output Bus",
"Optional 1x Data Access Hatch next to the Controller"};
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing) {
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE)};
}
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16]};
}
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "AssemblyLine.png");
}
public GT_Recipe.GT_Recipe_Map getRecipeMap() {
return null;
}
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
public boolean isFacingValid(byte aFacing) {
return aFacing > 1;
}
public boolean checkRecipe(ItemStack aStack) {
if(GT_Values.D1)System.out.println("Start ALine recipe check");
ArrayList<ItemStack> tDataStickList = getDataItems(2);
if (tDataStickList.size() == 0) return false;
if(GT_Values.D1)System.out.println("Stick accepted, " + tDataStickList.size() + " Data Sticks found");
ItemStack tStack[] = new ItemStack[15];
FluidStack[] tFluids = new FluidStack[4];
boolean recipeNA = false;
boolean findRecipe = false;
for (ItemStack tDataStick : tDataStickList){
recipeNA = false;
NBTTagCompound tTag = tDataStick.getTagCompound();
if (tTag == null) continue;
for (int i = 0; i < 15; i++) {
if (!tTag.hasKey("" + i)) continue;
if (mInputBusses.get(i) == null) {
recipeNA = true;
break;
}
tStack[i] = GT_Utility.loadItem(tTag, "" + i);
if (tStack[i] == null) continue;
if(GT_Values.D1)System.out.println("Item "+i+" : "+tStack[i].getUnlocalizedName());
ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
if (!GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) || tStack[i].stackSize > stackInSlot.stackSize) {
if(GT_Values.D1)System.out.println(i +" not accepted");
recipeNA = true;
break;
}
if(GT_Values.D1)System.out.println(i+" accepted");
}
if (recipeNA) continue;
if(GT_Values.D1)System.out.println("All Items done, start fluid check");
for (int i = 0; i < 4; i++) {
if (!tTag.hasKey("f" + i)) continue;
tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i);
if (tFluids[i] == null) continue;
if(GT_Values.D1)System.out.println("Fluid "+i+" "+tFluids[i].getUnlocalizedName());
if (mInputHatches.get(i) == null) {
recipeNA = true;
break;
}
FluidStack fluidInHatch = mInputHatches.get(i).mFluid;
if (fluidInHatch == null || !GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) {
if(GT_Values.D1)System.out.println(i+" not accepted");
recipeNA = true;
break;
}
if(GT_Values.D1)System.out.println(i+" accepted");
}
if (recipeNA) continue;
if(GT_Values.D1)System.out.println("Input accepted, check other values");
if (!tTag.hasKey("output")) continue;
mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")};
if (mOutputItems[0] == null || !GT_Utility.isStackValid(mOutputItems[0]))
continue;
if (!tTag.hasKey("time")) continue;
mMaxProgresstime = tTag.getInteger("time");
if (mMaxProgresstime <= 0) continue;
if (!tTag.hasKey("eu")) continue;
mEUt = tTag.getInteger("eu");
if(GT_Values.D1)System.out.println("Find avaiable recipe");
findRecipe = true;
break;
}
if (!findRecipe) return false;
if(GT_Values.D1)System.out.println("All checked start consuming inputs");
for (int i = 0; i < 15; i++) {
if (tStack[i] == null) continue;
ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
stackInSlot.stackSize -= tStack[i].stackSize;
}
for (int i = 0; i < 4; i++) {
if (tFluids[i] == null) continue;
mInputHatches.get(i).mFluid.amount -= tFluids[i].amount;
if (mInputHatches.get(i).mFluid.amount <= 0) {
mInputHatches.get(i).mFluid = null;
}
}
if(GT_Values.D1)System.out.println("Check overclock");
byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage()));
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
if (mEUt <= 16) {
this.mEUt = (mEUt * (1 << tTier - 1) * (1 << tTier - 1));
this.mMaxProgresstime = (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);
updateSlots();
if(GT_Values.D1)System.out.println("Recipe sucessfull");
return true;
}
public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {
super.startSoundLoop(aIndex, aX, aY, aZ);
if (aIndex == 20) {
GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ);
}
}
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
if (xDir != 0) {
for (int r = 0; r <= 16; r++) {
int i = r * xDir;
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, 0, i);
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(0, 0, i) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(0, 0, i) == 10)) {
if(r == 1 && !addDataAccessToMachineList(tTileEntity, 16)){
return false;
}
}
if (!aBaseMetaTileEntity.getBlockOffset(0, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, -2, i);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(0, -2, i) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(0, -2, i) != 0) {
return false;
}
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 1, i);
if (!addEnergyInputToMachineList(tTileEntity, 16)) {
if (aBaseMetaTileEntity.getBlockOffset(xDir, 1, i) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(xDir, 1, i) != 0) {
return false;
}
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(xDir, 0, i) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(xDir, 0, i) == 9)) {
return false;
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(xDir, -1, i) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, i) == 5)) {
return false;
}
if (!(aBaseMetaTileEntity.getBlockOffset(xDir * 2, 0, i) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, 0, i) == 10)) {
return false;
}
if (!aBaseMetaTileEntity.getBlockOffset(xDir * 2, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir * 2, -2, i);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(xDir * 2, -2, i) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, -2, i) != 0) {
return false;
}
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, -2, i);
if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) {
return r > 0 && mEnergyHatches.size() > 0;
}
}
} else {
for (int r = 0; r <= 16; r++) {
int i = r * -zDir;
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 0, 0);
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, 0) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0) == 10)) {
if(r == 1 && !addDataAccessToMachineList(tTileEntity, 16)){
return false;
}
}
if (!aBaseMetaTileEntity.getBlockOffset(i, -1, 0).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, 0);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(i, -2, 0) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, 0) != 0) {
return false;
}
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 1, zDir);
if (!addEnergyInputToMachineList(tTileEntity, 16)) {
if (aBaseMetaTileEntity.getBlockOffset(i, 1, zDir) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, 1, zDir) != 0) {
return false;
}
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir) == 9)) {
return false;
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, -1, zDir) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(i, -1, zDir) == 5)) {
return false;
}
if (!(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir * 2) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir * 2) == 10)) {
return false;
}
if (!aBaseMetaTileEntity.getBlockOffset(i, -1, zDir * 2).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir * 2);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(i, -2, zDir * 2) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, zDir * 2) != 0) {
return false;
}
}
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir);
if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) {
return r > 0 && mEnergyHatches.size() > 0;
}
}
}
return false;
}
/**
* @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
*/
private boolean isCorrectDataItem(ItemStack aStack, int state){
if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, true, true)) return true;
if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true;
if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true;
return false;
}
/**
* @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
*/
public ArrayList<ItemStack> getDataItems(int state) {
ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
if (GT_Utility.isStackValid(mInventory[1]) && isCorrectDataItem(mInventory[1], state)) {
rList.add(mInventory[1]);
}
for (GT_MetaTileEntity_Hatch_DataAccess tHatch : mDataAccessHatches) {
if (isValidMetaTileEntity(tHatch)) {
for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) {
if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null
&& isCorrectDataItem(tHatch.getBaseMetaTileEntity().getStackInSlot(i), state))
rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
}
}
}
return rList;
}
public boolean addDataAccessToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) {
((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity);
}
return false;
}
public int getMaxEfficiency(ItemStack aStack) {
return 10000;
}
public int getPollutionPerTick(ItemStack aStack) {
return 0;
}
public int getDamageToComponent(ItemStack aStack) {
return 0;
}
public boolean explodesOnComponentBreak(ItemStack aStack) {
return false;
}
}

View file

@ -0,0 +1,51 @@
package gregtech.common.tileentities.machines.multi;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public class GT_MetaTileEntity_ConcreteBackfiller1 extends GT_MetaTileEntity_ConcreteBackfillerBase {
public GT_MetaTileEntity_ConcreteBackfiller1(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_ConcreteBackfiller1(String aName) {
super(aName);
}
@Override
public String[] getDescription() {
return getDescriptionInternal("");
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_ConcreteBackfiller1(mName);
}
@Override
protected ItemList getCasingBlockItem() {
return ItemList.Casing_SolidSteel;
}
@Override
protected Materials getFrameMaterial() {
return Materials.Steel;
}
@Override
protected int getCasingTextureIndex() {
return 16;
}
@Override
protected int getRadius() {
return 16;
}
@Override
protected int getMinTier() {
return 2;
}
}

View file

@ -0,0 +1,66 @@
package gregtech.common.tileentities.machines.multi;
import static gregtech.api.enums.GT_Values.VN;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public class GT_MetaTileEntity_ConcreteBackfiller2 extends GT_MetaTileEntity_ConcreteBackfillerBase {
public GT_MetaTileEntity_ConcreteBackfiller2(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_ConcreteBackfiller2(String aName) {
super(aName);
}
@Override
public String[] getDescription() {
String casings = getCasingBlockItem().get(0).getDisplayName();
return new String[]{
"Controller Block for the Advanced Concrete Backfiller",
"Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)",
"3x1x3 Base of " + casings,
"1x3x1 " + casings + " pillar (Center of base)",
"1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
"1x Input Hatch (One of base casings)",
"1x Maintenance Hatch (One of base casings)",
"1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)",
"Put Programmed Circuits into Data Access to config radius",
"Radius = (total config value)x2 blocks",
"Default 64, Maximum 128",};
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_ConcreteBackfiller2(mName);
}
@Override
protected ItemList getCasingBlockItem() {
return ItemList.Casing_StableTitanium;
}
@Override
protected Materials getFrameMaterial() {
return Materials.Titanium;
}
@Override
protected int getCasingTextureIndex() {
return 50;
}
@Override
protected int getRadius() {
int tConfig = getTotalConfigValue() * 2;
return tConfig >= 128 ? 128 : tConfig <= 0 ? 64 : tConfig;
}
@Override
protected int getMinTier() {
return 4;
}
}

View file

@ -0,0 +1,125 @@
package gregtech.common.tileentities.machines.multi;
import static gregtech.api.enums.GT_Values.V;
import static gregtech.api.enums.GT_Values.VN;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Materials;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTileEntity_DrillerBase {
private int mLastXOff = 0, mLastZOff = 0;
public GT_MetaTileEntity_ConcreteBackfillerBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_ConcreteBackfillerBase(String aName) {
super(aName);
}
protected String[] getDescriptionInternal(String tierSuffix) {
String casings = getCasingBlockItem().get(0).getDisplayName();
return new String[]{
"Controller Block for the Concrete Backfiller " + (tierSuffix != null ? tierSuffix : ""),
"Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)",
"3x1x3 Base of " + casings,
"1x3x1 " + casings + " pillar (Center of base)",
"1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
"1x Input Hatch (One of base casings)",
"1x Maintenance Hatch (One of base casings)",
"1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)",
"Radius is " + getRadius() + " blocks"};
}
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DrillingRig.png");
}
protected abstract int getRadius();
@Override
protected boolean checkHatches() {
return !mMaintenanceHatches.isEmpty() && !mInputHatches.isEmpty() && !mEnergyHatches.isEmpty();
}
@Override
protected void setElectricityStats() {
this.mEfficiency = getCurrentEfficiency(null);
this.mEfficiencyIncrease = 10000;
//T1 = 48; T2 = 192; T3 = 768; T4 = 3072
this.mEUt = 12 * (1 << (getMinTier() << 1));
this.mMaxProgresstime = (isPickingPipes ? 240: 80) / (1 << getMinTier());
long voltage = getMaxInputVoltage();
long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1];
while (this.mEUt <= overclockEu) {
this.mEUt *= 4;
this.mMaxProgresstime /= 2;
}
this.mEUt = -this.mEUt;
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
}
@Override
protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) {
if (isRefillableBlock(xPipe, yHead - 1, zPipe))
return tryRefillBlock(xPipe, yHead - 1, zPipe);
int radius = getRadius();
if (mLastXOff == 0 && mLastZOff == 0) {
mLastXOff = - radius;
mLastZOff = - radius;
}
if (yHead != yDrill) {
for (int i = mLastXOff; i <= radius; i++) {
for (int j = (i == mLastXOff ? mLastZOff : - radius); j <= radius; j++) {
if (isRefillableBlock(xPipe + i, yHead, zPipe + j)){
mLastXOff = i;
mLastZOff = j;
return tryRefillBlock(xPipe + i, yHead, zPipe + j);
}
}
}
}
if (tryPickPipe()) {
mLastXOff = 0;
mLastZOff = 0;
return true;
} else {
isPickingPipes = false;
stopMachine();
return false;
}
}
private boolean isRefillableBlock(int aX, int aY, int aZ){
if (getBaseMetaTileEntity().getTileEntity(aX, aY, aZ) != null) return false;
if (getBaseMetaTileEntity().getAir(aX, aY, aZ) || !getBaseMetaTileEntity().getBlock(aX, aY, aZ).getMaterial().isSolid())
return true;
return false;
}
private boolean tryRefillBlock(int aX, int aY, int aZ) {
if (!tryConsumeFluid())
return false;
getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ, GregTech_API.sBlockConcretes, 8, 3);
return true;
}
private boolean tryConsumeFluid() {
if (!depleteInput(Materials.Concrete.getMolten(144L))){
mMaxProgresstime = 0;
return false;
}
return true;
}
}

View file

@ -0,0 +1,357 @@
package gregtech.common.tileentities.machines.multi;
import static gregtech.api.enums.GT_Values.W;
import java.util.ArrayList;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
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_DataAccess;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase {
private static final ItemStack miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0);
private static final ItemStack miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0);
private static final Block miningPipeBlock = GT_Utility.getBlockFromStack(miningPipe);
private static final Block miningPipeTipBlock = GT_Utility.getBlockFromStack(miningPipeTip);
private Block casingBlock;
private int casingMeta;
private int frameMeta;
private int casingTextureIndex;
private ForgeDirection back;
private int xDrill, yDrill, zDrill, xPipe, zPipe, yHead;
protected boolean isPickingPipes;
public GT_MetaTileEntity_DrillerBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
initFields();
}
public GT_MetaTileEntity_DrillerBase(String aName) {
super(aName);
initFields();
}
private void initFields() {
casingBlock = getCasingBlockItem().getBlock();
casingMeta = getCasingBlockItem().get(0).getItemDamage();
int frameId = 4096 + getFrameMaterial().mMetaItemSubID;
frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W;
casingTextureIndex = getCasingTextureIndex();
isPickingPipes = false;
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing)
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex],new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL)};
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex]};
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
aNBT.setBoolean("isPickingPipe", isPickingPipes);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
isPickingPipes = aNBT.getBoolean("isPickingPipes");
}
protected boolean tryPickPipe() {
if (yHead == yDrill) return false;
if (tryOutputPipe()){
if (checkBlockAndMeta(xPipe, yHead + 1, zPipe, miningPipeBlock, W))
getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead + 1, zPipe, miningPipeTipBlock);
getBaseMetaTileEntity().getWorld().setBlockToAir(xPipe, yHead, zPipe);
return true;
}
return false;
}
protected boolean tryLowerPipe() {
if (!isHasMiningPipes()) return false;
if (yHead <= 0) return false;
if (!canLowerPipe()) return false;
getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead - 1, zPipe, miningPipeTipBlock);
if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeBlock);
getBaseMetaTileEntity().decrStackSize(1, 1);
return true;
}
private void putMiningPipesFromInputsInController() {
int maxPipes = miningPipe.getMaxStackSize();
if (isHasMiningPipes(maxPipes)) return;
ItemStack pipes = getStackInSlot(1);
for (ItemStack storedItem : getStoredInputs()) {
if (!storedItem.isItemEqual(miningPipe)) continue;
if (pipes == null) {
setInventorySlotContents(1, GT_Utility.copy(miningPipe));
pipes = getStackInSlot(1);
}
if (pipes.stackSize == maxPipes) break;
int needPipes = maxPipes - pipes.stackSize;
int transferPipes = storedItem.stackSize < needPipes ? storedItem.stackSize : needPipes;
pipes.stackSize += transferPipes;
storedItem.stackSize -= transferPipes;
}
updateSlots();
}
private boolean tryOutputPipe(){
if (!getBaseMetaTileEntity().addStackToSlot(1, GT_Utility.copyAmount(1, miningPipe)))
mOutputItems = new ItemStack[] {GT_Utility.copyAmount(1, miningPipe)};
return true;
}
protected boolean canLowerPipe(){
return yHead > 0 && !checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, W);
}
private boolean isHasMiningPipes() {
return isHasMiningPipes(1);
}
private boolean isHasMiningPipes(int minCount) {
ItemStack pipe = getStackInSlot(1);
return pipe != null && pipe.stackSize > minCount - 1 && pipe.isItemEqual(miningPipe);
}
private boolean isEnergyEnough() {
long requiredEnergy = 512 + getMaxInputVoltage() * 4;
for (GT_MetaTileEntity_Hatch_Energy energyHatch : mEnergyHatches) {
requiredEnergy -= energyHatch.getEUVar();
if (requiredEnergy <= 0) return true;
}
return false;
}
protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead){
if(!tryLowerPipe())
if(waitForPipes()) return false;
isPickingPipes = true;
return true;
}
protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) {
if (tryPickPipe()) {
return true;
} else {
isPickingPipes = false;
stopMachine();
return false;
}
}
@Override
public boolean checkRecipe(ItemStack aStack) {
//Public pipe actions
setElectricityStats();
int oldYHead = yHead;
if (!checkPipesAndSetYHead() || !isEnergyEnough()) {
stopMachine();
return false;
}
putMiningPipesFromInputsInController();
if (!isPickingPipes)
return workingDownward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead);
else
return workingUpward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead);
}
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
updateCoordinates();
//check base layer
for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) {
for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) {
if (xOff == 0 && zOff == 0) continue;
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff);
if (!checkCasingBlock(xOff, 0, zOff)
&& !addMaintenanceToMachineList(tTileEntity, casingTextureIndex)
&& !addInputToMachineList(tTileEntity, casingTextureIndex)
&& !addOutputToMachineList(tTileEntity, casingTextureIndex)
&& !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)
&& !addDataAccessToMachineList(tTileEntity, casingTextureIndex))
return false;
}
}
if(!checkHatches()) return false;
if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) return false;
//check tower
for (int yOff = 1; yOff < 4; yOff++) {
if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ)
|| !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ)
|| !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ)
|| !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1)
|| !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1)
|| !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ))
return false;
}
return true;
}
private void updateCoordinates() {
xDrill = getBaseMetaTileEntity().getXCoord();
yDrill = getBaseMetaTileEntity().getYCoord();
zDrill = getBaseMetaTileEntity().getZCoord();
back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing());
xPipe = xDrill + back.offsetX;
zPipe = zDrill + back.offsetZ;
}
private boolean checkPipesAndSetYHead() {
yHead = yDrill - 1;
while (checkBlockAndMeta(xPipe, yHead, zPipe, miningPipeBlock, W)) yHead--; //skip pipes
//is pipe tip OR is controller layer
if (checkBlockAndMeta(xPipe, yHead, zPipe, miningPipeTipBlock, W) || ++yHead == yDrill) return true;
//pipe column is broken - try fix
getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeTipBlock);
return true;
}
protected boolean checkCasingBlock(int xOff, int yOff, int zOff) {
return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta);
}
//meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation)
protected boolean checkFrameBlock(int xOff, int yOff, int zOff) {
return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta);
}
protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) {
return checkBlockAndMeta(xDrill + xOff, yDrill + yOff, zDrill + zOff, block, meta);
}
private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) {
return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta)
&& getBaseMetaTileEntity().getBlock(x, y, z) == block;
}
protected boolean waitForPipes(){
if (canLowerPipe()) {
mMaxProgresstime = 0;
return true;
}
return false;
}
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
@Override
public int getMaxEfficiency(ItemStack aStack) {
return 10000;
}
@Override
public int getPollutionPerTick(ItemStack aStack) {
return 0;
}
@Override
public int getDamageToComponent(ItemStack aStack) {
return 0;
}
@Override
public boolean explodesOnComponentBreak(ItemStack aStack) {
return false;
}
public abstract Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity);
protected abstract ItemList getCasingBlockItem();
protected abstract Materials getFrameMaterial();
protected abstract int getCasingTextureIndex();
protected abstract int getMinTier();
protected abstract boolean checkHatches();
protected abstract void setElectricityStats();
public int getTotalConfigValue(){
int config = 0;
ArrayList<ItemStack> tCircuitList = getDataItems(1);
for (ItemStack tCircuit : tCircuitList)
config += tCircuit.getItemDamage();
return config;
}
public ArrayList<GT_MetaTileEntity_Hatch_DataAccess> mDataAccessHatches = new ArrayList<GT_MetaTileEntity_Hatch_DataAccess>();
/**
* @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
*/
private boolean isCorrectDataItem(ItemStack aStack, int state){
if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, true, true)) return true;
if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true;
if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true;
return false;
}
/**
* @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
*/
public ArrayList<ItemStack> getDataItems(int state) {
ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
if (GT_Utility.isStackValid(mInventory[1]) && isCorrectDataItem(mInventory[1], state)) {
rList.add(mInventory[1]);
}
for (GT_MetaTileEntity_Hatch_DataAccess tHatch : mDataAccessHatches) {
if (isValidMetaTileEntity(tHatch)) {
for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) {
if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null
&& isCorrectDataItem(tHatch.getBaseMetaTileEntity().getStackInSlot(i), state))
rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
}
}
}
return rList;
}
public boolean addDataAccessToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) {
((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity);
}
return false;
}
}

View file

@ -1,231 +0,0 @@
package gregtech.common.tileentities.machines.multi;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import static gregtech.common.GT_UndergroundOil.undergroundOil;
public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase {
private boolean completedCycle = false;
public GT_MetaTileEntity_OilDrill(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_OilDrill(String aName) {
super(aName);
}
public String[] getDescription() {
return new String[]{
"Controller Block for the Oil Drilling Rig",
"Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)",
"3x1x3 Base of Solid Steel Machine Casings",
"1x3x1 Solid Steel Machine Casing pillar (Center of base)",
"1x3x1 Steel Frame Boxes (Each Steel pillar side and on top)",
"1x Output Hatch (One of base casings)",
"1x Maintenance Hatch (One of base casings)",
"1x Energy Hatch (One of base casings)"};
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing) {
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_OIL_DRILL_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_OIL_DRILL)};
}
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16]};
}
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DrillingRig.png");
}
@Override
public boolean checkRecipe(ItemStack aStack) {
if (mInventory[1] == null || (mInventory[1].isItemEqual(GT_ModHandler.getIC2Item("miningPipe", 1L)) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) {
ArrayList<ItemStack> tItems = getStoredInputs();
for (ItemStack tStack : tItems) {
if (tStack.isItemEqual(GT_ModHandler.getIC2Item("miningPipe", 1L))) {
if (tStack.stackSize < 2) {
tStack = null;
} else {
tStack.stackSize--;
}
}
if (mInventory[1] == null) {
mInventory[1] = GT_ModHandler.getIC2Item("miningPipe", 1L);
} else {
mInventory[1].stackSize++;
}
}
}
FluidStack tFluid = undergroundOil(getBaseMetaTileEntity(),.5F+(getInputTier()*.25F));
if (tFluid == null) {
stopMachine();
return false;
}
if (getYOfPumpHead() > 0 && getBaseMetaTileEntity().getBlockOffset(ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX, getYOfPumpHead() - 1 - getBaseMetaTileEntity().getYCoord(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ) != Blocks.bedrock) {
if (completedCycle) {
moveOneDown();
}
tFluid = null;
if (mEnergyHatches.size() > 0 && mEnergyHatches.get(0).getEUVar() > (512 + getMaxInputVoltage() * 4))
completedCycle = true;
}
long tVoltage = getMaxInputVoltage();
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000;
int tEU = 24;
int tDuration = 160;
if (tEU <= 16) {
this.mEUt = (tEU * (1 << tTier - 1) * (1 << tTier - 1));
this.mMaxProgresstime = (tDuration / (1 << tTier - 1));
} else {
this.mEUt = tEU;
this.mMaxProgresstime = tDuration;
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);
this.mOutputFluids = new FluidStack[]{tFluid};
return true;
}
private boolean moveOneDown() {
if ((this.mInventory[1] == null) || (this.mInventory[1].stackSize < 1)
|| (!GT_Utility.areStacksEqual(this.mInventory[1], GT_ModHandler.getIC2Item("miningPipe", 1L)))) {
return false;
}
int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ;
int yHead = getYOfPumpHead();
if (yHead < 1) {
return false;
}
if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir) == Blocks.bedrock) {
return false;
}
if (!(getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir, GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))))) {
return false;
}
if (yHead != getBaseMetaTileEntity().getYCoord()) {
getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir, GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L)));
}
getBaseMetaTileEntity().decrStackSize(1, 1);
return true;
}
private int getYOfPumpHead() {
int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ;
int y = getBaseMetaTileEntity().getYCoord() - 1;
while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) == GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L))) {
y--;
}
if (y == getBaseMetaTileEntity().getYCoord() - 1) {
if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))) {
return y + 1;
}
} else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility
.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L)) && this.mInventory[1] != null && this.mInventory[1].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[1], GT_ModHandler.getIC2Item("miningPipe", 1L))) {
getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir,
GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L)));
getBaseMetaTileEntity().decrStackSize(0, 1);
}
return y;
}
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if ((xDir + i != 0) || (zDir + j != 0)) {
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16)) && (!addOutputToMachineList(tTileEntity, 16)) && (!addEnergyInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 0) {
return false;
}
}
}
}
}
for (int y = 1; y < 4; y++) {
if (aBaseMetaTileEntity.getBlockOffset(xDir, y, zDir) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getBlockOffset(xDir + 1, y, zDir) != GregTech_API.sBlockMachines) {
return false;
}
if (aBaseMetaTileEntity.getBlockOffset(xDir - 1, y, zDir) != GregTech_API.sBlockMachines) {
return false;
}
if (aBaseMetaTileEntity.getBlockOffset(xDir, y, zDir + 1) != GregTech_API.sBlockMachines) {
return false;
}
if (aBaseMetaTileEntity.getBlockOffset(xDir, y, zDir - 1) != GregTech_API.sBlockMachines) {
return false;
}
if (aBaseMetaTileEntity.getBlockOffset(xDir, y + 3, zDir) != GregTech_API.sBlockMachines) {
return false;
}
}
return true;
}
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
@Override
public int getMaxEfficiency(ItemStack aStack) {
return 10000;
}
@Override
public int getPollutionPerTick(ItemStack aStack) {
return 0;
}
@Override
public int getDamageToComponent(ItemStack aStack) {
return 0;
}
@Override
public boolean explodesOnComponentBreak(ItemStack aStack) {
return false;
}
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_OilDrill(this.mName);
}
}

View file

@ -0,0 +1,51 @@
package gregtech.common.tileentities.machines.multi;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public class GT_MetaTileEntity_OilDrill1 extends GT_MetaTileEntity_OilDrillBase {
public GT_MetaTileEntity_OilDrill1(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_OilDrill1(String aName) {
super(aName);
}
@Override
public String[] getDescription() {
return getDescriptionInternal("I");
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_OilDrill1(mName);
}
@Override
protected ItemList getCasingBlockItem() {
return ItemList.Casing_SolidSteel;
}
@Override
protected Materials getFrameMaterial() {
return Materials.Steel;
}
@Override
protected int getCasingTextureIndex() {
return 16;
}
@Override
protected int getRangeInChunks() {
return 1;
}
@Override
protected int getMinTier() {
return 2;
}
}

View file

@ -0,0 +1,51 @@
package gregtech.common.tileentities.machines.multi;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public class GT_MetaTileEntity_OilDrill2 extends GT_MetaTileEntity_OilDrillBase {
public GT_MetaTileEntity_OilDrill2(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_OilDrill2(String aName) {
super(aName);
}
@Override
public String[] getDescription() {
return getDescriptionInternal("II");
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_OilDrill2(mName);
}
@Override
protected ItemList getCasingBlockItem() {
return ItemList.Casing_StableTitanium;
}
@Override
protected Materials getFrameMaterial() {
return Materials.Titanium;
}
@Override
protected int getCasingTextureIndex() {
return 50;
}
@Override
protected int getRangeInChunks() {
return 3;
}
@Override
protected int getMinTier() {
return 3;
}
}

View file

@ -0,0 +1,51 @@
package gregtech.common.tileentities.machines.multi;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public class GT_MetaTileEntity_OilDrill3 extends GT_MetaTileEntity_OilDrillBase {
public GT_MetaTileEntity_OilDrill3(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_OilDrill3(String aName) {
super(aName);
}
@Override
public String[] getDescription() {
return getDescriptionInternal("III");
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GT_MetaTileEntity_OilDrill3(mName);
}
@Override
protected ItemList getCasingBlockItem() {
return ItemList.Casing_RobustTungstenSteel;
}
@Override
protected Materials getFrameMaterial() {
return Materials.TungstenSteel;
}
@Override
protected int getCasingTextureIndex() {
return 48;
}
@Override
protected int getRangeInChunks() {
return 6;
}
@Override
protected int getMinTier() {
return 4;
}
}

View file

@ -0,0 +1,152 @@
package gregtech.common.tileentities.machines.multi;
import static gregtech.api.enums.GT_Values.V;
import static gregtech.api.enums.GT_Values.VN;
import static gregtech.common.GT_UndergroundOil.undergroundOil;
import java.util.ArrayList;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_DrillerBase {
private boolean completedCycle = false;
private ArrayList<Chunk> mOilFieldChunks = new ArrayList<Chunk>();
private int mOilId = 0;
public GT_MetaTileEntity_OilDrillBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_OilDrillBase(String aName) {
super(aName);
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
aNBT.setInteger("mOilId", mOilId);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
mOilId = aNBT.getInteger("mOilId");
}
protected String[] getDescriptionInternal(String tierSuffix) {
String casings = getCasingBlockItem().get(0).getDisplayName();
return new String[]{
"Controller Block for the Oil Drilling Rig " + (tierSuffix != null ? tierSuffix : ""),
"Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)",
"3x1x3 Base of " + casings,
"1x3x1 " + casings + " pillar (Center of base)",
"1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
"1x Output Hatch (One of base casings)",
"1x Maintenance Hatch (One of base casings)",
"1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)",
"Working on " + getRangeInChunks() + " * " + getRangeInChunks() + " chunks",
"Use Programmed Circuits to ignore near exhausted oil field"};
}
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DrillingRig.png");
}
protected int getRangeInChunks(){
return 0;
}
@Override
protected boolean checkHatches() {
return !mMaintenanceHatches.isEmpty() && !mOutputHatches.isEmpty() && !mEnergyHatches.isEmpty();
}
@Override
protected void setElectricityStats() {
this.mEfficiency = getCurrentEfficiency(null);
this.mEfficiencyIncrease = 10000;
//T1 = 24; T2 = 96; T3 = 384
this.mEUt = 6 * (1 << (getMinTier() << 1));
//160 per chunk in MV
this.mMaxProgresstime = (isPickingPipes ? 80 : 640 * getRangeInChunks() * getRangeInChunks()) / (1 << getMinTier());
long voltage = getMaxInputVoltage();
long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1];
while (this.mEUt <= overclockEu) {
this.mEUt *= 4;
this.mMaxProgresstime /= 2;
}
this.mEUt = -this.mEUt;
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
}
@Override
protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead){
if (!tryLowerPipe()){
if (waitForPipes()) return false;
if (tryFillChunkList()) {
float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F;
FluidStack tFluid = pumpOil(speed);
if (tFluid != null && tFluid.amount > getTotalConfigValue()){
this.mOutputFluids = new FluidStack[]{tFluid};
return true;
}
}
isPickingPipes = true;
return true;
}
return true;
}
private boolean tryFillChunkList(){
FluidStack tFluid, tOil;
if (mOilId <= 0) {
tFluid = undergroundOil(getBaseMetaTileEntity(), -1);
if (tFluid == null) return false;
mOilId = tFluid.getFluidID();
}
tOil = new FluidStack(FluidRegistry.getFluid(mOilId), 0);
if (mOilFieldChunks.isEmpty()) {
Chunk tChunk = getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord());
int range = getRangeInChunks();
int xChunk = (tChunk.xPosition / range) * range, zChunk = (tChunk.zPosition / range) * range;
int xDir = tChunk.xPosition < 0 ? -1 : 1, zDir = tChunk.zPosition < 0 ? -1 : 1;
for (int i = 0; i < range; i++) {
for (int j = 0; j < range; j++) {
tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i * xDir, zChunk + j * zDir);
tFluid = undergroundOil(tChunk, -1);
if (tOil.isFluidEqual(tFluid))
mOilFieldChunks.add(tChunk);
}
}
}
if (mOilFieldChunks.isEmpty()) return false;
return true;
}
private FluidStack pumpOil(float speed){
if (mOilId <= 0) return null;
FluidStack tFluid, tOil;
tOil = new FluidStack(FluidRegistry.getFluid(mOilId), 0);
for (Chunk tChunk : mOilFieldChunks) {
tFluid = undergroundOil(getBaseMetaTileEntity(),speed);
if (tFluid == null) mOilFieldChunks.remove(tChunk);
if (tOil.isFluidEqual(tFluid)) tOil.amount += tFluid.amount;
}
return tOil.amount == 0 ? null : tOil;
}
}

View file

@ -1,425 +1,204 @@
package gregtech.common.tileentities.machines.multi;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.objects.ItemData;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.blocks.GT_TileEntity_Ores;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkPosition;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import static gregtech.api.enums.GT_Values.*;
public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_MultiBlockBase {
private static final ItemStack miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0);
private static final ItemStack miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0);
private static final Block miningPipeBlock = GT_Utility.getBlockFromStack(miningPipe);
private static final Block miningPipeTipBlock = GT_Utility.getBlockFromStack(miningPipeTip);
private final ArrayList<ChunkPosition> oreBlockPositions = new ArrayList<>();
private Block casingBlock;
private int casingMeta;
private int frameMeta;
private int casingTextureIndex;
private ForgeDirection back;
private int xDrill, yDrill, zDrill, xCenter, zCenter, yHead;
private boolean isPickingPipes;
public GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
initFields();
}
public GT_MetaTileEntity_OreDrillingPlantBase(String aName) {
super(aName);
initFields();
}
private void initFields() {
casingBlock = getCasingBlockItem().getBlock();
casingMeta = getCasingBlockItem().get(0).getItemDamage();
int frameId = 4096 + getFrameMaterial().mMetaItemSubID;
frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W;
casingTextureIndex = getCasingTextureIndex();
isPickingPipes = false;
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing)
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex],new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL)};
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex]};
}
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OreDrillingPlant.png");
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
aNBT.setBoolean("isPickingPipes", isPickingPipes);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
isPickingPipes = aNBT.getBoolean("isPickingPipes");
}
@Override
public boolean checkRecipe(ItemStack aStack) {
setElectricityStats();
int oldYHead = yHead;
if (!checkPipesAndSetYHead() || !isEnergyEnough()) {
stopMachine();
return false;
}
if (yHead != oldYHead) oreBlockPositions.clear();
if (isPickingPipes) {
if (tryPickPipe()) {
mOutputItems = new ItemStack[] {GT_Utility.copyAmount(1, miningPipe)};
return true;
} else {
isPickingPipes = false;
stopMachine();
return false;
}
}
putMiningPipesFromInputsInController();
if (!tryConsumeDrillingFluid()) return false;
fillMineListIfEmpty();
if (oreBlockPositions.isEmpty()) {
if (!tryLowerPipe()) {
isPickingPipes = true;
return true;
}
//new layer - fill again
fillMineListIfEmpty();
}
ChunkPosition oreBlockPos = null;
Block oreBlock = null;
while ((oreBlock == null || oreBlock == Blocks.air) && !oreBlockPositions.isEmpty()) {
oreBlockPos = oreBlockPositions.remove(0);
oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
}
if (oreBlock != null && oreBlock != Blocks.air) {
ArrayList<ItemStack> oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
mOutputItems = getOutputByDrops(oreBlockDrops);
}
return true;
}
private boolean isEnergyEnough() {
long requiredEnergy = 512 + getMaxInputVoltage() * 4;
for (GT_MetaTileEntity_Hatch_Energy energyHatch : mEnergyHatches) {
requiredEnergy -= energyHatch.getEUVar();
if (requiredEnergy <= 0) return true;
}
return false;
}
private boolean tryPickPipe() {
if (yHead == yDrill) return false;
if (checkBlockAndMeta(xCenter, yHead + 1, zCenter, miningPipeBlock, W))
getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead + 1, zCenter, miningPipeTipBlock);
getBaseMetaTileEntity().getWorld().setBlockToAir(xCenter, yHead, zCenter);
return true;
}
private void setElectricityStats() {
this.mEfficiency = getCurrentEfficiency(null);
this.mEfficiencyIncrease = 10000;
//T1 = 12; T2 = 48; T3 = 192; T4 = 768
this.mEUt = 3 * (1 << (getMinTier() << 1));
//T1 = 960; T2 = 480; T3 = 240; T4 = 120
this.mMaxProgresstime = (isPickingPipes ? 80 : 1920) / (1 << getMinTier());
long voltage = getMaxInputVoltage();
long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1];
while (this.mEUt <= overclockEu) {
this.mEUt *= 4;
this.mMaxProgresstime /= 2;
}
this.mEUt = -this.mEUt;
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
}
private ItemStack[] getOutputByDrops(ArrayList<ItemStack> oreBlockDrops) {
long voltage = getMaxInputVoltage();
ArrayList<ItemStack> outputItems = new ArrayList<>();
while (!oreBlockDrops.isEmpty()) {
ItemStack currentItem = oreBlockDrops.remove(0).copy();
if (!doUseMaceratorRecipe(currentItem)) {
multiplyStackSize(currentItem);
outputItems.add(currentItem);
continue;
}
GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, voltage, null, currentItem);
if (tRecipe == null) {
outputItems.add(currentItem);
continue;
}
for (int i = 0; i < tRecipe.mOutputs.length; i++) {
ItemStack recipeOutput = tRecipe.mOutputs[i].copy();
if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i))
multiplyStackSize(recipeOutput);
outputItems.add(recipeOutput);
}
}
return outputItems.toArray(new ItemStack[0]);
}
private boolean doUseMaceratorRecipe(ItemStack currentItem) {
ItemData itemData = GT_OreDictUnificator.getItemData(currentItem);
return itemData == null
|| itemData.mPrefix != OrePrefixes.crushed
&& itemData.mPrefix != OrePrefixes.dustImpure
&& itemData.mPrefix != OrePrefixes.dust
&& itemData.mMaterial.mMaterial != Materials.Oilsands;
}
private void multiplyStackSize(ItemStack itemStack) {
itemStack.stackSize *= getBaseMetaTileEntity().getRandomNumber(4) + 1;
}
private ArrayList<ItemStack> getBlockDrops(final Block oreBlock, int posX, int posY, int posZ) {
final int blockMeta = getBaseMetaTileEntity().getMetaID(posX, posY, posZ);
if (oreBlock.canSilkHarvest(getBaseMetaTileEntity().getWorld(), null, posX, posY, posZ, blockMeta)) {
return new ArrayList<ItemStack>() {{
add(new ItemStack(oreBlock, 1, blockMeta));
}};
} else return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, 1);
}
private boolean tryConsumeDrillingFluid() {
return depleteInput(new FluidStack(ItemList.sDrillingFluid, 2000));
}
private void putMiningPipesFromInputsInController() {
int maxPipes = miningPipe.getMaxStackSize();
if (isHasMiningPipes(maxPipes)) return;
ItemStack pipes = getStackInSlot(1);
for (ItemStack storedItem : getStoredInputs()) {
if (!storedItem.isItemEqual(miningPipe)) continue;
if (pipes == null) {
setInventorySlotContents(1, GT_Utility.copy(miningPipe));
pipes = getStackInSlot(1);
}
if (pipes.stackSize == maxPipes) break;
int needPipes = maxPipes - pipes.stackSize;
int transferPipes = storedItem.stackSize < needPipes ? storedItem.stackSize : needPipes;
pipes.stackSize += transferPipes;
storedItem.stackSize -= transferPipes;
}
updateSlots();
}
private void fillMineListIfEmpty() {
if (!oreBlockPositions.isEmpty()) return;
tryAddOreBlockToMineList(xCenter, yHead - 1, zCenter);
if (yHead == yDrill) return; //skip controller block layer
int radius = getRadiusInChunks() << 4;
for (int xOff = -radius; xOff <= radius; xOff++)
for (int zOff = -radius; zOff <= radius; zOff++)
tryAddOreBlockToMineList(xDrill + xOff, yHead, zDrill + zOff);
}
private void tryAddOreBlockToMineList(int x, int y, int z) {
Block block = getBaseMetaTileEntity().getBlock(x, y, z);
int blockMeta = getBaseMetaTileEntity().getMetaID(x, y, z);
ChunkPosition blockPos = new ChunkPosition(x, y, z);
if (oreBlockPositions.contains(blockPos)) return;
if (block instanceof GT_Block_Ores_Abstract) {
TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(x, y, z);
if (tTileEntity != null && tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural)
oreBlockPositions.add(blockPos);
} else {
ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta));
if (association != null && association.mPrefix.toString().startsWith("ore"))
oreBlockPositions.add(blockPos);
}
}
private boolean tryLowerPipe() {
if (!isHasMiningPipes()) return false;
if (yHead <= 0) return false;
if (checkBlockAndMeta(xCenter, yHead - 1, zCenter, Blocks.bedrock, W)) return false;
getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead - 1, zCenter, miningPipeTipBlock);
if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeBlock);
getBaseMetaTileEntity().decrStackSize(1, 1);
return true;
}
private boolean isHasMiningPipes() {
return isHasMiningPipes(1);
}
private boolean isHasMiningPipes(int minCount) {
ItemStack pipe = getStackInSlot(1);
return pipe != null && pipe.stackSize > minCount - 1 && pipe.isItemEqual(miningPipe);
}
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
updateCoordinates();
//check base layer
for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) {
for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) {
if (xOff == 0 && zOff == 0) continue;
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff);
if (!checkCasingBlock(xOff, 0, zOff)
&& !addMaintenanceToMachineList(tTileEntity, casingTextureIndex)
&& !addInputToMachineList(tTileEntity, casingTextureIndex)
&& !addOutputToMachineList(tTileEntity, casingTextureIndex)
&& !addEnergyInputToMachineList(tTileEntity, casingTextureIndex))
return false;
}
}
if (mMaintenanceHatches.isEmpty() || mInputHatches.isEmpty() || mOutputBusses.isEmpty() || mEnergyHatches.isEmpty()) return false;
if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) return false;
//check tower
for (int yOff = 1; yOff < 4; yOff++) {
if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ)
|| !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ)
|| !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ)
|| !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1)
|| !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1)
|| !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ))
return false;
}
return true;
}
private void updateCoordinates() {
xDrill = getBaseMetaTileEntity().getXCoord();
yDrill = getBaseMetaTileEntity().getYCoord();
zDrill = getBaseMetaTileEntity().getZCoord();
back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing());
xCenter = xDrill + back.offsetX;
zCenter = zDrill + back.offsetZ;
}
private boolean checkPipesAndSetYHead() {
yHead = yDrill - 1;
while (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeBlock, W)) yHead--; //skip pipes
//is pipe tip OR is controller layer
if (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeTipBlock, W) || ++yHead == yDrill) return true;
//pipe column is broken - try fix
getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeTipBlock);
return true;
}
private boolean checkCasingBlock(int xOff, int yOff, int zOff) {
return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta);
}
//meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation)
private boolean checkFrameBlock(int xOff, int yOff, int zOff) {
return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta);
}
private boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) {
return checkBlockAndMeta(xDrill + xOff, yDrill + yOff, zDrill + zOff, block, meta);
}
private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) {
return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta)
&& getBaseMetaTileEntity().getBlock(x, y, z) == block;
}
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
@Override
public int getMaxEfficiency(ItemStack aStack) {
return 10000;
}
@Override
public int getPollutionPerTick(ItemStack aStack) {
return 0;
}
@Override
public int getDamageToComponent(ItemStack aStack) {
return 0;
}
@Override
public boolean explodesOnComponentBreak(ItemStack aStack) {
return false;
}
protected abstract ItemList getCasingBlockItem();
protected abstract Materials getFrameMaterial();
protected abstract int getCasingTextureIndex();
protected abstract int getRadiusInChunks();
protected abstract int getMinTier();
protected String[] getDescriptionInternal(String tierSuffix) {
String casings = getCasingBlockItem().get(0).getDisplayName();
return new String[]{
"Controller Block for the Ore Drilling Plant " + (tierSuffix != null ? tierSuffix : ""),
"Size(WxHxD): 3x7x3, Controller (Front middle bottom)",
"3x1x3 Base of " + casings,
"1x3x1 " + casings + " pillar (Center of base)",
"1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
"1x Input Hatch for drilling fluid (Any bottom layer casing)",
"1x Input Bus for mining pipes (Any bottom layer casing; not necessary)",
"1x Output Bus (Any bottom layer casing)",
"1x Maintenance Hatch (Any bottom layer casing)",
"1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)",
"Radius is " + (getRadiusInChunks() << 4) + " blocks"};
}
}
package gregtech.common.tileentities.machines.multi;
import static gregtech.api.enums.GT_Values.V;
import static gregtech.api.enums.GT_Values.VN;
import java.util.ArrayList;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.ItemData;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.blocks.GT_TileEntity_Ores;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkPosition;
import net.minecraftforge.fluids.FluidStack;
public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase {
private final ArrayList<ChunkPosition> oreBlockPositions = new ArrayList<>();
public GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
public GT_MetaTileEntity_OreDrillingPlantBase(String aName) {
super(aName);
}
@Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OreDrillingPlant.png");
}
@Override
protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead){
if (yHead != oldYHead) oreBlockPositions.clear();
fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead);
if (oreBlockPositions.isEmpty()) {
if (!tryLowerPipe()) {
if (waitForPipes()) return false;
isPickingPipes = true;
return true;
}
//new layer - fill again
fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead);
}
ChunkPosition oreBlockPos = null;
Block oreBlock = null;
while ((oreBlock == null || oreBlock == Blocks.air) && !oreBlockPositions.isEmpty()) {
oreBlockPos = oreBlockPositions.remove(0);
oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
}
if (!tryConsumeDrillingFluid()) return false;
if (oreBlock != null && oreBlock != Blocks.air) {
ArrayList<ItemStack> oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
mOutputItems = getOutputByDrops(oreBlockDrops);
}
return true;
}
@Override
protected boolean checkHatches(){
return !mMaintenanceHatches.isEmpty() && !mInputHatches.isEmpty() && !mOutputBusses.isEmpty() && !mEnergyHatches.isEmpty();
}
@Override
protected void setElectricityStats() {
this.mEfficiency = getCurrentEfficiency(null);
this.mEfficiencyIncrease = 10000;
//T1 = 12; T2 = 48; T3 = 192; T4 = 768
this.mEUt = 3 * (1 << (getMinTier() << 1));
//T1 = 960; T2 = 480; T3 = 240; T4 = 120
this.mMaxProgresstime = (isPickingPipes ? 80 : 1920) / (1 << getMinTier());
long voltage = getMaxInputVoltage();
long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1];
while (this.mEUt <= overclockEu) {
this.mEUt *= 4;
this.mMaxProgresstime /= 2;
}
this.mEUt = -this.mEUt;
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
}
private ItemStack[] getOutputByDrops(ArrayList<ItemStack> oreBlockDrops) {
long voltage = getMaxInputVoltage();
ArrayList<ItemStack> outputItems = new ArrayList<>();
while (!oreBlockDrops.isEmpty()) {
ItemStack currentItem = oreBlockDrops.remove(0).copy();
if (!doUseMaceratorRecipe(currentItem)) {
multiplyStackSize(currentItem);
outputItems.add(currentItem);
continue;
}
GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, voltage, null, currentItem);
if (tRecipe == null) {
outputItems.add(currentItem);
continue;
}
for (int i = 0; i < tRecipe.mOutputs.length; i++) {
ItemStack recipeOutput = tRecipe.mOutputs[i].copy();
if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i))
multiplyStackSize(recipeOutput);
outputItems.add(recipeOutput);
}
}
return outputItems.toArray(new ItemStack[0]);
}
private boolean doUseMaceratorRecipe(ItemStack currentItem) {
ItemData itemData = GT_OreDictUnificator.getItemData(currentItem);
return itemData == null
|| itemData.mPrefix != OrePrefixes.crushed
&& itemData.mPrefix != OrePrefixes.dustImpure
&& itemData.mPrefix != OrePrefixes.dust
&& itemData.mMaterial.mMaterial != Materials.Oilsands;
}
private void multiplyStackSize(ItemStack itemStack) {
itemStack.stackSize *= getBaseMetaTileEntity().getRandomNumber(4) + 1;
}
private ArrayList<ItemStack> getBlockDrops(final Block oreBlock, int posX, int posY, int posZ) {
final int blockMeta = getBaseMetaTileEntity().getMetaID(posX, posY, posZ);
if (oreBlock.canSilkHarvest(getBaseMetaTileEntity().getWorld(), null, posX, posY, posZ, blockMeta)) {
return new ArrayList<ItemStack>() {{
add(new ItemStack(oreBlock, 1, blockMeta));
}};
} else return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, 1);
}
private boolean tryConsumeDrillingFluid() {
if (!depleteInput(new FluidStack(ItemList.sDrillingFluid, 2000))) {
mMaxProgresstime = 0;
return false;
}
return true;
}
private void fillMineListIfEmpty(int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead) {
if (!oreBlockPositions.isEmpty()) return;
tryAddOreBlockToMineList(xPipe, yHead - 1, zPipe);
if (yHead == yDrill) return; //skip controller block layer
int radius = getRadiusInChunks() << 4;
for (int xOff = -radius; xOff <= radius; xOff++)
for (int zOff = -radius; zOff <= radius; zOff++)
tryAddOreBlockToMineList(xDrill + xOff, yHead, zDrill + zOff);
}
private void tryAddOreBlockToMineList(int x, int y, int z) {
Block block = getBaseMetaTileEntity().getBlock(x, y, z);
int blockMeta = getBaseMetaTileEntity().getMetaID(x, y, z);
ChunkPosition blockPos = new ChunkPosition(x, y, z);
if (oreBlockPositions.contains(blockPos)) return;
if (block instanceof GT_Block_Ores_Abstract) {
TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(x, y, z);
if (tTileEntity != null && tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural)
oreBlockPositions.add(blockPos);
} else {
ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta));
if (association != null && association.mPrefix.toString().startsWith("ore"))
oreBlockPositions.add(blockPos);
}
}
protected abstract int getRadiusInChunks();
protected String[] getDescriptionInternal(String tierSuffix) {
String casings = getCasingBlockItem().get(0).getDisplayName();
return new String[]{
"Controller Block for the Ore Drilling Plant " + (tierSuffix != null ? tierSuffix : ""),
"Size(WxHxD): 3x7x3, Controller (Front middle bottom)",
"3x1x3 Base of " + casings,
"1x3x1 " + casings + " pillar (Center of base)",
"1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
"1x Input Hatch for drilling fluid (Any bottom layer casing)",
"1x Input Bus for mining pipes (Any bottom layer casing; not necessary)",
"1x Output Bus (Any bottom layer casing)",
"1x Maintenance Hatch (Any bottom layer casing)",
"1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)",
"Radius is " + (getRadiusInChunks() << 4) + " blocks"};
}
}

View file

@ -357,8 +357,8 @@ public class GT_Loader_MetaTileEntities implements Runnable {
GT_ModHandler.addCraftingRecipe(ItemList.Hatch_AutoMaintenance.get(1L, new Object[0]), bitsd, new Object[]{"CHC", "AMA", "CHC", 'M', ItemList.Hull_IV,'H',ItemList.Hatch_Maintenance,'A',ItemList.Robot_Arm_IV,'C',OrePrefixes.circuit.get(Materials.Master)});
ItemList.Hatch_DataAccess_EV.set(new GT_MetaTileEntity_Hatch_DataAccess(131, "hatch.dataaccess", "Data Access Hatch", 4).getStackForm(1L));
ItemList.Hatch_DataAccess_LuV.set(new GT_MetaTileEntity_Hatch_DataAccess(132, "hatch.dataaccess.adv", "Advanced Data Access Hatch", 6).getStackForm(1L));
ItemList.Hatch_DataAccess_EV.set(new GT_MetaTileEntity_Hatch_DataAccess(131, "hatch.dataaccess", "Data Access Hatch", 4).getStackForm(1L));
ItemList.Hatch_DataAccess_LuV.set(new GT_MetaTileEntity_Hatch_DataAccess(132, "hatch.dataaccess.adv", "Advanced Data Access Hatch", 6).getStackForm(1L));
GT_ModHandler.addCraftingRecipe(ItemList.Hatch_DataAccess_EV.get(1L, new Object[0]), bitsd, new Object[]{"COC", "OMO", "COC", 'M', ItemList.Hull_EV, 'O', ItemList.Tool_DataStick , 'C' ,OrePrefixes.circuit.get(Materials.Elite)});
GT_ModHandler.addCraftingRecipe(ItemList.Hatch_DataAccess_LuV.get(1L, new Object[0]), bitsd, new Object[]{"COC", "OMO", "COC", 'M', ItemList.Hull_LuV, 'O', ItemList.Tool_DataOrb , 'C' ,OrePrefixes.circuit.get(Materials.Ultimate)});
@ -1231,8 +1231,17 @@ public class GT_Loader_MetaTileEntities implements Runnable {
GT_ModHandler.addCraftingRecipe(ItemList.Seismic_Prospector.get(1L, new Object[0]), bitsd, new Object[]{"WWW", "EME", "CCC", 'M', ItemList.Hull_Steel, 'W', OrePrefixes.plateDouble.get(Materials.Steel), 'E', OrePrefixes.circuit.get(Materials.Basic), 'C', ItemList.Sensor_LV});
GT_ModHandler.addCraftingRecipe(ItemList.Seismic_Prospector_Adv.get(1L, new Object[0]), bitsd, new Object[] { "WWW", "EME", "CCC", 'M', ItemList.Hull_EV, 'W', OrePrefixes.plateDouble.get(Materials.VanadiumSteel),'E', OrePrefixes.circuit.get(Materials.Data), 'C', ItemList.Sensor_EV });
ItemList.OilDrill.set(new GT_MetaTileEntity_OilDrill(1157, "multimachine.oildrill", "Oil Drilling Rig").getStackForm(1));
GT_ModHandler.addCraftingRecipe(ItemList.OilDrill.get(1L, new Object[0]), bitsd, new Object[]{"WWW", "EME", "CCC", 'M', ItemList.Hull_MV, 'W', OrePrefixes.frameGt.get(Materials.Steel), 'E', OrePrefixes.circuit.get(Materials.Good), 'C', ItemList.Electric_Motor_MV});
ItemList.OilDrill1.set(new GT_MetaTileEntity_OilDrill1(1157, "multimachine.oildrill1", "Oil Drilling Rig").getStackForm(1));
ItemList.OilDrill2.set(new GT_MetaTileEntity_OilDrill2(133, "multimachine.oildrill2", "Oil Drilling Rig II").getStackForm(1));
ItemList.OilDrill3.set(new GT_MetaTileEntity_OilDrill3(134, "multimachine.oildrill3", "Oil Drilling Rig III").getStackForm(1));
GT_ModHandler.addCraftingRecipe(ItemList.OilDrill1.get(1L, new Object[0]), bitsd, new Object[]{"WWW", "EME", "CCC", 'M', ItemList.Hull_MV, 'W', OrePrefixes.frameGt.get(Materials.Steel), 'E', OrePrefixes.circuit.get(Materials.Good), 'C', ItemList.Electric_Motor_MV});
GT_ModHandler.addCraftingRecipe(ItemList.OilDrill1.get(1L, new Object[0]), bitsd, new Object[]{"WWW", "EME", "CCC", 'M', ItemList.OilDrill1, 'W', OrePrefixes.frameGt.get(Materials.Titanium), 'E', OrePrefixes.circuit.get(Materials.Advanced), 'C', ItemList.Electric_Motor_HV});
GT_ModHandler.addCraftingRecipe(ItemList.OilDrill1.get(1L, new Object[0]), bitsd, new Object[]{"WWW", "EME", "CCC", 'M', ItemList.OilDrill2, 'W', OrePrefixes.frameGt.get(Materials.TungstenSteel), 'E', OrePrefixes.circuit.get(Materials.Data), 'C', ItemList.Electric_Motor_EV});
ItemList.ConcreteBackfiller1.set(new GT_MetaTileEntity_ConcreteBackfiller1(135, "multimachine.concretebackfiller1", "Concrete Backfiller").getStackForm(1));
ItemList.ConcreteBackfiller2.set(new GT_MetaTileEntity_ConcreteBackfiller2(136, "multimachine.concretebackfiller3", "Advanced Concrete Backfiller").getStackForm(1));
GT_ModHandler.addCraftingRecipe(ItemList.ConcreteBackfiller1.get(1L, new Object[0]), bitsd, new Object[]{"WPW", "EME", "CQC", 'M', ItemList.Hull_MV, 'W', OrePrefixes.frameGt.get(Materials.Steel), 'E', OrePrefixes.circuit.get(Materials.Good), 'C', ItemList.Electric_Motor_MV, 'P', OrePrefixes.pipeLarge.get(Materials.Steel), 'Q', ItemList.Electric_Pump_MV});
GT_ModHandler.addCraftingRecipe(ItemList.ConcreteBackfiller2.get(1L, new Object[0]), bitsd, new Object[]{"WPW", "EME", "CQC", 'M', ItemList.ConcreteBackfiller1, 'W', OrePrefixes.frameGt.get(Materials.Titanium), 'E', OrePrefixes.circuit.get(Materials.Data), 'C', ItemList.Electric_Motor_EV, 'P', OrePrefixes.pipeLarge.get(Materials.Steel), 'Q', ItemList.Electric_Pump_EV});
ItemList.OreDrill1.set(new GT_MetaTileEntity_OreDrillingPlant1(1158, "multimachine.oredrill1", "Ore Drilling Plant").getStackForm(1));
GT_ModHandler.addCraftingRecipe(ItemList.OreDrill1.get(1L), bitsd, new Object[]{"WWW", "EME", "CCC", 'M', ItemList.Hull_EV, 'W', OrePrefixes.frameGt.get(Materials.Titanium), 'E', OrePrefixes.circuit.get(Materials.Data), 'C', ItemList.Electric_Motor_EV});