diff options
author | Dream-Master <dream-master@gmx.net> | 2016-06-21 18:50:29 +0200 |
---|---|---|
committer | Dream-Master <dream-master@gmx.net> | 2016-06-21 18:50:29 +0200 |
commit | 09add3e8ac3be54b1e6c068e87d4fb5143c6d785 (patch) | |
tree | 7b02b400788333f9ebf82081736c9c55f8ed48e8 /src/main/java/gregtech/common/tileentities/machines/multi | |
parent | b09b54435f9427332854558c42bd2c902825cbfe (diff) | |
download | GT5-Unofficial-09add3e8ac3be54b1e6c068e87d4fb5143c6d785.tar.gz GT5-Unofficial-09add3e8ac3be54b1e6c068e87d4fb5143c6d785.tar.bz2 GT5-Unofficial-09add3e8ac3be54b1e6c068e87d4fb5143c6d785.zip |
even with Blood asp experimental branch
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines/multi')
29 files changed, 5431 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java new file mode 100644 index 0000000000..f9c9f9654b --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AdvMiner2.java @@ -0,0 +1,295 @@ +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.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.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_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.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBase { + + private final ArrayList<ChunkPosition> mMineList = new ArrayList(); + private boolean completedCycle = false; + + public GT_MetaTileEntity_AdvMiner2(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_AdvMiner2(String aName) { + super(aName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Advanced Miner II", + "Size(WxHxD): 3x7x3, Controller (Front middle bottom)", + "3x1x3 Base of Solid Steel Casings", + "1x3x1 Solid Steel Casing pillar (Center of base)", + "1x3x1 Steel Frame Boxes (Each Steel pillar side and on top)", + "1x Input Hatch (Any bottom layer casing)", + "1x Output Bus (Any bottom layer casing)", + "1x Maintenance Hatch (Any bottom layer casing)", + "1x MV+ Energy Hatch (Any bottom layer casing)"}; + } + + 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_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + 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))) { + tStack.stackSize--; + if (tStack.stackSize < 1) { + tStack = null; + } + if (mInventory[1] == null) { + mInventory[1] = GT_ModHandler.getIC2Item("miningPipe", 1L); + } else { + mInventory[1].stackSize++; + } + } + + } + } + if (mInputHatches == null || mInputHatches.get(0).mFluid == null || mInputHatches.get(0).mFluid.getFluid().getID() != ItemList.sDrillingFluid.getID()) { + return false; + } + FluidStack tFluid = mInputHatches.get(0).mFluid.copy(); + if (tFluid == null) { + return false; + } + if (tFluid.amount < 100) { + return false; + } + tFluid.amount = 100; + depleteInput(tFluid); + long tVoltage = getMaxInputVoltage(); + if (getBaseMetaTileEntity().getRandomNumber(20) == 0) { + if (mMineList.isEmpty()) { + int yLevel = getYOfPumpHead(); + for (int i = -48; i < 49; i++) { + for (int f = -48; f < 49; f++) { + Block tBlock = getBaseMetaTileEntity().getBlockOffset(i, yLevel - getBaseMetaTileEntity().getYCoord(), f); + if (tBlock == GregTech_API.sBlockOres1) { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityOffset(i, yLevel - getBaseMetaTileEntity().getYCoord(), f); + if ((tTileEntity instanceof GT_TileEntity_Ores) && ((GT_TileEntity_Ores) tTileEntity).mNatural == true && !mMineList.contains(new ChunkPosition(i, yLevel - getBaseMetaTileEntity().getYCoord(), f))) { + mMineList.add(new ChunkPosition(i, yLevel - getBaseMetaTileEntity().getYCoord(), f)); + } + } + } + } + } + if (mMineList.isEmpty()) { + if(getBaseMetaTileEntity().getBlockOffset(ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX, getYOfPumpHead() - 1 - getBaseMetaTileEntity().getYCoord(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ) != Blocks.bedrock){ + if (mEnergyHatches.size() > 0 && mEnergyHatches.get(0).getEUVar() > (512 + getMaxInputVoltage() * 4)) { + moveOneDown(); + } + }else{return false;} + } + ArrayList<ItemStack> tDrops = new ArrayList(); + if (!mMineList.isEmpty()) { + ChunkPosition oreBlockOffsetPos = mMineList.get(0); + tDrops = ((GT_TileEntity_Ores) getBaseMetaTileEntity().getTileEntityOffset(oreBlockOffsetPos.chunkPosX, oreBlockOffsetPos.chunkPosY, oreBlockOffsetPos.chunkPosZ)).getDrops(1); + if (!tDrops.isEmpty()) { + ItemData tData = GT_OreDictUnificator.getItemData(tDrops.get(0).copy()); + if (tData.mPrefix != OrePrefixes.crushed&& tData.mMaterial.mMaterial != Materials.Oilsands) { + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, tVoltage, null, tDrops.get(0).copy()); + if (tRecipe != null) { + this.mOutputItems = new ItemStack[tRecipe.mOutputs.length]; + for (int g = 0; g < mOutputItems.length; g++) { + mOutputItems[g] = tRecipe.mOutputs[g].copy(); + mOutputItems[g].stackSize = mOutputItems[g].stackSize * (getBaseMetaTileEntity().getRandomNumber(4) + 1); + } + } + } else { + this.mOutputItems = null; + ItemStack[] tStack = new ItemStack[tDrops.size()]; + for (int j = 0; j < tDrops.size(); j++) { + tStack[j] = tDrops.get(j).copy(); + tStack[j].stackSize = tStack[j].stackSize * (getBaseMetaTileEntity().getRandomNumber(4) + 1); + } + mOutputItems = tStack; + } + } + getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockOffsetPos.chunkPosX + getBaseMetaTileEntity().getXCoord(), oreBlockOffsetPos.chunkPosY + getBaseMetaTileEntity().getYCoord(), oreBlockOffsetPos.chunkPosZ + getBaseMetaTileEntity().getZCoord()); + mMineList.remove(0); + } + } + + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + int tEU = 48; + int tDuration = 24; + 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); + 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 <= 0) { + 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 int getAmountOfOutputs() { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_AdvMiner2(this.mName); + } + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java new file mode 100644 index 0000000000..e4a7d0dff5 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -0,0 +1,230 @@ +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.Arrays; + +public class GT_MetaTileEntity_AssemblyLine + extends GT_MetaTileEntity_MultiBlockBase { + 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(2-16)x4, variable length", + "Bottom: Steel Casing(or Maintenance or Input Hatch), Input Bus(Last Output Bus), Steel Casing", + "Middle: Reinforced Glass, Assembling Line, Reinforced Glass", + "UpMiddle: Grate Casing(or Controller), Assembling Casing, Grate Casing", + "Top: Steel Casing(or Energy Hatch)", + "Up to 16 repeating slices, last is Output Bus"}; + } + + 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_IMPLOSION_COMPRESSOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR)}; + } + 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(), "ImplosionCompressor.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sImplosionRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sAssemblylineRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + 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.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots(); + return true; + } + } + return false; + } + + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) 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; + + if(i!=0&&aBaseMetaTileEntity.getBlockOffset(0, 0, i)!=GregTech_API.sBlockCasings3&&aBaseMetaTileEntity.getMetaIDOffset(0, 0, i)!=10){return false;} + if(!aBaseMetaTileEntity.getBlockOffset(0, -1, i).getUnlocalizedName().equals("blockAlloyGlass")){return false;} + IGregTechTileEntity 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)){ + if (!addOutputToMachineList(tTileEntity, 16)){;return false; + }else{if(r>0){return true;}else{return false;}} + } + } + }else{ + for(int r = 0; r <= 16; r++){ + int i = r*-zDir; + + if(i!=0&&aBaseMetaTileEntity.getBlockOffset(i, 0, 0)!=GregTech_API.sBlockCasings3&&aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0)!=10){return false;} + if(!aBaseMetaTileEntity.getBlockOffset(i, -1, 0).getUnlocalizedName().equals("blockAlloyGlass")){return false;} + IGregTechTileEntity 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)){ + if (!addOutputToMachineList(tTileEntity, 16)){ + }else{if(r>0){return true;}else{return false;}} + } + } + } + return false; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 1000; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 2; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java new file mode 100644 index 0000000000..5d17de69d4 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java @@ -0,0 +1,345 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.common.gui.GT_Container_BronzeBlastFurnace; +import gregtech.common.gui.GT_GUIContainer_BronzeBlastFurnace; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class GT_MetaTileEntity_BronzeBlastFurnace + extends MetaTileEntity { + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE)}; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE_ACTIVE)}; + public int mMaxProgresstime = 0; + public int mUpdate = 5; + public int mProgresstime = 0; + public boolean mMachine = false; + public ItemStack mOutputItem1; + public ItemStack mOutputItem2; + + public GT_MetaTileEntity_BronzeBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 4); + } + + public GT_MetaTileEntity_BronzeBlastFurnace(String aName) { + super(aName, 4); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Bronze Blast Furnace", + "How to get your first Steel", + "Size(WxHxD): 3x4x3 (Hollow, with opening on top)", + "Bronze Plated Bricks for the rest (32 at least!)"}; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return aActive ? FACING_ACTIVE : FACING_FRONT; + } + return FACING_SIDE; + } + + public boolean isSteampowered() { + return false; + } + + public boolean isElectric() { + return false; + } + + public boolean isPneumatic() { + return false; + } + + public boolean isEnetInput() { + return false; + } + + public boolean isEnetOutput() { + return false; + } + + public boolean isInputFacing(byte aSide) { + return false; + } + + public boolean isOutputFacing(byte aSide) { + return false; + } + + public boolean isTeleporterCompatible() { + return false; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public int getProgresstime() { + return this.mProgresstime; + } + + public int maxProgresstime() { + return this.mMaxProgresstime; + } + + public int increaseProgress(int aProgress) { + this.mProgresstime += aProgress; + return this.mMaxProgresstime - this.mProgresstime; + } + + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_BronzeBlastFurnace(this.mName); + } + + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mProgresstime", this.mProgresstime); + aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); + if (this.mOutputItem1 != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem1.writeToNBT(tNBT); + aNBT.setTag("mOutputItem1", tNBT); + } + if (this.mOutputItem2 != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem2.writeToNBT(tNBT); + aNBT.setTag("mOutputItem2", tNBT); + } + } + + public void loadNBTData(NBTTagCompound aNBT) { + this.mUpdate = 5; + this.mProgresstime = aNBT.getInteger("mProgresstime"); + this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); + this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_BronzeBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_BronzeBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + private boolean checkMachine() { + int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 3; j++) { + for (int k = -1; k < 2; k++) { + if ((xDir + i != 0) || (j != 0) || (zDir + k != 0)) { + if ((i != 0) || (j == -1) || (k != 0)) { + if ((getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) != GregTech_API.sBlockCasings1) || (getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) { + return false; + } + } else if ((!GT_Utility.arrayContains(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[]{Blocks.lava, Blocks.flowing_lava, null})) && (!getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { + return false; + } + } + } + } + } + return true; + } + + public void onMachineBlockUpdate() { + this.mUpdate = 5; + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if ((aBaseMetaTileEntity.isClientSide()) && + (aBaseMetaTileEntity.isActive())) { + aBaseMetaTileEntity.getWorld().spawnParticle("largesmoke", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, 0.0D); + } + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate-- == 0) { + this.mMachine = checkMachine(); + } + if (this.mMachine) { + if (this.mMaxProgresstime > 0) { + if (++this.mProgresstime >= this.mMaxProgresstime) { + addOutputProducts(); + this.mOutputItem1 = null; + this.mOutputItem2 = null; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + try { + GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel"); + } catch (Exception e) { + } + } + } else if (aBaseMetaTileEntity.isAllowedToWork()) { + checkRecipe(); + } + } + aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); + if (aBaseMetaTileEntity.isActive()) { + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); + this.mUpdate = 1; + } + } else { + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); + this.mUpdate = 1; + } + } + } + } + + private void addOutputProducts() { + if (this.mOutputItem1 != null) { + if (this.mInventory[2] == null) { + this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1}); + } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { + this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize); + } + } + if (this.mOutputItem2 != null) { + if (this.mInventory[3] == null) { + this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2}); + } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { + this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize); + } + } + } + + private boolean spaceForOutput(ItemStack aStack1, ItemStack aStack2) { + if (((this.mInventory[2] == null) || (aStack1 == null) || ((this.mInventory[2].stackSize + aStack1.stackSize <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && ( + (this.mInventory[3] == null) || (aStack2 == null) || ((this.mInventory[3].stackSize + aStack2.stackSize <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { + return true; + } + return false; + } + + private boolean checkRecipe() { + if (!this.mMachine) { + return false; + } + if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 4); + this.mMaxProgresstime = 7200; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 2); + this.mMaxProgresstime = 4800; + return true; + } + if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 9); + getBaseMetaTileEntity().decrStackSize(1, 4); + this.mMaxProgresstime = 64800; + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 2); + this.mMaxProgresstime = 3600; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 1); + this.mMaxProgresstime = 2400; + return true; + } + if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 9); + getBaseMetaTileEntity().decrStackSize(1, 2); + this.mMaxProgresstime = 32400; + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 36); + this.mMaxProgresstime = 64800; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 18); + this.mMaxProgresstime = 43200; + return true; + } + if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 4); + this.mMaxProgresstime = 64800; + return true; + } + } + } + this.mOutputItem1 = null; + this.mOutputItem2 = null; + return false; + } + + public boolean isGivingInformation() { + return false; + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex > 1; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aIndex < 2) { + } + return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); + } + + public byte getTileEntityBaseType() { + return 0; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java new file mode 100644 index 0000000000..24394ddd98 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Charcoal_Pit.java @@ -0,0 +1,222 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.OrePrefixes; +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_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.world.ChunkPosition; + +import java.util.ArrayList; + +public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlockBase { + + private boolean running = false; + private boolean p1, p2, p3, p4, p5, p6; + + public GT_MetaTileEntity_Charcoal_Pit(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_Charcoal_Pit(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Charcoal_Pit(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller for the Charcoal Pit", + "Converts Logs into Brittle Charcoal blocks", + "Max Size(WxHxD): 11x6x11, Controller (Top layer, centered)", + "11x1x11 of Bricks (Bottom layer only)", + "11x5x11 of Logs (Above bottom Brick layer)", + "Only grass/dirt can touch Log blocks", + "No air between logs allowed"}; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == 1) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[10], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[10]}; + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + + return true; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + if (!checkRecursiveBlocks()) { + return false; + } + + if (mEfficiency == 0) { + this.mEfficiency = 10000; + this.mEfficiencyIncrease = 10000; + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + return true; + } else { + this.mEfficiency = 0; + this.mEfficiencyIncrease = 0; + this.mMaxProgresstime = 0; + } + return false; + } + + private boolean checkRecursiveBlocks() { + ArrayList<ChunkPosition> tList1 = new ArrayList(); + ArrayList<ChunkPosition> tList2 = new ArrayList(); + + Block tBlock = this.getBaseMetaTileEntity().getBlockOffset(0, -1, 0); + if (!isWoodLog(tBlock)) { + return false; + } else { + tList2.add(new ChunkPosition(0, -1, 0)); + } + while (!tList2.isEmpty()) { + ChunkPosition tPos = (ChunkPosition) tList2.get(0); + tList2.remove(0); + if (!checkAllBlockSides(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ, tList1, tList2)) { + return false; + } + } + if (running) { + for (ChunkPosition tPos : tList1) { + if (isWoodLog(this.getBaseMetaTileEntity().getBlockOffset(tPos.chunkPosX, tPos.chunkPosY, tPos.chunkPosZ))) + this.getBaseMetaTileEntity().getWorld().setBlock(this.getBaseMetaTileEntity().getXCoord() + tPos.chunkPosX, this.getBaseMetaTileEntity().getYCoord() + tPos.chunkPosY, this.getBaseMetaTileEntity().getZCoord() + tPos.chunkPosZ, GregTech_API.sBlockReinforced, 4, 3); + } + running = false; + return false; + } else { + this.mMaxProgresstime = (int) Math.sqrt(tList1.size() * 240000); + } + running = true; + return true; + } + + private boolean checkAllBlockSides(int aX, int aY, int aZ, ArrayList<ChunkPosition> aList1, ArrayList<ChunkPosition> aList2) { + p1 = false; + p2 = false; + p3 = false; + p4 = false; + p5 = false; + p6 = false; + Block tBlock = this.getBaseMetaTileEntity().getBlockOffset(aX + 1, aY, aZ); + if (aX + 1 < 6 && (isWoodLog(tBlock))) { + if (!aList1.contains(new ChunkPosition(aX + 1, aY, aZ)) && (!aList2.contains(new ChunkPosition(aX + 1, aY, aZ)))) + p1 = true; + } else if (!(tBlock == Blocks.dirt || tBlock == Blocks.grass)) { + return false; + } + + tBlock = this.getBaseMetaTileEntity().getBlockOffset(aX - 1, aY, aZ); + if (aX - 1 > -6 && (isWoodLog(tBlock))) { + if (!aList1.contains(new ChunkPosition(aX - 1, aY, aZ)) && (!aList2.contains(new ChunkPosition(aX - 1, aY, aZ)))) + p2 = true; + } else if (!(tBlock == Blocks.dirt || tBlock == Blocks.grass)) { + return false; + } + + tBlock = this.getBaseMetaTileEntity().getBlockOffset(aX, aY + 1, aZ); + if (aY + 1 < 1 && (isWoodLog(tBlock))) { + if (!aList1.contains(new ChunkPosition(aX, aY + 1, aZ)) && (!aList2.contains(new ChunkPosition(aX, aY + 1, aZ)))) + p3 = true; + } else if (!(tBlock == Blocks.dirt || tBlock == Blocks.grass || (aX == 0 && aY == -1 && aZ == 0 && tBlock == GregTech_API.sBlockMachines))) { + return false; + } + + tBlock = this.getBaseMetaTileEntity().getBlockOffset(aX, aY - 1, aZ); + if (aY - 1 > -6 && (isWoodLog(tBlock))) { + if (!aList1.contains(new ChunkPosition(aX, aY - 1, aZ)) && (!aList2.contains(new ChunkPosition(aX, aY - 1, aZ)))) + p4 = true; + } else if (tBlock != Blocks.brick_block) { + return false; + } + + tBlock = this.getBaseMetaTileEntity().getBlockOffset(aX, aY, aZ + 1); + if (aZ + 1 < 6 && (isWoodLog(tBlock))) { + if (!aList1.contains(new ChunkPosition(aX, aY, aZ + 1)) && (!aList2.contains(new ChunkPosition(aX, aY, aZ + 1)))) + p5 = true; + } else if (!(tBlock == Blocks.dirt || tBlock == Blocks.grass)) { + return false; + } + + tBlock = this.getBaseMetaTileEntity().getBlockOffset(aX, aY, aZ - 1); + if (aZ - 1 > -6 && (isWoodLog(tBlock))) { + if (!aList1.contains(new ChunkPosition(aX, aY, aZ - 1)) && (!aList2.contains(new ChunkPosition(aX, aY, aZ - 1)))) + p6 = true; + } else if (!(tBlock == Blocks.dirt || tBlock == Blocks.grass)) { + return false; + } + aList1.add(new ChunkPosition(aX, aY, aZ)); + if (p1) aList2.add(new ChunkPosition(aX + 1, aY, aZ)); + if (p2) aList2.add(new ChunkPosition(aX - 1, aY, aZ)); + if (p3) aList2.add(new ChunkPosition(aX, aY + 1, aZ)); + if (p4) aList2.add(new ChunkPosition(aX, aY - 1, aZ)); + if (p5) aList2.add(new ChunkPosition(aX, aY, aZ + 1)); + if (p6) aList2.add(new ChunkPosition(aX, aY, aZ - 1)); + return true; + } + + public boolean isWoodLog(Block log){ + String tTool = log.getHarvestTool(0); + return OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe"))) || (log.getMaterial() == Material.wood); + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + return true; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 1; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java new file mode 100644 index 0000000000..4dee3d7584 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DieselEngine.java @@ -0,0 +1,246 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +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.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +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.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.Collection; + +public class GT_MetaTileEntity_DieselEngine extends GT_MetaTileEntity_MultiBlockBase { + protected int fuelConsumption = 0; + protected int fuelValue = 0; + protected int fuelRemaining = 0; + protected boolean boostEu = false; + + public GT_MetaTileEntity_DieselEngine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + public GT_MetaTileEntity_DieselEngine(String aName) { + super(aName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Large Diesel Engine", + "Size(WxHxD): 3x3x4, Controller (front centered)", + "3x3x4 of Stable Titanium Casing (hollow, Min 24!)", + "2x Titanium Pipe Casing Block inside the Hollow Casing", + "1x Input Hatch (one of the Casings)", + "1x Maintenance Hatch (one of the Casings)", + "1x Muffler Hatch (top middle back)", + "1x Dynamo Hatch (back centered)", + "Engine Intake Casings not obstructed (only air blocks)"}; + } + + 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[50], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[50]}; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeDieselEngine.png"); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<FluidStack> tFluids = getStoredFluids(); + Collection<GT_Recipe> tRecipeList = GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList; + + if(tFluids.size() > 0 && tRecipeList != null) { //Does input hatch have a diesel fuel? + for (FluidStack hatchFluid1 : tFluids) { //Loops through hatches + for(GT_Recipe aFuel : tRecipeList) { //Loops through diesel fuel recipes + FluidStack tLiquid; + if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null) { //Create fluidstack from current recipe + if (hatchFluid1.isFluidEqual(tLiquid)) { //Has a diesel fluid + if(tFluids.contains(Materials.Oxygen.getGas(1L))) { //Has oxygen? + if(depleteInput(Materials.Oxygen.getGas((8192 / aFuel.mSpecialValue) / 4))) boostEu = true; + } else boostEu = false; + + if(tFluids.contains(Materials.Lubricant.getFluid(1L))) { //Has lubricant? + //Deplete Lubricant. 1000L should = 1 hour of runtime (if baseEU = 2048) + if(mRuntime % 72 == 0 || mRuntime == 0) depleteInput(Materials.Lubricant.getFluid(boostEu ? 4 : 1)); + } else return false; + + fuelConsumption = tLiquid.amount = boostEu ? 8192 / aFuel.mSpecialValue : 2048 / aFuel.mSpecialValue; //Calc fuel consumption + if(depleteInput(tLiquid)) { //Deplete that amount + fuelValue = aFuel.mSpecialValue; + fuelRemaining = hatchFluid1.amount; //Record available fuel + this.mEUt = mEfficiency < 2000 ? 0 : (int) (2048 * ((float) mEfficiency / 10000)); //Output 0 if startup is less than 20% + this.mProgresstime = 1; + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 50; + return true; + } + } + } + } + } + } + this.mEUt = 0; + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + byte tSide = getBaseMetaTileEntity().getBackFacing(); + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); + + if(getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 1) != getGearboxBlock() && getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 2) != getGearboxBlock()) { + return false; + } + if(getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 1) != getGearboxMeta() && getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 2) != getGearboxMeta()) { + return false; + } + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 4; k = (byte) (k + 1)) { + Block frontAir = getBaseMetaTileEntity().getBlock(tX - (tSide == 5 ? 1 : tSide == 4 ? -1 : i), tY + j, tZ - (tSide == 2 ? -1 : tSide == 3 ? 1 : i)); + if(!(frontAir.getUnlocalizedName().equalsIgnoreCase("tile.air") || frontAir.getUnlocalizedName().equalsIgnoreCase("tile.railcraft.residual.heat"))) { + return false; //Fail if vent blocks are obstructed + } + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2))) { + if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } else if (!addMufflerToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? 2 : tSide == 4 ? -2 : 0), tY + 1, tZ + (tSide == 3 ? 2 : tSide == 2 ? -2 : 0)), getCasingTextureIndex())) { + return false; //Fail if no muffler top middle back + } else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)))) { + return false; + } + } else if (k == 0) { + if(!(getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getIntakeBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getIntakeMeta())) { + return false; + } + } else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } else { + return false; + } + } + } + } + } + this.mDynamoHatches.clear(); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { + this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { + return false; + } + } + return true; + } + + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getCasingMeta() { + return 2; + } + + public Block getIntakeBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getIntakeMeta() { + return 13; + } + + public Block getGearboxBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getGearboxMeta() { + return 4; + } + + public byte getCasingTextureIndex() { + return 50; + } + + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_DieselEngine(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + return boostEu ? 40000 : 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + "Diesel Engine", + "Current Output: "+mEUt+" EU/t", + "Fuel Consumption: "+fuelConsumption+"L/t", + "Fuel Value: "+fuelValue+" EU/mb", + "Fuel Remaining: "+fuelRemaining+" Litres", + "Current Efficiency: "+(mEfficiency/100)+"%"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java new file mode 100644 index 0000000000..d1274c0cc0 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java @@ -0,0 +1,206 @@ +package gregtech.common.tileentities.machines.multi; + +import java.util.ArrayList; +import java.util.Arrays; + +import org.apache.commons.lang3.ArrayUtils; + +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_Hatch_Output; +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.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_DistillationTower + extends GT_MetaTileEntity_MultiBlockBase { + private static boolean controller; + + public GT_MetaTileEntity_DistillationTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_DistillationTower(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_DistillationTower(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Distillation Tower", + "Size(WxHxD): 3x6x3 (Hollow), Controller (Front bottom)", + "1x Input Hatch (Any bottom layer casing)", + "5x Output Hatch (Any casing besides bottom layer)", + "1x Output Bus (Any bottom layer casing)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Clean Stainless Steel Casings for the rest (26 at least!)"}; + } + + 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[49], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[49]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DistillationTower.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sDistillationRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, tFluidList.size()); + if (tFluids.length > 0) { + for(int i = 0;i<tFluids.length;i++){ + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sDistillationRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tFluids[i]}, new ItemStack[]{}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[]{})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + 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.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + this.mOutputFluids = tRecipe.mFluidOutputs.clone(); + ArrayUtils.reverse(mOutputFluids); + updateSlots(); + return true; + } + } + } + } + + return false; + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + int tAmount = 0; + controller = false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 6; h++) { + if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) + { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 49)) && (!addInputToMachineList(tTileEntity, 49)) && (!addOutputToMachineList(tTileEntity, 49)) && (!addEnergyInputToMachineList(tTileEntity, 49)) && (!ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings4) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { + return false; + } + tAmount++; + } + } + } + } + } + if (this.mOutputBusses.size() != 1 || this.mInputBusses.size() != 0 || this.mOutputHatches.size() != 5) { + return false; + } + int height = this.getBaseMetaTileEntity().getYCoord(); + if (this.mInputHatches.get(0).getBaseMetaTileEntity().getYCoord() != height || this.mOutputBusses.get(0).getBaseMetaTileEntity().getYCoord() != height) { + return false; + } + GT_MetaTileEntity_Hatch_Output[] tmpHatches = new GT_MetaTileEntity_Hatch_Output[5]; + for (int i = 0; i < this.mOutputHatches.size(); i++) { + int hatchNumber = this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; + if (tmpHatches[hatchNumber] == null) { + tmpHatches[hatchNumber] = this.mOutputHatches.get(i); + } else { + return false; + } + } + this.mOutputHatches.clear(); + for (int i = 0; i < tmpHatches.length; i++) { + this.mOutputHatches.add(tmpHatches[i]); + } + return tAmount >= 26; + } + + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; + } + return false; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 1; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java new file mode 100644 index 0000000000..c3139a9b92 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -0,0 +1,222 @@ +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.Arrays; + +public class GT_MetaTileEntity_ElectricBlastFurnace + extends GT_MetaTileEntity_MultiBlockBase { + private int mHeatingCapacity = 0; + + public GT_MetaTileEntity_ElectricBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_ElectricBlastFurnace(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ElectricBlastFurnace(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Blast Furnace", + "Size(WxHxD): 3x4x3 (Hollow), Controller (Front middle bottom)", + "16x Heating Coils (Two middle Layers, hollow)", + "1x Input (Any bottom layer casing)", + "1x Output (Any bottom layer casing)", + "1x Energy Hatch (Any bottom layer casing)", + "1x Maintenance Hatch (Any bottom layer casing)", + "1x Muffler Hatch (Top middle)", + "Heat Proof Machine Casings for the rest"}; + } + + 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[11], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[11]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "ElectricBlastFurnace.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBlastRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBlastRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (this.mHeatingCapacity >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + 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.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots(); + return true; + } + } + return false; + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + this.mHeatingCapacity = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + if (!aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir)) { + return false; + } + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), 11); + + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); + switch (tUsedMeta) { + case 12: + this.mHeatingCapacity = 1800; + break; + case 13: + this.mHeatingCapacity = 2700; + break; + case 14: + this.mHeatingCapacity = 3600; + break; + default: + return false; + } + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 11) { + return false; + } + } + } + } + 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, 11)) && (!addInputToMachineList(tTileEntity, 11)) && (!addOutputToMachineList(tTileEntity, 11)) && (!addEnergyInputToMachineList(tTileEntity, 11))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 11) { + return false; + } + } + } + } + } + this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); + return true; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 10; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 2; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java new file mode 100644 index 0000000000..7d950a490b --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer.java @@ -0,0 +1,467 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.GT_Mod; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_MultiMachine; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.gui.GT_GUIContainer_FusionReactor; +import net.minecraft.block.Block; +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; + +import java.util.ArrayList; + +public abstract class GT_MetaTileEntity_FusionComputer extends GT_MetaTileEntity_MultiBlockBase { + + public GT_Recipe mLastRecipe; + public int mEUStore; + + public GT_MetaTileEntity_FusionComputer(int aID, String aName, String aNameRegional, int tier) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_FusionComputer(String aName) { + super(aName); + } + + public abstract int tier(); + + public abstract long maxEUStore(); + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_FusionReactor(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "FusionComputer.png", GT_Recipe.GT_Recipe_Map.sFusionRecipes.mNEIName); + } + + public abstract MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity); + + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { + + return aSide != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xCenter = getBaseMetaTileEntity().getXCoord() + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX * 5; + int yCenter = getBaseMetaTileEntity().getYCoord(); + int zCenter = getBaseMetaTileEntity().getZCoord() + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ * 5; + if (((isAdvancedMachineCasing(xCenter + 5, yCenter, zCenter)) || (xCenter + 5 == getBaseMetaTileEntity().getXCoord())) + && ((isAdvancedMachineCasing(xCenter - 5, yCenter, zCenter)) || (xCenter - 5 == getBaseMetaTileEntity().getXCoord())) + && ((isAdvancedMachineCasing(xCenter, yCenter, zCenter + 5)) || (zCenter + 5 == getBaseMetaTileEntity().getZCoord())) + && ((isAdvancedMachineCasing(xCenter, yCenter, zCenter - 5)) || (zCenter - 5 == getBaseMetaTileEntity().getZCoord())) && (checkCoils(xCenter, yCenter, zCenter)) + && (checkHulls(xCenter, yCenter, zCenter)) && (checkUpperOrLowerHulls(xCenter, yCenter + 1, zCenter)) && (checkUpperOrLowerHulls(xCenter, yCenter - 1, zCenter)) + && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter + 3, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter - 3, aBaseMetaTileEntity)) + && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter + 5, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter + 4, yCenter, zCenter - 5, aBaseMetaTileEntity)) + && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter + 3, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter - 3, aBaseMetaTileEntity)) + && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter + 5, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 4, yCenter, zCenter - 5, aBaseMetaTileEntity)) + && (addIfEnergyInjector(xCenter + 3, yCenter, zCenter + 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 3, yCenter, zCenter + 4, aBaseMetaTileEntity)) + && (addIfEnergyInjector(xCenter + 5, yCenter, zCenter + 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 5, yCenter, zCenter + 4, aBaseMetaTileEntity)) + && (addIfEnergyInjector(xCenter + 3, yCenter, zCenter - 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 3, yCenter, zCenter - 4, aBaseMetaTileEntity)) + && (addIfEnergyInjector(xCenter + 5, yCenter, zCenter - 4, aBaseMetaTileEntity)) && (addIfEnergyInjector(xCenter - 5, yCenter, zCenter - 4, aBaseMetaTileEntity)) + && (addIfExtractor(xCenter + 1, yCenter, zCenter - 5, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 1, yCenter, zCenter + 5, aBaseMetaTileEntity)) + && (addIfExtractor(xCenter - 1, yCenter, zCenter - 5, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 1, yCenter, zCenter + 5, aBaseMetaTileEntity)) + && (addIfExtractor(xCenter + 1, yCenter, zCenter - 7, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 1, yCenter, zCenter + 7, aBaseMetaTileEntity)) + && (addIfExtractor(xCenter - 1, yCenter, zCenter - 7, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 1, yCenter, zCenter + 7, aBaseMetaTileEntity)) + && (addIfExtractor(xCenter + 5, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 5, yCenter, zCenter + 1, aBaseMetaTileEntity)) + && (addIfExtractor(xCenter - 5, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 5, yCenter, zCenter + 1, aBaseMetaTileEntity)) + && (addIfExtractor(xCenter + 7, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter + 7, yCenter, zCenter + 1, aBaseMetaTileEntity)) + && (addIfExtractor(xCenter - 7, yCenter, zCenter - 1, aBaseMetaTileEntity)) && (addIfExtractor(xCenter - 7, yCenter, zCenter + 1, aBaseMetaTileEntity)) + && (addIfInjector(xCenter + 1, yCenter + 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 1, yCenter + 1, zCenter + 6, aBaseMetaTileEntity)) + && (addIfInjector(xCenter - 1, yCenter + 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter - 1, yCenter + 1, zCenter + 6, aBaseMetaTileEntity)) + && (addIfInjector(xCenter - 6, yCenter + 1, zCenter + 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter + 1, zCenter + 1, aBaseMetaTileEntity)) + && (addIfInjector(xCenter - 6, yCenter + 1, zCenter - 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter + 1, zCenter - 1, aBaseMetaTileEntity)) + && (addIfInjector(xCenter + 1, yCenter - 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 1, yCenter - 1, zCenter + 6, aBaseMetaTileEntity)) + && (addIfInjector(xCenter - 1, yCenter - 1, zCenter - 6, aBaseMetaTileEntity)) && (addIfInjector(xCenter - 1, yCenter - 1, zCenter + 6, aBaseMetaTileEntity)) + && (addIfInjector(xCenter - 6, yCenter - 1, zCenter + 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter - 1, zCenter + 1, aBaseMetaTileEntity)) + && (addIfInjector(xCenter - 6, yCenter - 1, zCenter - 1, aBaseMetaTileEntity)) && (addIfInjector(xCenter + 6, yCenter - 1, zCenter - 1, aBaseMetaTileEntity)) + && (this.mEnergyHatches.size() >= 1) && (this.mOutputHatches.size() >= 1) && (this.mInputHatches.size() >= 2)) { + if (this.mEnergyHatches != null) { + for (int i = 0; i < this.mEnergyHatches.size(); i++) { + if (this.mEnergyHatches.get(i).mTier < tier()) + return false; + } + } + if (this.mOutputHatches != null) { + for (int i = 0; i < this.mOutputHatches.size(); i++) { + if (this.mOutputHatches.get(i).mTier < tier()) + return false; + } + } + if (this.mInputHatches != null) { + for (int i = 0; i < this.mInputHatches.size(); i++) { + if (this.mInputHatches.get(i).mTier < tier()) + return false; + } + } + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + return true; + } + return false; + } + + private boolean checkTier(byte tier, ArrayList<GT_MetaTileEntity_Hatch> list) { + if (list != null) { + for (int i = 0; i < list.size(); i++) { + if (list.get(i).mTier < tier) { + return false; + } + } + } + return true; + } + + private boolean checkCoils(int aX, int aY, int aZ) { + return (isFusionCoil(aX + 6, aY, aZ - 1)) && (isFusionCoil(aX + 6, aY, aZ)) && (isFusionCoil(aX + 6, aY, aZ + 1)) && (isFusionCoil(aX + 5, aY, aZ - 3)) && (isFusionCoil(aX + 5, aY, aZ - 2)) + && (isFusionCoil(aX + 5, aY, aZ + 2)) && (isFusionCoil(aX + 5, aY, aZ + 3)) && (isFusionCoil(aX + 4, aY, aZ - 4)) && (isFusionCoil(aX + 4, aY, aZ + 4)) + && (isFusionCoil(aX + 3, aY, aZ - 5)) && (isFusionCoil(aX + 3, aY, aZ + 5)) && (isFusionCoil(aX + 2, aY, aZ - 5)) && (isFusionCoil(aX + 2, aY, aZ + 5)) + && (isFusionCoil(aX + 1, aY, aZ - 6)) && (isFusionCoil(aX + 1, aY, aZ + 6)) && (isFusionCoil(aX, aY, aZ - 6)) && (isFusionCoil(aX, aY, aZ + 6)) && (isFusionCoil(aX - 1, aY, aZ - 6)) + && (isFusionCoil(aX - 1, aY, aZ + 6)) && (isFusionCoil(aX - 2, aY, aZ - 5)) && (isFusionCoil(aX - 2, aY, aZ + 5)) && (isFusionCoil(aX - 3, aY, aZ - 5)) + && (isFusionCoil(aX - 3, aY, aZ + 5)) && (isFusionCoil(aX - 4, aY, aZ - 4)) && (isFusionCoil(aX - 4, aY, aZ + 4)) && (isFusionCoil(aX - 5, aY, aZ - 3)) + && (isFusionCoil(aX - 5, aY, aZ - 2)) && (isFusionCoil(aX - 5, aY, aZ + 2)) && (isFusionCoil(aX - 5, aY, aZ + 3)) && (isFusionCoil(aX - 6, aY, aZ - 1)) + && (isFusionCoil(aX - 6, aY, aZ)) && (isFusionCoil(aX - 6, aY, aZ + 1)); + } + + private boolean checkUpperOrLowerHulls(int aX, int aY, int aZ) { + return (isAdvancedMachineCasing(aX + 6, aY, aZ)) && (isAdvancedMachineCasing(aX + 5, aY, aZ - 3)) && (isAdvancedMachineCasing(aX + 5, aY, aZ - 2)) + && (isAdvancedMachineCasing(aX + 5, aY, aZ + 2)) && (isAdvancedMachineCasing(aX + 5, aY, aZ + 3)) && (isAdvancedMachineCasing(aX + 4, aY, aZ - 4)) + && (isAdvancedMachineCasing(aX + 4, aY, aZ + 4)) && (isAdvancedMachineCasing(aX + 3, aY, aZ - 5)) && (isAdvancedMachineCasing(aX + 3, aY, aZ + 5)) + && (isAdvancedMachineCasing(aX + 2, aY, aZ - 5)) && (isAdvancedMachineCasing(aX + 2, aY, aZ + 5)) && (isAdvancedMachineCasing(aX, aY, aZ - 6)) + && (isAdvancedMachineCasing(aX, aY, aZ + 6)) && (isAdvancedMachineCasing(aX - 2, aY, aZ - 5)) && (isAdvancedMachineCasing(aX - 2, aY, aZ + 5)) + && (isAdvancedMachineCasing(aX - 3, aY, aZ - 5)) && (isAdvancedMachineCasing(aX - 3, aY, aZ + 5)) && (isAdvancedMachineCasing(aX - 4, aY, aZ - 4)) + && (isAdvancedMachineCasing(aX - 4, aY, aZ + 4)) && (isAdvancedMachineCasing(aX - 5, aY, aZ - 3)) && (isAdvancedMachineCasing(aX - 5, aY, aZ - 2)) + && (isAdvancedMachineCasing(aX - 5, aY, aZ + 2)) && (isAdvancedMachineCasing(aX - 5, aY, aZ + 3)) && (isAdvancedMachineCasing(aX - 6, aY, aZ)); + } + + private boolean checkHulls(int aX, int aY, int aZ) { + return (isAdvancedMachineCasing(aX + 6, aY, aZ - 3)) && (isAdvancedMachineCasing(aX + 6, aY, aZ - 2)) && (isAdvancedMachineCasing(aX + 6, aY, aZ + 2)) + && (isAdvancedMachineCasing(aX + 6, aY, aZ + 3)) && (isAdvancedMachineCasing(aX + 3, aY, aZ - 6)) && (isAdvancedMachineCasing(aX + 3, aY, aZ + 6)) + && (isAdvancedMachineCasing(aX + 2, aY, aZ - 6)) && (isAdvancedMachineCasing(aX + 2, aY, aZ + 6)) && (isAdvancedMachineCasing(aX - 2, aY, aZ - 6)) + && (isAdvancedMachineCasing(aX - 2, aY, aZ + 6)) && (isAdvancedMachineCasing(aX - 3, aY, aZ - 6)) && (isAdvancedMachineCasing(aX - 3, aY, aZ + 6)) + && (isAdvancedMachineCasing(aX - 7, aY, aZ)) && (isAdvancedMachineCasing(aX + 7, aY, aZ)) && (isAdvancedMachineCasing(aX, aY, aZ - 7)) && (isAdvancedMachineCasing(aX, aY, aZ + 7)) + && (isAdvancedMachineCasing(aX - 6, aY, aZ - 3)) && (isAdvancedMachineCasing(aX - 6, aY, aZ - 2)) && (isAdvancedMachineCasing(aX - 6, aY, aZ + 2)) + && (isAdvancedMachineCasing(aX - 6, aY, aZ + 3)) && (isAdvancedMachineCasing(aX - 4, aY, aZ - 2)) && (isAdvancedMachineCasing(aX - 4, aY, aZ + 2)) + && (isAdvancedMachineCasing(aX + 4, aY, aZ - 2)) && (isAdvancedMachineCasing(aX + 4, aY, aZ + 2)) && (isAdvancedMachineCasing(aX - 2, aY, aZ - 4)) + && (isAdvancedMachineCasing(aX - 2, aY, aZ + 4)) && (isAdvancedMachineCasing(aX + 2, aY, aZ - 4)) && (isAdvancedMachineCasing(aX + 2, aY, aZ + 4)); + } + + private boolean addIfEnergyInjector(int aX, int aY, int aZ, IGregTechTileEntity aBaseMetaTileEntity) { + if (addEnergyInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntity(aX, aY, aZ), 53)) { + return true; + } + return isAdvancedMachineCasing(aX, aY, aZ); + } + + private boolean addIfInjector(int aX, int aY, int aZ, IGregTechTileEntity aTileEntity) { + if (addInputToMachineList(aTileEntity.getIGregTechTileEntity(aX, aY, aZ), 53)) { + return true; + } + return isAdvancedMachineCasing(aX, aY, aZ); + } + + private boolean addIfExtractor(int aX, int aY, int aZ, IGregTechTileEntity aTileEntity) { + if (addOutputToMachineList(aTileEntity.getIGregTechTileEntity(aX, aY, aZ), 53)) { + return true; + } + return isAdvancedMachineCasing(aX, aY, aZ); + } + + private boolean isAdvancedMachineCasing(int aX, int aY, int aZ) { + return (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasing()) && (getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()); + } + + public abstract Block getCasing(); + + public abstract int getCasingMeta(); + + private boolean isFusionCoil(int aX, int aY, int aZ) { + return (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getFusionCoil() && (getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getFusionCoilMeta())); + } + + public abstract Block getFusionCoil(); + + public abstract int getFusionCoilMeta(); + + public abstract String[] getDescription(); + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + ITexture[] sTexture; + if (aSide == aFacing) { + sTexture = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, Dyes.getModulation(-1, Dyes._NULL.mRGBa)), new GT_RenderedTexture(getIconOverlay())}; + } else { + if (!aActive) { + sTexture = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS, Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; + } else { + sTexture = new ITexture[]{new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW, Dyes.getModulation(-1, Dyes._NULL.mRGBa))}; + } + } + return sTexture; + } + + public abstract IIconContainer getIconOverlay(); + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public int overclock(int mStartEnergy) { + if (tierOverclock() == 1) { + return 1; + } + if (tierOverclock() == 2) { + return mStartEnergy < 160000000 ? 2 : 1; + } + return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + if (tFluidList.size() > 1) { + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sFusionRecipes.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, GT_Values.V[8], tFluids, new ItemStack[]{}); + if (tRecipe == null && !mRunningOnLoad) { + turnCasingActive(false); + this.mLastRecipe = null; + return false; + } + if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[]{})) { + this.mLastRecipe = tRecipe; + this.mEUt = (this.mLastRecipe.mEUt * overclock(this.mLastRecipe.mSpecialValue)); + this.mMaxProgresstime = this.mLastRecipe.mDuration / overclock(this.mLastRecipe.mSpecialValue); + this.mEfficiencyIncrease = 10000; + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + turnCasingActive(true); + mRunningOnLoad = false; + return true; + } + } + return false; + } + + public abstract int tierOverclock(); + + public boolean turnCasingActive(boolean status) { + if (this.mEnergyHatches != null) { + for (GT_MetaTileEntity_Hatch_Energy hatch : this.mEnergyHatches) { + hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; + } + } + if (this.mOutputHatches != null) { + for (GT_MetaTileEntity_Hatch_Output hatch : this.mOutputHatches) { + hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; + } + } + if (this.mInputHatches != null) { + for (GT_MetaTileEntity_Hatch_Input hatch : this.mInputHatches) { + hatch.mMachineBlock = status ? (byte) 52 : (byte) 53; + } + } + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (mEfficiency < 0) + mEfficiency = 0; + if (mRunningOnLoad && checkMachine(aBaseMetaTileEntity, mInventory[1])) { + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipe(mInventory[1]); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + } + if (mStartUpCheck < 0) { + if (mMachine) { + if (this.mEnergyHatches != null) { + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + if (isValidMetaTileEntity(tHatch)) { + if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore() + && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(2048 * tierOverclock(), false)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true); + } + } + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + stopMachine(); + } + if (getRepairStatus() > 0) { + if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputItems != null) + for (ItemStack tStack : mOutputItems) if (tStack != null) addOutput(tStack); + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) if (tStack != null) addOutput(tStack); + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mOutputItems = null; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + try { + GT_Mod.instance.achievements.issueAchivementHatchFluid(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), mOutputFluids[0]); + } catch (Exception e) { + } + } + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipe(mInventory[1]); + } + } else { + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { + turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (checkRecipe(mInventory[1])) { + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + mMaxProgresstime = 0; + turnCasingActive(false); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); + } + } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } else { + this.mLastRecipe = null; + stopMachine(); + } + } else { + turnCasingActive(false); + this.mLastRecipe = null; + stopMachine(); + } + } + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) + | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + this.mLastRecipe = null; + stopMachine(); + return false; + } + } + if (this.mEUStore <= 0) { + this.mLastRecipe = null; + stopMachine(); + return false; + } + return true; + } + + public boolean drainEnergyInput(long aEU) { + return false; + } + + @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 int getAmountOfOutputs() { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public String[] getInfoData() { + String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; + float plasmaOut = 0; + int powerRequired = 0; + if (this.mLastRecipe != null) { + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float)this.mLastRecipe.getFluidOutput(0).amount / (float)this.mLastRecipe.mDuration; + } + } + + return new String[]{ + "Fusion Reactor MK "+tier, + "EU Required: "+powerRequired+"EU/t", + "Stored EU: "+mEUStore+" / "+maxEUStore(), + "Plasma Output: "+plasmaOut+"L/t"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java new file mode 100644 index 0000000000..39d38e9bd3 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java @@ -0,0 +1,69 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import net.minecraft.block.Block; + +public class GT_MetaTileEntity_FusionComputer1 extends GT_MetaTileEntity_FusionComputer { + + public GT_MetaTileEntity_FusionComputer1(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 6); + } + + public GT_MetaTileEntity_FusionComputer1(String aName) { + super(aName); + } + + @Override + public int tier() { + return 6; + } + + @Override + public long maxEUStore() { + return 160000000L * (Math.min(16, this.mEnergyHatches.size())) / 16L; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_FusionComputer1(mName); + } + + @Override + public int getCasingMeta() { + return 6; + } + + @Override + public Block getFusionCoil() { + return GregTech_API.sBlockCasings1; + } + + @Override + public int getFusionCoilMeta() { + return 15; + } + + public String[] getDescription() { + return new String[]{"It's over 9000!!!", "LuV Casings around Superconducting Coils", "2-16 Input Hatches", "1-16 Output Hatches", "1-16 Energy Hatches", "All Hatches must be LuV or better", "2048EU/t and 10mio EU Cap per Energy Hatch"}; + } + + @Override + public int tierOverclock() { + return 1; + } + + @Override + public Block getCasing() { + return GregTech_API.sBlockCasings1; + } + + @Override + public IIconContainer getIconOverlay() { + return Textures.BlockIcons.OVERLAY_FUSION1; + } + +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java new file mode 100644 index 0000000000..1fd1ca7576 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java @@ -0,0 +1,68 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import net.minecraft.block.Block; + +public class GT_MetaTileEntity_FusionComputer2 extends GT_MetaTileEntity_FusionComputer { + + public GT_MetaTileEntity_FusionComputer2(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 6); + } + + public GT_MetaTileEntity_FusionComputer2(String aName) { + super(aName); + } + + @Override + public int tier() { + return 7; + } + + @Override + public long maxEUStore() { + return 320000000L * (Math.min(16, this.mEnergyHatches.size())) / 16L; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_FusionComputer2(mName); + } + + @Override + public int getCasingMeta() { + return 6; + } + + @Override + public Block getFusionCoil() { + return GregTech_API.sBlockCasings4; + } + + @Override + public int getFusionCoilMeta() { + return 7; + } + + public String[] getDescription() { + return new String[]{"It's over 9000!!!", "Fusion Casings around Fusion Coils", "2-16 Input Hatches", "1-16 Output Hatches", "1-16 Energy Hatches", "All Hatches must be ZPMV or better", "4096EU/t and 20mio EU Cap per Energy Hatch"}; + } + + @Override + public int tierOverclock() { + return 2; + } + + @Override + public Block getCasing() { + return GregTech_API.sBlockCasings4; + } + + @Override + public IIconContainer getIconOverlay() { + return Textures.BlockIcons.OVERLAY_FUSION2; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java new file mode 100644 index 0000000000..9d1a9a9579 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java @@ -0,0 +1,69 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import net.minecraft.block.Block; + +public class GT_MetaTileEntity_FusionComputer3 extends GT_MetaTileEntity_FusionComputer { + + public GT_MetaTileEntity_FusionComputer3(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 6); + } + + public GT_MetaTileEntity_FusionComputer3(String aName) { + super(aName); + } + + @Override + public int tier() { + return 8; + } + + @Override + public long maxEUStore() { + return 640000000L * (Math.min(16, this.mEnergyHatches.size())) / 16L; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_FusionComputer3(mName); + } + + @Override + public int getCasingMeta() { + return 8; + } + + @Override + public Block getFusionCoil() { + return GregTech_API.sBlockCasings4; + } + + @Override + public int getFusionCoilMeta() { + return 7; + } + + public String[] getDescription() { + return new String[]{"A SUN DOWN ON EARTH", "Fusion Casings MK II around Fusion Coils", "2-16 Input Hatches", "1-16 Output Hatches", "1-16 Energy Hatches", "All Hatches must be UV or better", "8192EU/t and 40mio EU Cap per Energy Hatch"}; + } + + @Override + public int tierOverclock() { + return 4; + } + + @Override + public Block getCasing() { + return GregTech_API.sBlockCasings4; + } + + @Override + public IIconContainer getIconOverlay() { + return Textures.BlockIcons.OVERLAY_FUSION3; + } +} + diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java new file mode 100644 index 0000000000..0127a4332a --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -0,0 +1,290 @@ +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_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import net.minecraft.block.Block; +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.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBlockBase { + + private static boolean controller; + public GT_MetaTileEntity_Hatch_Input mInputHotFluidHatch; + public GT_MetaTileEntity_Hatch_Output mOutputColdFluidHatch; + public boolean superheated = false; + private float water; + + public GT_MetaTileEntity_HeatExchanger(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + public GT_MetaTileEntity_HeatExchanger(String aName) { + super(aName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Heat Exchanger", + "Size(WxHxD): 3x4x3, Controller (Front middle at bottom)", + "3x3x4 of Stable Titanium Casing (hollow, Min 24!)", + "2 Titanium Pipe Casing Blocks (Inside the Hollow Casing)", + "1x Distillated Water Input (Any casing)", + "min 1 Steam Output (Any casing)", + "1x Hot Fluid Input (Bottom center)", + "1x Cold Fluid Output (Top Center)", + "1x Maintenance Hatch (Any casing)"}; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + superheated = aNBT.getBoolean("superheated"); + super.loadNBTData(aNBT); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("superheated", superheated); + super.saveNBTData(aNBT); + } + + 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[50], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[50]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeHeatExchanger.png"); + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + if (mInputHotFluidHatch.getFluid() == null) + return true; + + int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch + + int superheated_threshold = 4000; // default: must have 4000L per second to generate superheated steam + float efficiency = 1f; // default: operate at 100% efficiency with no integrated circuitry + float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25) + int shs_reduction_per_config = 150; // reduce threshold 150L/s per circuitry level (1-25) + float steam_output_multiplier = 4f; // default: multiply output by 4 + float penalty = 0.0f; // penalty to apply to output based on circuitry level (1-25). + boolean do_lava = false; + + // Do we have an integrated circuit with a valid configuration? + if (mInventory[1] != null && mInventory[1].getUnlocalizedName().startsWith("gt.integrated_circuit")) { + int circuit_config = mInventory[1].getItemDamage(); + if (circuit_config >= 1 && circuit_config <= 25) { + // If so, apply the penalty and reduced threshold. + penalty = (circuit_config - 1) * penalty_per_config; + superheated_threshold -= (shs_reduction_per_config * (circuit_config - 1)); + } + } + efficiency -= penalty; + + // If we're working with lava, adjust the threshold and multipliers accordingly. + if (GT_ModHandler.isLava(mInputHotFluidHatch.getFluid())) { + superheated_threshold /= 4; + do_lava = true; + } else if (mInputHotFluidHatch.getFluid().isFluidEqual(FluidRegistry.getFluidStack("ic2hotcoolant", 1))) { + steam_output_multiplier = 2f; + } else { + // If we're working with neither, fail out + return false; + } + + superheated = fluidAmountToConsume >= superheated_threshold; // set the internal superheated flag if we have enough hot fluid. Used in the onRunningTick method. + fluidAmountToConsume = Math.min(fluidAmountToConsume, superheated_threshold * 2); // Don't consume too much hot fluid per second + mInputHotFluidHatch.drain(fluidAmountToConsume, true); + this.mMaxProgresstime = 20; + this.mEUt = (int) (fluidAmountToConsume * steam_output_multiplier * efficiency); + if (do_lava) { + mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2pahoehoelava", fluidAmountToConsume), true); + this.mEfficiencyIncrease = 80; + } else { + mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2coolant", fluidAmountToConsume), true); + this.mEfficiencyIncrease = 80; + } + return true; + } + + private int useWater(float input) { + water = water + input; + int usage = (int) water; + water = water - (int) usage; + return usage; + } + + public boolean onRunningTick(ItemStack aStack) { + if (this.mEUt > 0) { + int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); // APPROXIMATELY how much steam to generate. + if (tGeneratedEU > 0) { + + if (superheated) + tGeneratedEU /= 2; // We produce half as much superheated steam if necessary + + int distilledConsumed = useWater(tGeneratedEU / 160f); // how much distilled water to consume + //tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect 1:160 ratio with distilled water consumption + + FluidStack distilledStack = GT_ModHandler.getDistilledWater(distilledConsumed); + if (depleteInput(distilledStack)) // Consume the distilled water + { + if (superheated) { + addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU)); // Generate superheated steam + } else { + addOutput(GT_ModHandler.getSteam(tGeneratedEU)); // Generate regular steam + } + } else { + explodeMultiblock(); // Generate crater + } + } + return true; + } + return true; + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + int tCasingAmount = 0; + int tFireboxAmount = 0; + controller = false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + for (int k = 0; k <= 3; k++) { + if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && !addInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && !addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && !ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getCasingBlock()) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getCasingMeta()) { + return false; + } + tCasingAmount++; + } + } + } else { + if (!addHotFluidInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j), 50)) { + return false; + } + if (!addColdFluidOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j), 50)) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != getPipeBlock()) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != getPipeMeta()) { + return false; + } + + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != getPipeBlock()) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != getPipeMeta()) { + return false; + } + } + } + } + return (tCasingAmount >= 24); + } + + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; + } + return false; + } + + public boolean addColdFluidOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + mOutputColdFluidHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; + return true; + } + return false; + } + + public boolean addHotFluidInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); + mInputHotFluidHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + return true; + } + return false; + } + + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getCasingMeta() { + return 2; + } + + public byte getCasingTextureIndex() { + return 50; + } + + public Block getPipeBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getPipeMeta() { + return 14; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 1; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_HeatExchanger(this.mName); + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java new file mode 100644 index 0000000000..5ae5b5710b --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java @@ -0,0 +1,155 @@ +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; +import java.util.Arrays; + +public class GT_MetaTileEntity_ImplosionCompressor + extends GT_MetaTileEntity_MultiBlockBase { + public GT_MetaTileEntity_ImplosionCompressor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_ImplosionCompressor(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ImplosionCompressor(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Implosion Compressor", + "Size(WxHxD): 3x3x3 (Hollow), Controller (Front centered)", + "1x Input Bus (Any casing)", + "1x Output Bus (Any casing)", + "1x Maintenance Hatch (Any casing)", + "1x Muffler Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Solid Steel Casings for the rest (16 at least!)"}; + } + + 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_IMPLOSION_COMPRESSOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR)}; + } + 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(), "ImplosionCompressor.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sImplosionRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + if (tInputList.size() > 0) { + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sImplosionRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + this.mEUt = (-tRecipe.mEUt); + this.mMaxProgresstime = Math.max(1, tRecipe.mDuration); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + sendLoopStart((byte) 20); + updateSlots(); + return true; + } + } + return false; + } + + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 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 (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addMufflerToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16)) && (!addOutputToMachineList(tTileEntity, 16)) && (!addEnergyInputToMachineList(tTileEntity, 16))) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (((tBlock != GregTech_API.sBlockCasings2) || (tMeta != 0)) && ((tBlock != GregTech_API.sBlockCasings3) || (tMeta != 4))) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 1000; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 2; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java new file mode 100644 index 0000000000..ff6a43067a --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java @@ -0,0 +1,241 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.GT_Mod; +import gregtech.api.enums.Materials; +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_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +public abstract class GT_MetaTileEntity_LargeBoiler + extends GT_MetaTileEntity_MultiBlockBase { + private boolean firstRun = true; + + public GT_MetaTileEntity_LargeBoiler(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeBoiler(String aName) { + super(aName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Large Boiler", + "Produces "+(getEUt()*40)*(runtimeBoost(20)/20f)+"L of Steam/sec for 1 Coal", + "Size(WxHxD): 3x5x3, Controller (Front middle in Fireboxes)", + "3x1x3 of Fire Boxes (Bottom layer, Min 3)", + "3x4x3 of Casing (Above Fireboxes, hollow, Min 24!)", + "3 Pipe Casing Blocks (Inside the Hollow Casing)", + "1x Input Hatch/Bus (Any Firebox)", + "1x Output Hatch (Any Firebox)", + "1x Maintenance Hatch (Any Firebox)", + "1x Muffler Hatch (Any Firebox)", + "Refined liquid fuels have 1/4 efficiency"}; + } + + public abstract Block getCasingBlock(); + + public abstract byte getCasingMeta(); + + public abstract byte getCasingTextureIndex(); + + public abstract Block getPipeBlock(); + + public abstract byte getPipeMeta(); + + public abstract Block getFireboxBlock(); + + public abstract byte getFireboxMeta(); + + public abstract byte getFireboxTextureIndex(); + + public abstract int getEUt(); + + public abstract int getEfficiencyIncrease(); + + 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[getCasingTextureIndex()], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[getCasingTextureIndex()]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeBoiler.png"); + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + for (GT_Recipe tRecipe : GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(tRecipe.getRepresentativeInput(0), true); + if ((tFluid != null) && (tRecipe.mSpecialValue > 1)) { + tFluid.amount = 1000; + if (depleteInput(tFluid)) { + this.mMaxProgresstime = (runtimeBoost(tRecipe.mSpecialValue / 2)); + this.mEUt = getEUt(); + this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease() * 4); + return true; + } + } + } + for (GT_Recipe tRecipe : GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels.mRecipeList) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(tRecipe.getRepresentativeInput(0), true); + if (tFluid != null) { + tFluid.amount = 1000; + if (depleteInput(tFluid)) { + this.mMaxProgresstime = Math.max(1, runtimeBoost(tRecipe.mSpecialValue * 2)); + this.mEUt = getEUt(); + this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); + return true; + } + } + } + ArrayList<ItemStack> tInputList = getStoredInputs(); + if (!tInputList.isEmpty()) { + for (ItemStack tInput : tInputList) { + if ((GT_Utility.getFluidForFilledItem(tInput, true) == null) && ((this.mMaxProgresstime = runtimeBoost(GT_ModHandler.getFuelValue(tInput) / 80)) > 0)) { + this.mEUt = getEUt(); + this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); + this.mOutputItems = new ItemStack[]{GT_Utility.getContainerItem(tInput, true)}; + tInput.stackSize -= 1; + updateSlots(); + return true; + } + } + } + this.mMaxProgresstime = 0; + this.mEUt = 0; + return false; + } + + abstract int runtimeBoost(int mTime); + + public boolean onRunningTick(ItemStack aStack) { + if (this.mEUt > 0) { + int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); + if (tGeneratedEU > 0) { + long amount = (tGeneratedEU + 160) / 160; + if (depleteInput(Materials.Water.getFluid(amount)) || depleteInput(GT_ModHandler.getDistilledWater(amount))) { + addOutput(GT_ModHandler.getSteam(tGeneratedEU)); + } else { + explodeMultiblock(); + } + } + return true; + } + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (mProgresstime > 0 && firstRun) { + firstRun = false; + try { + GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "extremepressure"); + } catch (Exception e) { + } + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + int tCasingAmount = 0; + int tFireboxAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + for (int k = 1; k <= 4; k++) { + if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), getCasingTextureIndex())) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getCasingBlock()) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getCasingMeta()) { + return false; + } + tCasingAmount++; + } + } + } else { + for (int k = 1; k <= 3; k++) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getPipeBlock()) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getPipeMeta()) { + return false; + } + } + if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 4, zDir + j), getCasingTextureIndex())) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 4, zDir + j) != getCasingBlock()) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 4, zDir + j) != getCasingMeta()) { + return false; + } + tCasingAmount++; + } + } + } + } + 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, getFireboxTextureIndex())) && (!addInputToMachineList(tTileEntity, getFireboxTextureIndex())) && (!addMufflerToMachineList(tTileEntity, getFireboxTextureIndex()))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != getFireboxBlock()) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != getFireboxMeta()) { + return false; + } + tFireboxAmount++; + } + } + } + } + return (tCasingAmount >= 24) && (tFireboxAmount >= 3); + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 10; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 1; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Bronze.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Bronze.java new file mode 100644 index 0000000000..5c949b6108 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Bronze.java @@ -0,0 +1,66 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; + +public class GT_MetaTileEntity_LargeBoiler_Bronze + extends GT_MetaTileEntity_LargeBoiler { + public GT_MetaTileEntity_LargeBoiler_Bronze(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeBoiler_Bronze(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeBoiler_Bronze(this.mName); + } + + public Block getCasingBlock() { + return GregTech_API.sBlockCasings1; + } + + public byte getCasingMeta() { + return 10; + } + + public byte getCasingTextureIndex() { + return 10; + } + + public Block getPipeBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getPipeMeta() { + return 12; + } + + public Block getFireboxBlock() { + return GregTech_API.sBlockCasings3; + } + + public byte getFireboxMeta() { + return 13; + } + + public byte getFireboxTextureIndex() { + return 45; + } + + public int getEUt() { + return 400; + } + + public int getEfficiencyIncrease() { + return 16; + } + + @Override + int runtimeBoost(int mTime) { + return mTime * 2; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Steel.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Steel.java new file mode 100644 index 0000000000..0f663dc9a8 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Steel.java @@ -0,0 +1,66 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; + +public class GT_MetaTileEntity_LargeBoiler_Steel + extends GT_MetaTileEntity_LargeBoiler { + public GT_MetaTileEntity_LargeBoiler_Steel(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeBoiler_Steel(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeBoiler_Steel(this.mName); + } + + public Block getCasingBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getCasingMeta() { + return 0; + } + + public byte getCasingTextureIndex() { + return 16; + } + + public Block getPipeBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getPipeMeta() { + return 13; + } + + public Block getFireboxBlock() { + return GregTech_API.sBlockCasings3; + } + + public byte getFireboxMeta() { + return 14; + } + + public byte getFireboxTextureIndex() { + return 46; + } + + public int getEUt() { + return 600; + } + + public int getEfficiencyIncrease() { + return 12; + } + + @Override + int runtimeBoost(int mTime) { + return mTime * 150 / 100; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Titanium.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Titanium.java new file mode 100644 index 0000000000..6fc32f8c34 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_Titanium.java @@ -0,0 +1,66 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; + +public class GT_MetaTileEntity_LargeBoiler_Titanium + extends GT_MetaTileEntity_LargeBoiler { + public GT_MetaTileEntity_LargeBoiler_Titanium(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeBoiler_Titanium(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeBoiler_Titanium(this.mName); + } + + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getCasingMeta() { + return 2; + } + + public byte getCasingTextureIndex() { + return 50; + } + + public Block getPipeBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getPipeMeta() { + return 14; + } + + public Block getFireboxBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getFireboxMeta() { + return 3; + } + + public byte getFireboxTextureIndex() { + return 51; + } + + public int getEUt() { + return 800; + } + + public int getEfficiencyIncrease() { + return 8; + } + + @Override + int runtimeBoost(int mTime) { + return mTime * 130 / 100; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_TungstenSteel.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_TungstenSteel.java new file mode 100644 index 0000000000..f6609307a7 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler_TungstenSteel.java @@ -0,0 +1,67 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; + +public class GT_MetaTileEntity_LargeBoiler_TungstenSteel + extends GT_MetaTileEntity_LargeBoiler { + public GT_MetaTileEntity_LargeBoiler_TungstenSteel(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeBoiler_TungstenSteel(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeBoiler_TungstenSteel(this.mName); + } + + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + public byte getCasingMeta() { + return 0; + } + + public byte getCasingTextureIndex() { + return 48; + } + + public Block getPipeBlock() { + return GregTech_API.sBlockCasings2; + } + + public byte getPipeMeta() { + return 15; + } + + public Block getFireboxBlock() { + return GregTech_API.sBlockCasings3; + } + + public byte getFireboxMeta() { + return 15; + } + + public byte getFireboxTextureIndex() { + return 47; + } + + public int getEUt() { + return 1000; + } + + public int getEfficiencyIncrease() { + return 4; + } + + @Override + int runtimeBoost(int mTime) { + return mTime * 120 / 100; + } + +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java new file mode 100644 index 0000000000..458b65bda0 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java @@ -0,0 +1,222 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.gui.GT_GUIContainer_MultiMachine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import net.minecraft.block.Block; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_MultiBlockBase { + + protected int baseEff = 0; + protected int optFlow = 0; + protected int realOptFlow = 0; + protected int storedFluid = 0; + protected int counter = 0; + + public GT_MetaTileEntity_LargeTurbine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + public GT_MetaTileEntity_LargeTurbine(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return getMaxEfficiency(aStack) > 0; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeTurbine.png"); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + byte tSide = getBaseMetaTileEntity().getBackFacing(); + if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2))) { + int tAirCount = 0; + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + for (byte k = -1; k < 2; k = (byte) (k + 1)) { + if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { + tAirCount++; + } + } + } + } + if (tAirCount != 10) { + return false; + } + for (byte i = 2; i < 6; i = (byte) (i + 1)) { + IGregTechTileEntity tTileEntity; + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine))) { + return false; + } + } + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 4; k = (byte) (k + 1)) { + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2))) { + if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)))) { + return false; + } + } else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } else { + return false; + } + } + } + } + } + this.mDynamoHatches.clear(); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) { + this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { + return false; + } + } + } else { + return false; + } + return true; + } + + public abstract Block getCasingBlock(); + + public abstract byte getCasingMeta(); + + public abstract byte getCasingTextureIndex(); + + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + } + + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<FluidStack> tFluids = getStoredFluids(); + if (tFluids.size() > 0) { + if (baseEff == 0 || optFlow == 0 || counter >= 1000 || this.getBaseMetaTileEntity().hasWorkJustBeenEnabled() + || this.getBaseMetaTileEntity().hasInventoryBeenModified()) { + counter = 0; + baseEff = (int) ((50.0F + + (10.0F * ((GT_MetaGenerated_Tool) aStack.getItem()).getToolCombatDamage(aStack))) * 100); + optFlow = (int) Math.max(Float.MIN_NORMAL, + ((GT_MetaGenerated_Tool) aStack.getItem()).getToolStats(aStack).getSpeedMultiplier() + * ((GT_MetaGenerated_Tool) aStack.getItem()).getPrimaryMaterial(aStack).mToolSpeed + * 50); + } else { + counter++; + } + } + + int newPower = fluidIntoPower(tFluids, optFlow, baseEff); // How much the turbine should be producing with this flow + int difference = newPower - this.mEUt; // difference between current output and new output + + // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the difference in power level (per tick) + // This is how much the turbine can actually change during this tick + int maxChangeAllowed = Math.max(10, (int) Math.ceil(Math.abs(difference) * 0.01)); + + if (Math.abs(difference) > maxChangeAllowed) { // If this difference is too big, use the maximum allowed change + int change = maxChangeAllowed * (difference > 0 ? 1 : -1); // Make the change positive or negative. + this.mEUt += change; // Apply the change + } else + this.mEUt = newPower; + + if (mEUt <= 0) { + +// this.mEfficiencyIncrease = (-10); + this.mEfficiency = 0; + //stopMachine(); + return false; + } else { + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = (10); + return true; + } + } + + abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff); + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 1; + } + + public int getMaxEfficiency(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) { + return 0; + } + if (aStack.getItem() instanceof GT_MetaGenerated_Tool_01) { + return 10000; + } + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return true; + } + + @Override + public String[] getInfoData() { + String tRunning = mMaxProgresstime>0 ? "Turbine running":"Turbine stopped"; + String tMaintainance = getIdealStatus() == getRepairStatus() ? "No Maintainance issues" : "Needs Maintainance" ; + int tDura = 0; + + if (mInventory[1] != null && mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { + tDura = (int) ((100.0f / GT_MetaGenerated_Tool.getToolMaxDamage(mInventory[1]) * (GT_MetaGenerated_Tool.getToolDamage(mInventory[1]))+1)); + } + + return new String[]{ + "Large Turbine", + tRunning, + "Current Output: "+mEUt+" EU/t", + "Optimal Flow: "+realOptFlow+" L/t", + "Fuel Remaining: "+storedFluid+"L", + "Current Speed: "+(mEfficiency/100)+"%", + "Turbine Damage: "+tDura+"%", + tMaintainance}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java new file mode 100644 index 0000000000..0e59e9e9c3 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -0,0 +1,129 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.Collection; + +public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeTurbine { + + public GT_MetaTileEntity_LargeTurbine_Gas(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeTurbine_Gas(String aName) { + super(aName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_SS_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_SS5) : Textures.BlockIcons.CASING_BLOCKS[59]}; + } + + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Large Gas Turbine", + "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", + "1x Input Hatch (Side centered)", + "1x Maintenance Hatch (Side centered)", + "1x Muffler Hatch (Side centered)", + "1x Dynamo Hatch (Back centered)", + "Titanium Turbine Casings for the rest (24 at least!)", + "Needs a Turbine Item (Inside controller GUI)"}; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null || GT_Recipe_Map.sTurbineFuels == null) return 0; + FluidStack tLiquid; + Collection<GT_Recipe> tRecipeList = GT_Recipe_Map.sTurbineFuels.mRecipeList; + if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) + if (aLiquid.isFluidEqual(tLiquid)) return tFuel.mSpecialValue; + return 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeTurbine_Gas(mName); + } + + @Override + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + @Override + public byte getCasingMeta() { + return 11; + } + + @Override + public byte getCasingTextureIndex() { + return 59; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 10; + } + + @Override + int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + int tEU = 0; + + int actualOptimalFlow = 0; + + if (aFluids.size() >= 1) { + FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest! + int fuelValue = getFuelValue(firstFuelType); + actualOptimalFlow = (int) (aOptFlow / fuelValue); + this.realOptFlow = actualOptimalFlow; + + int remainingFlow = (int) (actualOptimalFlow * 1.25f); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + int flow = 0; + int totalFlow = 0; + + for (int i = 0; i < aFluids.size(); i++) { + if (aFluids.get(i).isFluidEqual(firstFuelType)) { + flow = aFluids.get(i).amount; // Get all (steam) in hatch + flow = Math.min(flow, Math.min(remainingFlow, (int) (actualOptimalFlow * 1.25f))); // try to use up to 125% of optimal flow w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid = aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + } + } + + tEU = (int) (Math.min((float) actualOptimalFlow, totalFlow) * fuelValue); + + if (totalFlow != actualOptimalFlow) { + float efficiency = 1.0f - Math.abs(((totalFlow - (float) actualOptimalFlow) / actualOptimalFlow)); + if(totalFlow>aOptFlow){efficiency = 1.0f;} + if (efficiency < 0) + efficiency = 0; // Can happen with really ludicrously poor inefficiency. + tEU *= efficiency; + tEU = Math.max(1, tEU * aBaseEff / 10000); + } else { + tEU = tEU * aBaseEff / 10000; + } + + return tEU; + + } + return 0; + } + + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java new file mode 100644 index 0000000000..3321efd9e0 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -0,0 +1,115 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_LargeTurbine { + + public boolean achievement = false; + + public GT_MetaTileEntity_LargeTurbine_HPSteam(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeTurbine_HPSteam(String aName) { + super(aName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_SS_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_SS5) : Textures.BlockIcons.CASING_BLOCKS[58]}; + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Large High Pressure Steam Turbine", + "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", + "1x Input Hatch (Side centered)", + "1x Maintenance Hatch (Side centered)", + "1x Muffler Hatch (Side centered)", + "1x Dynamo Hatch (Back centered)", + "Stainless Steel Turbine Casings for the rest (24 at least!)", + "Needs a Turbine Item (Inside controller GUI)"}; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeTurbine_HPSteam(mName); + } + + @Override + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + @Override + public byte getCasingMeta() { + return 10; + } + + @Override + public byte getCasingTextureIndex() { + return 58; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + int tEU = 0; + int totalFlow = 0; // Byproducts are based on actual flow + int flow = 0; + int remainingFlow = (int) (aOptFlow * 1.25f); // Allowed to use up to 125% of optimal flow + this.realOptFlow = (aOptFlow / 2); + + for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { + String fluidName = aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)); + if (fluidName.equals("ic2.fluidSuperheatedSteam")) { + flow = aFluids.get(i).amount; // Get all (steam) in hatch + flow = Math.min(flow, Math.min(remainingFlow, (int) (aOptFlow * 1.25f))); // try to use up to 125% of optimal flow w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid = aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to keep depleting from hatches + totalFlow += flow; // track total used + if (!achievement) { + try { + GT_Mod.instance.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "efficientsteam"); + } catch (Exception e) { + } + achievement = true; + } + }else if(fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") || fluidName.equals("fluid.mfr.steam.still.name")){ + depleteInput(new FluidStack(aFluids.get(i), aFluids.get(i).amount)); + } + } + + tEU = (int) (Math.min((float) aOptFlow, totalFlow)); + addOutput(GT_ModHandler.getSteam(totalFlow)); + if (totalFlow > 0 && totalFlow != aOptFlow) { + float efficiency = 1.0f - Math.abs(((totalFlow - (float) aOptFlow) / aOptFlow)); + if(totalFlow>aOptFlow){efficiency = 1.0f;} + tEU *= efficiency; + tEU = Math.max(1, tEU * aBaseEff / 10000); + } else { + tEU = tEU * aBaseEff / 10000; + } + + return tEU; + } + + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java new file mode 100644 index 0000000000..2880c609a9 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -0,0 +1,131 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.Collection; + +public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_LargeTurbine { + + public GT_MetaTileEntity_LargeTurbine_Plasma(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeTurbine_Plasma(String aName) { + super(aName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_TU_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_TU5) : Textures.BlockIcons.CASING_BLOCKS[60]}; + } + + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Large Plasma Generator", + "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", + "1x Input Hatch (Side centered)", + "1x Maintenance Hatch (Side centered)", + "1x Muffler Hatch (Side centered)", + "1x Dynamo Hatch (Back centered)", + "Tungstensteel Turbine Casings for the rest (24 at least!)", + "Needs a Turbine Item (Inside controller GUI)"}; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null || GT_Recipe_Map.sTurbineFuels == null) return 0; + FluidStack tLiquid; + Collection<GT_Recipe> tRecipeList = GT_Recipe_Map.sPlasmaFuels.mRecipeList; + if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) + if (aLiquid.isFluidEqual(tLiquid)) return tFuel.mSpecialValue; + return 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeTurbine_Plasma(mName); + } + + @Override + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + @Override + public byte getCasingMeta() { + return 12; + } + + @Override + public byte getCasingTextureIndex() { + return 60; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + + aOptFlow *= 40; + int tEU = 0; + + int actualOptimalFlow = 0; + + if (aFluids.size() >= 1) { + FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest! + int fuelValue = getFuelValue(firstFuelType); + actualOptimalFlow = (int) ((aOptFlow + fuelValue - 1) / fuelValue); + this.realOptFlow = (aOptFlow / fuelValue); // For scanner info + + int remainingFlow = (int) (actualOptimalFlow * 1.25f); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + int flow = 0; + int totalFlow = 0; + + for (int i = 0; i < aFluids.size(); i++) { + if (aFluids.get(i).isFluidEqual(firstFuelType)) { + flow = aFluids.get(i).amount; // Get all (steam) in hatch + flow = Math.min(flow, Math.min(remainingFlow, (int) (actualOptimalFlow * 1.25f))); // try to use up to 125% of optimal flow w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid = aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + } + } + + tEU = (int) (Math.min((float) actualOptimalFlow, totalFlow) * fuelValue); + + if (totalFlow != actualOptimalFlow) { + float efficiency = 1.0f - Math.abs(((totalFlow - (float) actualOptimalFlow) / actualOptimalFlow)); + if(totalFlow>aOptFlow){efficiency = 1.0f;} + if (efficiency < 0) + efficiency = 0; // Can happen with really ludicrously poor inefficiency. + tEU *= efficiency; + tEU = Math.max(1, tEU * aBaseEff / 10000); + } else { + tEU = tEU * aBaseEff / 10000; + } + + return tEU; + + } + return 0; + } + + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java new file mode 100644 index 0000000000..6cf3897ebb --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -0,0 +1,121 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +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.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_LargeTurbine { + + private float water; + private boolean achievement = false; + + public GT_MetaTileEntity_LargeTurbine_Steam(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + + public GT_MetaTileEntity_LargeTurbine_Steam(String aName) { + super(aName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_ST_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_ST5) : Textures.BlockIcons.CASING_BLOCKS[57]}; + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Large Steam Turbine", + "Size(WxHxD): 3x3x4 (Hollow), Controller (Front centered)", + "1x Input Hatch (Side centered)", + "1x Maintenance Hatch (Side centered)", + "1x Muffler Hatch (Side centered)", + "1x Dynamo Hatch (Back centered)", + "Turbine Casings for the rest (24 at least!)", + "Needs a Turbine Item (Inside controller GUI)"}; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeTurbine_Steam(mName); + } + + @Override + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + @Override + public byte getCasingMeta() { + return 9; + } + + @Override + public byte getCasingTextureIndex() { + return 46; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + private int useWater(float input) { + water = water + input; + int usage = (int) water; + water = water - (int) usage; + return usage; + } + + @Override + int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + int tEU = 0; + int totalFlow = 0; // Byproducts are based on actual flow + int flow = 0; + int remainingFlow = (int) (aOptFlow * 1.25f); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + this.realOptFlow = ((aOptFlow / 2) / 2); + + for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and track totals. + String fluidName = aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)); + if (fluidName.equals("fluid.steam") || fluidName.equals("ic2.fluidSteam") || fluidName.equals("fluid.mfr.steam.still.name")) { + flow = aFluids.get(i).amount; // Get all (steam) in hatch + flow = Math.min(flow, Math.min(remainingFlow, (int) (aOptFlow * 1.25f))); // try to use up to 125% of optimal flow w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + this.storedFluid = aFluids.get(i).amount; + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + if (!achievement) { + try { + GT_Mod.instance.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam"); + } catch (Exception e) { + } + achievement = true; + } + } + } + + tEU = (int) (Math.min((float) aOptFlow, totalFlow)); + int waterToOutput = useWater(totalFlow / 160.0f); + addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); + if (totalFlow > 0 && totalFlow != aOptFlow) { + float efficiency = 1.0f - Math.abs(((totalFlow - (float) aOptFlow) / aOptFlow)); + if(totalFlow>aOptFlow){efficiency = 1.0f;} + tEU *= efficiency; + tEU = Math.max(1, tEU * aBaseEff / 20000); + } else { + tEU = tEU * aBaseEff / 20000; + } + + return tEU; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java new file mode 100644 index 0000000000..efd69309d5 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -0,0 +1,177 @@ +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; + +public class GT_MetaTileEntity_MultiFurnace + extends GT_MetaTileEntity_MultiBlockBase { + private int mLevel = 0; + + public GT_MetaTileEntity_MultiFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_MultiFurnace(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_MultiFurnace(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Multi Smelter", + "Smelts up to 6-18 Items at once", + "Size(WxHxD): 3x3x3 (Hollow), Controller (Front middle at bottom)", + "8x Heating Coils (Middle layer, hollow)", + "1x Input Bus (One of bottom)", + "1x Output Bus (One of bottom)", + "1x Maintenance Hatch (One of bottom)", + "1x Muffler Hatch (Top middle)", + "1x Energy Hatch (One of bottom)", + "Heat Proof Machine Casings for the rest",}; + } + + 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[11], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[11]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiFurnace.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sFurnaceRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + if (!tInputList.isEmpty()) { + byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); + + int j = 0; + this.mOutputItems = new ItemStack[6 * this.mLevel]; + for (int i = 0; (i < 100) && (j < this.mOutputItems.length); i++) { + if (null != (this.mOutputItems[j] = GT_ModHandler.getSmeltingOutput((ItemStack) tInputList.get(i % tInputList.size()), true, null))) { + j++; + } + } + if (j > 0) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + this.mEUt = (-4 * (1 << tTier - 1) * (1 << tTier - 1) * this.mLevel); + this.mMaxProgresstime = Math.max(1, 512 / (1 << tTier - 1)); + } + updateSlots(); + return true; + } + return false; + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + this.mLevel = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), 11); + + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); + switch (tUsedMeta) { + case 12: + this.mLevel = 1; + break; + case 13: + this.mLevel = 2; + break; + case 14: + this.mLevel = 3; + break; + default: + return false; + } + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 11) { + return false; + } + } + } + } + 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, 11)) && (!addInputToMachineList(tTileEntity, 11)) && (!addOutputToMachineList(tTileEntity, 11)) && (!addEnergyInputToMachineList(tTileEntity, 11))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 11) { + return false; + } + } + } + } + } + return true; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 20; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 18; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java new file mode 100644 index 0000000000..df62571864 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -0,0 +1,249 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase { + + public GT_MetaTileEntity_OilCracker(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_OilCracker(String aName) { + super(aName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Oil Cracking Unit", + "Cracks heavy oil into lighter parts", + "Size(WxHxD): 5x3x3 (Hollow), Controller (Front center)", + "Ring of 8 Cupronickel Coils (Each side of Controller)", + "1x Input Hatch (Left side middle)", + "1x Input Hatch (Any middle ring casing)", + "1x Output Hatch (Right side middle)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Clean Stainless Steel Casings for the rest (18 at least!)", + "Optional Steam(50% less EU/t) or Hydrogen(30% more output)"}; + } + + 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[49], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[49]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OilCrackingUnit.png"); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<FluidStack> tInputList = getStoredFluids(); + for (FluidStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCrakingRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tInput}, new ItemStack[]{}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, new FluidStack[]{tInput}, new ItemStack[]{})) { + boolean steam = false; + boolean hydrogen = false; + for (FluidStack tInput2 : tInputList) { + if (tInput2.getFluid() == GT_ModHandler.getSteam(1).getFluid()) { + steam = true; + tInput2.amount -= 128; + } + if (tInput2.getFluid() == Materials.Hydrogen.mGas) { + hydrogen = true; + steam = false; + tInput2.amount -= 64; + } + + } + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (steam) this.mEUt = this.mEUt / 2; + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + if (hydrogen) this.mOutputFluids[0].amount = this.mOutputFluids[0].amount * 130 / 100; + return true; + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int amount = 0; + if (xDir != 0) { + for (int i = -1; i < 2; i++) {// xDirection + for (int j = -1; j < 2; j++) {// height + for (int h = -2; h < 3; h++) { + if (!(j == 0 && i == 0 && (h == -1 || h == 0 || h == 1))) { + if (h == 1 || h == -1) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir); + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 12) { + return false; + } + } + if (h == 2 || h == -2) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir); + boolean tSide = ((aBaseMetaTileEntity.getBackFacing() == 4 && 2 == h) || (aBaseMetaTileEntity.getBackFacing() == 5 && -2 == h)); + if (tSide ? !addInputToMachineList(tTileEntity, 49) : !addOutputToMachineList(tTileEntity, 49)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 1) { + return false; + } + amount++; + } + } + if (h == 0) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, j, h + zDir); + if ((!addMaintenanceToMachineList(tTileEntity, 49)) && (!addInputToMachineList(tTileEntity, 49)) + && (!addEnergyInputToMachineList(tTileEntity, 49))) { + if (!((xDir + i) == 0 && j == 0 && (h + zDir) == 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, j, h + zDir) != GregTech_API.sBlockCasings4) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, j, h + zDir) != 1) { + return false; + } + amount++; + } + } + } + + } + } + } + } + } else { + for (int i = -1; i < 2; i++) {// zDirection + for (int j = -1; j < 2; j++) {// height + for (int h = -2; h < 3; h++) { + if (!(j == 0 && i == 0 && (h == -1 || h == 0 || h == 1))) { + if (h == 1 || h == -1) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir); + if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + h, j, i + zDir) != 12) { + return false; + } + } + if (h == 2 || h == -2) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir); + boolean tSide = (aBaseMetaTileEntity.getBackFacing() == h || (aBaseMetaTileEntity.getBackFacing() == 3 && -2 == h)); + if (tSide ? !addOutputToMachineList(tTileEntity, 49) : !addInputToMachineList(tTileEntity, 49)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings4) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + h, j, i + zDir) != 1) { + return false; + } + amount++; + } + } + if (h == 0) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + h, j, i + zDir); + if ((!addMaintenanceToMachineList(tTileEntity, 49)) && (!addInputToMachineList(tTileEntity, 49)) + && (!addEnergyInputToMachineList(tTileEntity, 49))) { + if (!((xDir + h) == 0 && j == 0 && (i + zDir) == 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + h, j, i + zDir) != GregTech_API.sBlockCasings4) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + h, j, i + zDir) != 1) { + return false; + } + amount++; + } + } + } + + } + } + } + } + } + if (amount < 19) 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 int getAmountOfOutputs() { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_OilCracker(this.mName); + } + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java new file mode 100644 index 0000000000..f7973c8029 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java @@ -0,0 +1,237 @@ +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; + +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 Casings", + "1x3x1 Solid Steel 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_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + 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 = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord()); + if (tFluid == null) { + return false; + } + if (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; + } else if (tFluid.amount < 5000) { + return false; + } else { + tFluid.amount = tFluid.amount / 5000; + } + 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 <= 0) { + 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 int getAmountOfOutputs() { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_OilDrill(this.mName); + } + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java new file mode 100644 index 0000000000..036709e038 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java @@ -0,0 +1,331 @@ +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.ArrayUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBlockBase { + + GT_Recipe mLastRecipe; + + public GT_MetaTileEntity_ProcessingArray(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_ProcessingArray(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_ProcessingArray(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Processing Array", + "Runs supplied machines as if placed in the world", + "Size(WxHxD): 3x3x3 (Hollow), Controller (Front centered)", + "1x Input Hatch/Bus (Any casing)", + "1x Output Hatch/Bus (Any casing)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Robust Tungstensteel Casings for the rest (16 at least!)", + "Place up to 16 Single Block GT Machines into the GUI Inventory"}; + } + + 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[48], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[48]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + if (mInventory[1] == null) return null; + String tmp = mInventory[1].getUnlocalizedName().replaceAll("gt.blockmachines.basicmachine.", ""); + if (tmp.startsWith("centrifuge")) { + return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; + } else if (tmp.startsWith("electrolyzer")) { + return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; + } else if (tmp.startsWith("alloysmelter")) { + return GT_Recipe.GT_Recipe_Map.sAlloySmelterRecipes; + } else if (tmp.startsWith("assembler")) { + return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; + } else if (tmp.startsWith("compressor")) { + return GT_Recipe.GT_Recipe_Map.sCompressorRecipes; + } else if (tmp.startsWith("extractor")) { + return GT_Recipe.GT_Recipe_Map.sExtractorRecipes; + } else if (tmp.startsWith("macerator")) { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + } else if (tmp.startsWith("recycler")) { + return GT_Recipe.GT_Recipe_Map.sRecyclerRecipes; + } else if (tmp.startsWith("thermalcentrifuge")) { + return GT_Recipe.GT_Recipe_Map.sThermalCentrifugeRecipes; + } else if (tmp.startsWith("orewasher")) { + return GT_Recipe.GT_Recipe_Map.sOreWasherRecipes; + } else if (tmp.startsWith("chemicalreactor")) { + return GT_Recipe.GT_Recipe_Map.sChemicalRecipes; + } else if (tmp.startsWith("chemicalbath")) { + return GT_Recipe.GT_Recipe_Map.sChemicalBathRecipes; + } else if (tmp.startsWith("electromagneticseparator")) { + return GT_Recipe.GT_Recipe_Map.sElectroMagneticSeparatorRecipes; + } else if (tmp.startsWith("autoclave")) { + return GT_Recipe.GT_Recipe_Map.sAutoclaveRecipes; + } else if (tmp.startsWith("mixer")) { + return GT_Recipe.GT_Recipe_Map.sMixerRecipes; + } else if (tmp.startsWith("hammer")) { + return GT_Recipe.GT_Recipe_Map.sHammerRecipes; + } else if (tmp.startsWith("sifter")) { + return GT_Recipe.GT_Recipe_Map.sSifterRecipes; + } else if (tmp.startsWith("extruder")) { + return GT_Recipe.GT_Recipe_Map.sExtruderRecipes; + } else if (tmp.startsWith("laserengraver")) { + return GT_Recipe.GT_Recipe_Map.sLaserEngraverRecipes; + } else if (tmp.startsWith("bender")) { + return GT_Recipe.GT_Recipe_Map.sBenderRecipes; + } else if (tmp.startsWith("wiremill")) { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } else if (tmp.startsWith("arcfurnace")) { + return GT_Recipe.GT_Recipe_Map.sArcFurnaceRecipes; + } else if (tmp.startsWith("brewery")) { + return GT_Recipe.GT_Recipe_Map.sBrewingRecipes; + } else if (tmp.startsWith("canner")) { + return GT_Recipe.GT_Recipe_Map.sCannerRecipes; + } else if (tmp.startsWith("cutter")) { + return GT_Recipe.GT_Recipe_Map.sCutterRecipes; + } else if (tmp.startsWith("fermenter")) { + return GT_Recipe.GT_Recipe_Map.sFermentingRecipes; + } else if (tmp.startsWith("fluidextractor")) { + return GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes; + } else if (tmp.startsWith("fluidsolidifier")) { + return GT_Recipe.GT_Recipe_Map.sFluidSolidficationRecipes; + } else if (tmp.startsWith("lathe")) { + return GT_Recipe.GT_Recipe_Map.sLatheRecipes; + } else if (tmp.startsWith("boxinator")) { + return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes; + } else if (tmp.startsWith("unboxinator")) { + return GT_Recipe.GT_Recipe_Map.sUnboxinatorRecipes; + } else if (tmp.startsWith("polarizer")) { + return GT_Recipe.GT_Recipe_Map.sPolarizerRecipes; + } + + return null; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + if (aStack != null && aStack.getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { + return true; + } + return false; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + if (!isCorrectMachinePart(mInventory[1])) { + return false; + } + GT_Recipe.GT_Recipe_Map map = getRecipeMap(); + if (map == null) { + return false; + } + ArrayList<ItemStack> tInputList = getStoredInputs(); + int tTier = 0; + if (mInventory[1].getUnlocalizedName().endsWith("1")) { + tTier = 1; + } + if (mInventory[1].getUnlocalizedName().endsWith("2")) { + tTier = 2; + } + if (mInventory[1].getUnlocalizedName().endsWith("3")) { + tTier = 3; + } + if (mInventory[1].getUnlocalizedName().endsWith("4")) { + tTier = 4; + } + if (mInventory[1].getUnlocalizedName().endsWith("5")) { + tTier = 5; + } + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 0 || tFluids.length > 0) { + GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if (tRecipe != null) { + mLastRecipe = tRecipe; + this.mEUt = 0; + this.mOutputItems = null; + this.mOutputFluids = null; + int machines = Math.min(16, mInventory[1].stackSize); + int i = 0; + for (; i < machines; i++) { + if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { + if (i == 0) { + return false; + } + break; + } + } + this.mMaxProgresstime = tRecipe.mDuration; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + this.mEUt *= i; + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + tOut[h] = tRecipe.getOutput(h).copy(); + tOut[h].stackSize = 0; + } + FluidStack tFOut = null; + if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); + for (int f = 0; f < tOut.length; f++) { + if (tRecipe.mOutputs[f] != null && tOut[f] != null) { + for (int g = 0; g < i; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + if (tFOut != null) { + int tSize = tFOut.amount; + tFOut.amount = tSize * i; + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + List<ItemStack> overStacks = new ArrayList<ItemStack>(); + for (int f = 0; f < tOut.length; f++) { + if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { + while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { + ItemStack tmp = tOut[f].copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); + overStacks.add(tmp); + } + } + } + if (overStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[overStacks.size()]; + tmp = overStacks.toArray(tmp); + tOut = ArrayUtils.addAll(tOut, tmp); + } + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOut) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOut = tSList.toArray(new ItemStack[tSList.size()]); + this.mOutputItems = tOut; + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); + return true; + } + } + return false; + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 48)) && (!addInputToMachineList(tTileEntity, 48)) && (!addOutputToMachineList(tTileEntity, 48)) && (!addEnergyInputToMachineList(tTileEntity, 48))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings4) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 1; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java new file mode 100644 index 0000000000..463fb144c6 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -0,0 +1,179 @@ +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; + +public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase { + + public GT_MetaTileEntity_PyrolyseOven(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_PyrolyseOven(String aName) { + super(aName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Pyrolyse Oven", + "Industrial Charcoal producer and Oil from Plants", + "Size(WxHxD): 5x4x5, Controller (Bottom center)", + "3x1x3 Kanthal Heating Coils (Inside bottom 5x1x5 layer)", + "9x Kanthal Heating Coils (Centered 3x1x3 area in Bottom layer)", + "1x Input Hatch/Bus (Centered 3x1x3 area in Top layer)", + "1x Output Hatch/Bus (Any bottom layer casing)", + "1x Maintenance Hatch (Any bottom layer casing)", + "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", + "1x Energy Hatch (Any bottom layer casing)", + "ULV Machine Casings for the rest (60 at least!)"}; + } + + 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[0], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[0]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "PyrolyseOven.png"); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + ArrayList<FluidStack> tFluidInputs = getStoredFluids(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sPyrolyseRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluidInputs.isEmpty() ? null : new FluidStack[]{tFluidInputs.get(0)}, new ItemStack[]{mInventory[1], tInput}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, tFluidInputs.isEmpty() ? null : new FluidStack[]{tFluidInputs.get(0)}, new ItemStack[]{tInput, mInventory[1]})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + if (tRecipe.mOutputs.length > 0) this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + if (tRecipe.mFluidOutputs.length > 0) + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + updateSlots(); + return true; + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + for (int h = 0; h < 4; h++) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he + if (h == 0) {// innen boden (kantal coils) + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 13) { + return false; + } + } else if (h == 3) {// innen decke (ulv casings + input + muffler) + if ((!addInputToMachineList(tTileEntity, 120)) && (!addMufflerToMachineList(tTileEntity, 120))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { + return false; + } + } + } else {// innen air + if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { + return false; + } + } + } else {// Au�erer 5x5 ohne h�he + if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) + if ((!addMaintenanceToMachineList(tTileEntity, 120)) && (!addOutputToMachineList(tTileEntity, 120)) && (!addEnergyInputToMachineList(tTileEntity, 120))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { + return false; + } + } + } + } else {// au�en �ber boden (ulv casings) + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings1) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { + 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 20; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_PyrolyseOven(this.mName); + } + +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java new file mode 100644 index 0000000000..6bad3005b2 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_VacuumFreezer.java @@ -0,0 +1,150 @@ +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; + +public class GT_MetaTileEntity_VacuumFreezer + extends GT_MetaTileEntity_MultiBlockBase { + public GT_MetaTileEntity_VacuumFreezer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_VacuumFreezer(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_VacuumFreezer(this.mName); + } + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Vacuum Freezer", + "Super cools hot ingots and cells", + "Size(WxHxD): 3x3x3 (Hollow), Controller (Front centered)", + "1x Input Bus (Any casing)", + "1x Output Bus (Any casing)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Frost Proof Casings for the rest (16 at least!)"}; + } + + 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[17], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[17]}; + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); + } + + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sVacuumRecipes; + } + + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sVacuumRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + 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.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + updateSlots(); + return true; + } + } + } + return false; + } + + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 17)) && (!addInputToMachineList(tTileEntity, 17)) && (!addOutputToMachineList(tTileEntity, 17)) && (!addEnergyInputToMachineList(tTileEntity, 17))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings2) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } + + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + public int getAmountOfOutputs() { + return 1; + } + + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file |