diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines')
14 files changed, 2629 insertions, 3104 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java index 9df0d03a1b..0d9fadc6df 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java @@ -1,6 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import gregtech.api.enums.GT_Values; +import static gregtech.api.enums.GT_Values.V; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -13,141 +13,117 @@ import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredMachineBlock { - public int mRange = 16; - - public GregtechMetaTileEntityChunkLoader(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Reprells nasty Creatures. Range: " + (4 + 12 * aTier) - + " unpowered / " + (16 + 48 * aTier) + " powered"); - } - - public GregtechMetaTileEntityChunkLoader(final String aName, final int aTier, final int aInvSlotCount, - final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 512; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return new ITexture[] { - Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - aSide != 1 ? null - : aActive ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) - : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER) - }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return null; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return true; - } - - @Override - public boolean isInputFacing(final byte aSide) { - return true; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - } - - @Override - public long maxAmperesIn() { - return 2; - } - - @Override - public long maxEUInput() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUStore() { - return 512 + GT_Values.V[this.mTier] * 50; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityChunkLoader(this.mName, this.mTier, this.mInventory.length, this.mDescription, - this.mTextures); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - final int[] tCoords = new int[] { - aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), - aBaseMetaTileEntity.getWorld().provider.dimensionId - }; - GT_SpawnEventHandler.mobReps.add(tCoords); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { - if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide()) { - final int[] tCoords = new int[] { - aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), - aBaseMetaTileEntity.getWorld().provider.dimensionId - }; - if (aTimer % 600 == 0 && !GT_SpawnEventHandler.mobReps.contains(tCoords)) { - GT_SpawnEventHandler.mobReps.add(tCoords); - } - if (aBaseMetaTileEntity.isUniversalEnergyStored(this.getMinimumStoredEU()) - && aBaseMetaTileEntity.decreaseStoredEnergyUnits(1 << this.mTier * 2, false)) { - this.mRange = 16 + 48 * this.mTier; - } - else { - this.mRange = 4 + 12 * this.mTier; - } - } - } - - @Override - public void onRemoval() { - final int[] tCoords = new int[] { - this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), - this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId - }; - GT_SpawnEventHandler.mobReps.remove(tCoords); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - } + public int mRange = 16; + + public GregtechMetaTileEntityChunkLoader(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 0, "Reprells nasty Creatures. Range: " + (4 + (12 * aTier)) + " unpowered / " + (16 + (48 * aTier)) + " powered"); + } + + public GregtechMetaTileEntityChunkLoader(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityChunkLoader(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], (aSide != 1) ? null : aActive ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER)}; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide()) { + int[] tCoords = new int[]{aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), aBaseMetaTileEntity.getWorld().provider.dimensionId}; + if ((aTimer % 600 == 0) && !GT_SpawnEventHandler.mobReps.contains(tCoords)) { + GT_SpawnEventHandler.mobReps.add(tCoords); + } + if (aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && aBaseMetaTileEntity.decreaseStoredEnergyUnits(1 << (this.mTier * 2), false)) { + mRange = 16 + (48 * mTier); + } else { + mRange = 4 + (12 * mTier); + } + } + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + int[] tCoords = new int[]{aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), aBaseMetaTileEntity.getWorld().provider.dimensionId}; + GT_SpawnEventHandler.mobReps.add(tCoords); + } + + @Override + public void onRemoval() { + int[] tCoords = new int[]{this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId}; + GT_SpawnEventHandler.mobReps.remove(tCoords); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return true; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public long maxEUStore() { + return 512 + V[mTier] * 50; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java index 102b79111f..4f893cc556 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java @@ -1,126 +1,200 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - -import org.apache.commons.lang3.ArrayUtils; - 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.*; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; +import java.util.Arrays; + 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 org.apache.commons.lang3.ArrayUtils; + public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase { - public static int sUUAperUUM = 1; - public static int sUUASpeedBonus = 4; - public static int sDurationMultiplier = 3215; - public static boolean sRequiresUUA = false; - private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); - // public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); - private int recipeCounter = 0; + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3215; + public static boolean sRequiresUUA = false; + private int recipeCounter = 0; + private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); + //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); - public GregtechMTE_NuclearReactor(final int aID, final String aName, final String aNameRegional) { + public GregtechMTE_NuclearReactor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMTE_NuclearReactor(final String aName) { + public GregtechMTE_NuclearReactor(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - for (int i = -3; i < 3; i++) { + public String[] getDescription() { + return new String[]{ + "Controller Block for the Nuclear Reactor", + "Produces heat from Radioactive beta decay.", + "Size(WxHxD): 5x4x5, Controller (Bottom center)", + "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", + "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", + "1x Input Hatch (Any bottom layer casing)", + "1x Output Hatch (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)", + "24x IC2 Reinforced Glass for the walls", + "Matter Fabricator Casings for the edges & top (40 at least!)", + CORE.GT_Tooltip}; + } + + @Override + 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[66], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) { + } + + @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; + } + } + } + } + + 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 = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.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/**sDurationMultiplier*/) / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = (tRecipe.mDuration/**sDurationMultiplier*/); + 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); + recipeCounter++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+recipeCounter); + return true; + } + } + else { + Utils.LOG_INFO("Invalid Recipe"); + } + } + } + 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 = -3; i < 4; i++) { for (int j = -3; j < 4; j++) { - for (int h = 0; h < 3; h++) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - h, zDir + j); + for (int h = 0; h < 4; h++) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (i != -3 && i != 3 && j != -3 && j != 3) {// Reactor - // Floor/Roof - // inner 7x7 - if (h == 0 || h == 4) {// Reactor Floor & Roof (Inner - // 7x7) + muffler x4 - if (!this.addMufflerToMachineList(tTileEntity, 66)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the top layers inner 3x3."); + if ((i != -3 && i != 3) && (j != -3 && j != 3)) {// Reactor Floor/Roof inner 7x7 + if (h == 0 || h == 4) {// Reactor Floor & Roof (Inner 7x7) + muffler x4 + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the top layers inner 3x3."); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); return false; } } - } - else {// Inside 6 layers, mostly air - if (i != -1 && i != 1 && j != -1 && j != 1) {// Reactor - // Floor/Roof - // inner - // 5x5 + } else {// Inside 6 layers, mostly air + if ((i != -1 && i != 1) && (j != -1 && j != 1)) {// Reactor Floor/Roof inner 5x5 if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); return false; } } - else { // carbon moderation rods are at 1,1 & -1,-1 - // & 1,-1 & -1,1 - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the top layers inner 3x3."); + else { //carbon moderation rods are at 1,1 & -1,-1 & 1,-1 & -1,1 + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the top layers inner 3x3."); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); return false; } - } + } } } // End Inner Workings else {// Reactor Exterior if (h == 1) { - if ((i == -3 || i == 3) && (j == -3 || j == 3)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Block temp = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - Utils.LOG_INFO( - "Reactor Casings Missing from one of the corners in the second layer. Block: "+temp.getLocalizedName() - +" x:"+(aBaseMetaTileEntity.getXCoord()+xDir+i) - +" y:"+(aBaseMetaTileEntity.getYCoord()+h) - +" z:"+(aBaseMetaTileEntity.getZCoord()+zDir+j) - ); + if ((i == -3 || i == 3) && (j == -3 || j == 3)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the corners in the second layer. Meta"); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); return false; } } - else if ((i != -3 || i != 3) && (j != -3 || j != 3)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { + else if ((i != -3 || i != 3) && (j != -3 || j != 3)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); return false; } @@ -131,23 +205,19 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } } if (h == 2) { - if ((i == -3 || i == 3) && (j == -3 || j == 3)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the corners in the third layer."); + if ((i == -3 || i == 3) && (j == -3 || j == 3)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the corners in the third layer."); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); return false; } } - else if ((i != -3 || i != 3) && (j != -3 || j != 3)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { + else if ((i != -3 || i != 3) && (j != -3 || j != 3)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); return false; } @@ -158,15 +228,12 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } } if (h == 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the edges on the top layer."); + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the edges on the top layer."); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); return false; } } @@ -181,143 +248,38 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } - } - - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, - tFluidList.size()); - if (tFluids.length > 0) { - for (int i = 0; i < tFluids.length; i++) { - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe( - this.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 - (this.getIdealStatus() - this.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(this.mOutputFluids); - this.recipeCounter++; - this.updateSlots(); - // Utils.LOG_INFO("Recipes Finished: "+recipeCounter); - return true; - } - } - else { - Utils.LOG_INFO("Invalid Recipe"); - } - } - } - return false; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public int getDamageToComponent(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Nuclear Reactor", "Produces heat from Radioactive beta decay.", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", - "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", - "1x Input Hatch (Any bottom layer casing)", "1x Output Hatch (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)", "24x IC2 Reinforced Glass for the walls", - "Reactor Casings for the edges, bottom & top (40 at least!)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getDamageToComponent(ItemStack aStack) { return 0; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[66], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[66] - }; + public int getAmountOfOutputs() { + return 1; } @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GregtechMTE_NuclearReactor(this.mName); } - @Override - public void onConfigLoad(final GT_Config aConfig) { - } - }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java index 2d9512ce2f..bb7327857a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; @@ -10,242 +7,226 @@ 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.*; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.util.Utils; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_AlloyBlastSmelter extends GT_MetaTileEntity_MultiBlockBase { - private int mHeatingCapacity = 0; - - public GregtechMetaTileEntity_AlloyBlastSmelter(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_AlloyBlastSmelter(final String aName) { - super(aName); - } - - @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final 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; - } - this.addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), 72); - - final byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); - - this.mHeatingCapacity = 20000; - - 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) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 14) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != 14) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 15) { - return false; - } - } - } - } - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (xDir + i != 0 || zDir + j != 0) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - 0, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 72) - && !this.addInputToMachineList(tTileEntity, 72) - && !this.addOutputToMachineList(tTileEntity, 72) - && !this.addEnergyInputToMachineList(tTileEntity, 72)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 15) { - return false; - } - } - } - } - } - this.mHeatingCapacity += 100 * (GT_Utility.getTier(this.getMaxInputVoltage()) - 2); - return true; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 1) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null && this.mHeatingCapacity >= tRecipe.mSpecialValue - && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - Utils.LOG_WARNING("Found some Valid Inputs."); - this.mEfficiency = 10000 - (this.getIdealStatus() - this.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.mOutputFluids = new FluidStack[] { - tRecipe.getFluidOutput(0) - }; - this.updateSlots(); - return true; - } - } - Utils.LOG_WARNING("Failed to find some Valid Inputs."); - return false; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "ElectricBlastFurnace.png"); - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override +public class GregtechMetaTileEntity_AlloyBlastSmelter + extends GT_MetaTileEntity_MultiBlockBase { + private int mHeatingCapacity = 0; + + public GregtechMetaTileEntity_AlloyBlastSmelter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_AlloyBlastSmelter(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); + } + + @Override public String[] getDescription() { - return new String[] { - "Controller Block for the Alloy Blast Smelter", // Outputs 144mb - // fluid for - // every - // inputStack.stackSize; - // Time to use - // those hot - // metals. - "Size: 3x3x4 (Hollow)", "Controller (front middle at bottom)", - "16x Blast Smelter Heat Containment Coils (two middle Layers, hollow)", "1x Input bus (one of bottom)", - "1x Output Hatch (one of bottom)", "1x Energy Hatch (one of bottom)", - "1x Maintenance Hatch (one of bottom)", "1x Muffler Hatch (top middle)", - "Blast Smelter Casings for the rest" - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 10; - } - - @Override + return new String[]{ + "Controller Block for the Alloy Blast Smelter", //Outputs 144mb fluid for every inputStack.stackSize; Time to use those hot metals. + "Size: 3x3x4 (Hollow)", + "Controller (front middle at bottom)", + "16x Blast Smelter Heat Containment Coils (two middle Layers, hollow)", + "1x Input bus (one of bottom)", + "1x Output Hatch (one of bottom)", + "1x Energy Hatch (one of bottom)", + "1x Maintenance Hatch (one of bottom)", + "1x Muffler Hatch (top middle)", + "Blast Smelter Casings for the rest"}; + } + + @Override + 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[72], 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[72]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "ElectricBlastFurnace.png"); + } + + @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[72], - 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[72] - }; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); - } + return Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + 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() > 1) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (this.mHeatingCapacity >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + Utils.LOG_WARNING("Found some Valid Inputs."); + 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.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + updateSlots(); + return true; + } + } + Utils.LOG_WARNING("Failed to find some Valid Inputs."); + return false; + } + + @Override + 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), 72); + + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); + + this.mHeatingCapacity = 20000; + + 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) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 14) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != 14) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 15) { + 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, 72)) && (!addInputToMachineList(tTileEntity, 72)) && (!addOutputToMachineList(tTileEntity, 72)) && (!addEnergyInputToMachineList(tTileEntity, 72))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 15) { + return false; + } + } + } + } + } + this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 10; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java index db857a782d..0838bdefbd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -1,10 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.ArrayUtils; - import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -21,137 +16,111 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +import java.util.ArrayList; +import java.util.List; + 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 GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_MultiBlockBase { - private static boolean controller; - private static boolean isDisabled = false; - private static ITexture frontFace; - private static ITexture frontFaceActive; - private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); - private static CustomIcon GT9_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); - // public static double recipesComplete = 0; - - ArrayList<ItemStack> tInputList = this.getStoredInputs(); +import org.apache.commons.lang3.ArrayUtils; - GT_Recipe mLastRecipe; +public class GregtechMetaTileEntity_IndustrialCentrifuge +extends GregtechMeta_MultiBlockBase { + private static boolean controller; + private static boolean isDisabled = false; + private static ITexture frontFace; + private static ITexture frontFaceActive; + private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static CustomIcon GT9_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + //public static double recipesComplete = 0; - public GregtechMetaTileEntity_IndustrialCentrifuge(final int aID, final String aName, final String aNameRegional) { + public GregtechMetaTileEntity_IndustrialCentrifuge(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - GregtechMetaTileEntity_IndustrialCentrifuge.frontFaceActive = new GT_RenderedTexture( - GregtechMetaTileEntity_IndustrialCentrifuge.GT9_5_Active); - GregtechMetaTileEntity_IndustrialCentrifuge.frontFace = new GT_RenderedTexture( - GregtechMetaTileEntity_IndustrialCentrifuge.GT9_5); + frontFaceActive = new GT_RenderedTexture(GT9_5_Active); + frontFace = new GT_RenderedTexture(GT9_5); } - public GregtechMetaTileEntity_IndustrialCentrifuge(final String aName) { + public GregtechMetaTileEntity_IndustrialCentrifuge(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - /* - * if (configSwitches.disableCentrifugeFormation){ EntityPlayerMP player - * = - * MinecraftServer.getServer().getConfigurationManager().func_152612_a( - * this.getBaseMetaTileEntity().getOwnerName()); if - * (!player.getEntityWorld().isRemote && isDisabled == false) - * PlayerUtils.messagePlayer(player, - * "This Multiblock is disabled via the config. [Only re-enable if you're bugtesting.]" - * ); isDisabled = true; return false; } - */ - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - // Utils.LOG_WARNING("X:"+xDir+" Y:"+yDir+" Z:"+zDir); - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { // X-Dir - for (int j = -1; j < 2; j++) { // Z-Dir - for (int h = -1; h < 2; h++) { // Y-Dir - if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { - - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - // Utils.LOG_WARNING("X:"+tTileEntity.getXCoord()+" - // Y:"+tTileEntity.getYCoord()+" - // Z:"+tTileEntity.getZCoord()); - if (!this.addMaintenanceToMachineList(tTileEntity, 57) - && !this.addInputToMachineList(tTileEntity, 57) - && !this.addOutputToMachineList(tTileEntity, 57) - && !this.addEnergyInputToMachineList(tTileEntity, 57)) { - - // Maintenance Hatch - if (tTileEntity != null && tTileEntity.getMetaTileEntity() != null) { - if (tTileEntity.getXCoord() == aBaseMetaTileEntity.getXCoord() - && tTileEntity.getYCoord() == aBaseMetaTileEntity.getYCoord() - && tTileEntity.getZCoord() == aBaseMetaTileEntity.getZCoord() + 2) { - if (tTileEntity - .getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance) { - Utils.LOG_WARNING("MAINT HATCH IN CORRECT PLACE"); - this.mMaintenanceHatches.add( - (GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this - .getCasingTextureIndex(); - } - else { - return false; - } - } - else { - Utils.LOG_WARNING("MAINT HATCH IN WRONG PLACE"); - } - } + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); + } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { - return false; - } - tAmount++; + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Centrifuge", + "Size: 3x3x3 (Hollow)", + "Controller (Front Center) [Orange]", + "1x Maintenance Hatch (Rear Center) [Green]", + "The rest can be placed anywhere except the Front [Red]", + "1x Input Hatch", + "1x Output Hatch", + "1x Input Bus", + "1x Output Bus", + "1x [EV] Energy Hatch (Can be higher Tier) [Blue]", + "Centrifuge Casings for the rest (16 at least)", + CORE.GT_Tooltip}; + } - } - } - } - } - } - return tAmount >= 16; + + + @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 ? frontFaceActive : frontFace : Textures.BlockIcons.CASING_BLOCKS[57]}; } + @Override - public boolean checkRecipe(final ItemStack aStack) { - /* - * if (!isCorrectMachinePart(mInventory[1])) { return false; } - */ + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialCentrifuge.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + ArrayList<ItemStack> tInputList = getStoredInputs(); + GT_Recipe mLastRecipe; + + @Override + public boolean checkRecipe(ItemStack aStack) { + /*if (!isCorrectMachinePart(mInventory[1])) { + return false; + }*/ Utils.LOG_WARNING("Centrifuge Debug - 1"); - final GT_Recipe.GT_Recipe_Map map = this.getRecipeMap(); + GT_Recipe.GT_Recipe_Map map = getRecipeMap(); if (map == null) { Utils.LOG_WARNING("Centrifuge Debug - False - No recipe map"); return false; } Utils.LOG_WARNING("Centrifuge Debug - 2"); - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - Utils.LOG_WARNING("Centrifuge Debug - Tier variable: " + tTier); - final ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - final FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + ArrayList<ItemStack> tInputList = getStoredInputs(); + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + Utils.LOG_WARNING("Centrifuge Debug - Tier variable: "+tTier); + ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); + ArrayList<FluidStack> tFluidList = getStoredFluids(); + FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); if (tInputList.size() > 0 || tFluids.length > 0) { - final GT_Recipe tRecipe = map.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); if (tRecipe != null) { Utils.LOG_WARNING("Recipe was not invalid"); - this.mLastRecipe = tRecipe; + mLastRecipe = tRecipe; this.mEUt = 0; this.mOutputItems = null; this.mOutputFluids = null; @@ -162,34 +131,29 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu } this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - Utils.LOG_WARNING("Centrifuge Debug - 2 - Max Progress Time: " + this.mMaxProgresstime); + Utils.LOG_WARNING("Centrifuge Debug - 2 - Max Progress Time: "+this.mMaxProgresstime); if (tRecipe.mEUt <= 16) { Utils.LOG_WARNING("Centrifuge Debug - Using < 16eu/t"); - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - Utils.LOG_WARNING("Centrifuge Debug - 3.1 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" - + this.mEUt + " Obscure GT Value " + gregtech.api.enums.GT_Values.V[tTier - 1]); - } - else { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + Utils.LOG_WARNING("Centrifuge Debug - 3.1 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); + } else { Utils.LOG_WARNING("Centrifuge Debug - using > 16eu/t"); this.mEUt = tRecipe.mEUt; this.mMaxProgresstime = tRecipe.mDuration; - Utils.LOG_WARNING("Centrifuge Debug - 3.2 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" - + this.mEUt + " Obscure GT Value " + gregtech.api.enums.GT_Values.V[tTier - 1]); - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { + Utils.LOG_WARNING("Centrifuge Debug - 3.2 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; this.mMaxProgresstime /= 2; - Utils.LOG_WARNING("Centrifuge Debug - 4 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" - + this.mEUt); + Utils.LOG_WARNING("Centrifuge Debug - 4 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); } } this.mEUt *= 1; if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - Utils.LOG_WARNING( - "Centrifuge Debug - 5 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" + this.mEUt); + this.mEUt = (-this.mEUt); + Utils.LOG_WARNING("Centrifuge Debug - 5 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); } ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; for (int h = 0; h < tRecipe.mOutputs.length; h++) { @@ -197,34 +161,30 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu tOut[h].stackSize = 0; } FluidStack tFOut = null; - if (tRecipe.getFluidOutput(0) != null) { - tFOut = tRecipe.getFluidOutput(0).copy(); - } + 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 < 1; g++) { - if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; - } } } } if (tFOut != null) { - final int tSize = tFOut.amount; + int tSize = tFOut.amount; tFOut.amount = tSize * 6; } this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mMaxProgresstime /= 4; - if (this.mMaxProgresstime <= 0) { + if (this.mMaxProgresstime <= 0){ this.mMaxProgresstime++; } - Utils.LOG_WARNING( - "Centrifuge Debug - 6 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" + this.mEUt); - final List<ItemStack> overStacks = new ArrayList<ItemStack>(); + Utils.LOG_WARNING("Centrifuge Debug - 6 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); + 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) { - final ItemStack tmp = tOut[f].copy(); + ItemStack tmp = tOut[f].copy(); tmp.stackSize = tmp.getMaxStackSize(); tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); overStacks.add(tmp); @@ -236,18 +196,14 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu tmp = overStacks.toArray(tmp); tOut = ArrayUtils.addAll(tOut, tmp); } - final List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (final ItemStack tS : tOut) { - if (tS.stackSize > 0) { - tSList.add(tS); - } + 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 - }; - this.updateSlots(); + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); Utils.LOG_WARNING("Centrifuge: True"); return true; } @@ -256,20 +212,11 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu return false; } - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - @SuppressWarnings("static-method") public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } + @SuppressWarnings("static-method") public byte getCasingMeta() { return 0; @@ -281,66 +228,89 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "IndustrialCentrifuge.png"); + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + /*if (configSwitches.disableCentrifugeFormation){ + EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(this.getBaseMetaTileEntity().getOwnerName()); + if (!player.getEntityWorld().isRemote && isDisabled == false) + PlayerUtils.messagePlayer(player, "This Multiblock is disabled via the config. [Only re-enable if you're bugtesting.]"); + isDisabled = true; + return false; + }*/ + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + //Utils.LOG_WARNING("X:"+xDir+" Y:"+yDir+" Z:"+zDir); + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { //X-Dir + for (int j = -1; j < 2; j++) { //Z-Dir + for (int h = -1; h < 2; h++) { //Y-Dir + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + //Utils.LOG_WARNING("X:"+tTileEntity.getXCoord()+" Y:"+tTileEntity.getYCoord()+" Z:"+tTileEntity.getZCoord()); + if ((!addMaintenanceToMachineList(tTileEntity, 57)) && (!addInputToMachineList(tTileEntity, 57)) && (!addOutputToMachineList(tTileEntity, 57)) && (!addEnergyInputToMachineList(tTileEntity, 57))) { + + //Maintenance Hatch + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if (tTileEntity.getXCoord() == aBaseMetaTileEntity.getXCoord() && tTileEntity.getYCoord() == aBaseMetaTileEntity.getYCoord() && tTileEntity.getZCoord() == (aBaseMetaTileEntity.getZCoord()+2)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + Utils.LOG_WARNING("MAINT HATCH IN CORRECT PLACE"); + this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { + return false; + } + } + else { + Utils.LOG_WARNING("MAINT HATCH IN WRONG PLACE"); + } + } + + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { + return false; + } + tAmount++; + + } + } + } + } + } + return tAmount >= 16; } - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Centrifuge", "Size: 3x3x3 (Hollow)", - "Controller (Front Center) [Orange]", "1x Maintenance Hatch (Rear Center) [Green]", - "The rest can be placed anywhere except the Front [Red]", "1x Input Hatch", "1x Output Hatch", - "1x Input Bus", "1x Output Bus", "1x [EV] Energy Hatch (Can be higher Tier) [Blue]", - "Centrifuge Casings for the rest (16 at least)", CORE.GT_Tooltip - }; + @SuppressWarnings("static-method") + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; + } + return false; } @Override - public int getMaxEfficiency(final ItemStack aStack) { + public int getMaxEfficiency(ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; + public int getAmountOfOutputs() { + return 1; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return new ITexture[] { - Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], - aFacing == aSide - ? aActive ? GregtechMetaTileEntity_IndustrialCentrifuge.frontFaceActive - : GregtechMetaTileEntity_IndustrialCentrifuge.frontFace - : Textures.BlockIcons.CASING_BLOCKS[57] - }; - } - - @SuppressWarnings("static-method") - public boolean ignoreController(final Block tTileEntity) { - if (!GregtechMetaTileEntity_IndustrialCentrifuge.controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; - } + public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); - } - }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java index 5d0ceb53e8..c2e2df7a8f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -1,284 +1,278 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; 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.*; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_IndustrialCokeOven extends GregtechMeta_MultiBlockBase { - private int mLevel = 0; - - public GregtechMetaTileEntity_IndustrialCokeOven(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } +public class GregtechMetaTileEntity_IndustrialCokeOven + extends GregtechMeta_MultiBlockBase { + private int mLevel = 0; - public GregtechMetaTileEntity_IndustrialCokeOven(final String aName) { - super(aName); - } + public GregtechMetaTileEntity_IndustrialCokeOven(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } - @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int xr = aBaseMetaTileEntity.getXCoord(); - int yr = aBaseMetaTileEntity.getYCoord(); - int zr = aBaseMetaTileEntity.getZCoord(); - this.mLevel = 0; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - return false; - } - this.addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), - GregtechMetaCasingBlocks.GTID + 1); + public GregtechMetaTileEntity_IndustrialCokeOven(String aName) { + super(aName); + } - final byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); - switch (tUsedMeta) { - case 2: - this.mLevel = 1; - break; - case 3: - this.mLevel = 2; - break; - default: - return false; - } - this.mOutputItems = new ItemStack[12 * this.mLevel]; - 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) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 1) { - return false; - } - } - } - } - for (int i = -1; i < 2; i++) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - // Utils.LOG_WARNING("STEP 1 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); - for (int j = -1; j < 2; j++) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - // Utils.LOG_WARNING("STEP 2 - x ["+xr+"] y ["+yr+"] z - // ["+zr+"]"); - if (xDir + i != 0 || zDir + j != 0) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - // Utils.LOG_WARNING("STEP 3 - x ["+xr+"] y ["+yr+"] z - // ["+zr+"]"); - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - 0, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, GregtechMetaCasingBlocks.GTID + 1) - && !this.addInputToMachineList(tTileEntity, GregtechMetaCasingBlocks.GTID + 1) - && !this.addOutputToMachineList(tTileEntity, GregtechMetaCasingBlocks.GTID + 1) - && !this.addEnergyInputToMachineList(tTileEntity, GregtechMetaCasingBlocks.GTID + 1)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 1) { - return false; - } - } - } - } - } - return true; - } + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); + } - @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + @Override + public String[] getDescription() { + return new String[]{"Processes Logs and Coal into Charcoal and Coal Coke.", + "Controller Block for the Industrial Coke Oven", + "Size: 3x3x3 (Hollow)", + "Controller (front middle at bottom)", + "8x Heat Resistant/Proof Coils (middle Layer, hollow)", + "1x Input (one of bottom)", + "1x Output (one of bottom)", + "1x Energy Hatch (one of bottom)", + "1x Maintenance Hatch (one of bottom)", + "1x Muffler Hatch (top middle)", + "Structural Coke Oven Casings for the rest", + CORE.GT_Tooltip}; + } - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + @Override + 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[GTID+1], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1]}; + } - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "CokeOven.png"); + } - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null && this.mLevel >= tRecipe.mSpecialValue - && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.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 = new FluidStack[] { - tRecipe.getFluidOutput(0) - }; - this.updateSlots(); - // Utils.LOG_INFO("Coke oven: True"); - return true; - } - } - // Utils.LOG_INFO("Coke oven: False"); - return false; - } - /* - * 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[12 * 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; } - */ + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; + + } - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } + /* @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + }*/ - @Override - public int getAmountOfOutputs() { - return 24; - } + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "CokeOven.png"); - } + @Override + 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); - /* - * @Override public boolean isCorrectMachinePart(ItemStack aStack) { return - * true; } - */ + 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); + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (this.mLevel >= 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)}; + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + updateSlots(); + //Utils.LOG_INFO("Coke oven: True"); + return true; + } + } + //Utils.LOG_INFO("Coke oven: False"); + return false; + } + /*public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + if (!tInputList.isEmpty()) { + byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); - @Override - public String[] getDescription() { - return new String[] { - "Processes Logs and Coal into Charcoal and Coal Coke.", "Controller Block for the Industrial Coke Oven", - "Size: 3x3x3 (Hollow)", "Controller (front middle at bottom)", - "8x Heat Resistant/Proof Coils (middle Layer, hollow)", "1x Input (one of bottom)", - "1x Output (one of bottom)", "1x Energy Hatch (one of bottom)", "1x Maintenance Hatch (one of bottom)", - "1x Muffler Hatch (top middle)", "Structural Coke Oven Casings for the rest", CORE.GT_Tooltip - }; - } + int j = 0; + this.mOutputItems = new ItemStack[12 * 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; - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 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; + }*/ - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int xr = aBaseMetaTileEntity.getXCoord(); + int yr = aBaseMetaTileEntity.getYCoord(); + int zr = aBaseMetaTileEntity.getZCoord(); + this.mLevel = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), GTID+1); - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); + switch (tUsedMeta) { + case 2: + this.mLevel = 1; + break; + case 3: + this.mLevel = 2; + break; + default: + return false; + } + this.mOutputItems = new ItemStack[12 * this.mLevel]; + 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) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 1) { + return false; + } + } + } + } + for (int i = -1; i < 2; i++) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 1 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + for (int j = -1; j < 2; j++) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 2 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + if ((xDir + i != 0) || (zDir + j != 0)) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 3 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, GTID+1)) && (!addInputToMachineList(tTileEntity, GTID+1)) && (!addOutputToMachineList(tTileEntity, GTID+1)) && (!addEnergyInputToMachineList(tTileEntity, GTID+1))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 1) { + return false; + } + } + } + } + } + return true; + } - } + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 1], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 1] - }; - } + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } - /* - * @Override public int getDamageToComponent(ItemStack aStack) { return 0; } - */ + /* @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + }*/ - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } + @Override + public int getAmountOfOutputs() { + return 24; + } - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); - } + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java index 16920395f7..1680006afd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java @@ -1,9 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.*; - -import org.apache.commons.lang3.ArrayUtils; - +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -17,154 +14,160 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + 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 GregtechMetaTileEntity_IndustrialElectrolyzer extends GregtechMeta_MultiBlockBase { - ArrayList<ItemStack> tInputList = this.getStoredInputs(); - - GT_Recipe mLastRecipe; +import org.apache.commons.lang3.ArrayUtils; - public GregtechMetaTileEntity_IndustrialElectrolyzer(final int aID, final String aName, - final String aNameRegional) { +public class GregtechMetaTileEntity_IndustrialElectrolyzer +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialElectrolyzer(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialElectrolyzer(final String aName) { + public GregtechMetaTileEntity_IndustrialElectrolyzer(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final 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)) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 62) - && !this.addMufflerToMachineList(tTileEntity, 62) - && !this.addInputToMachineList(tTileEntity, 62) - && !this.addOutputToMachineList(tTileEntity, 62) - && !this.addEnergyInputToMachineList(tTileEntity, 62)) { - final Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - final byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (tBlock != ModBlocks.blockCasingsMisc || tMeta != 5) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); } @Override - public boolean checkRecipe(final ItemStack aStack) { // TODO - Add Check to - // make sure Fluid - // output isn't full - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + public String[] getDescription() { + return new String[]{"Controller Block for the Industrial Electrolyzer", + "Size: 3x3x3 (Hollow)", + "Controller (front centered)", + "1x Input Bus (anywhere)", + "1x Output Bus (anywhere)", + "1x Input Hatch (anywhere)", + "1x Output Hatch (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "1x Muffler (anywhere)", + "Electrolyzer Casings for the rest (16 at least!)", + CORE.GT_Tooltip}; + } - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } + @Override + 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[GTID+5], new GT_RenderedTexture(aActive ? Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE : Textures.BlockIcons.STEAM_TURBINE_SIDE)}; } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5]}; + } - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialElectrolyzer.png"); + } - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null && 7500 >= tRecipe.mSpecialValue - && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.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); + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + ArrayList<ItemStack> tInputList = getStoredInputs(); + GT_Recipe mLastRecipe; - ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; + @Override + public boolean checkRecipe(ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full + 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); + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (7500 >= 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); + + 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(); - } + 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 < 1; g++) { - if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; - } } } } if (tFOut != null) { - final int tSize = tFOut.amount; + int tSize = tFOut.amount; tFOut.amount = tSize * 1; } - - final List<ItemStack> overStacks = new ArrayList<ItemStack>(); + + 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) { - final ItemStack tmp = tOut[f].copy(); + ItemStack tmp = tOut[f].copy(); tmp.stackSize = tmp.getMaxStackSize(); tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); overStacks.add(tmp); @@ -176,100 +179,76 @@ public class GregtechMetaTileEntity_IndustrialElectrolyzer extends GregtechMeta_ tmp = overStacks.toArray(tmp); tOut = ArrayUtils.addAll(tOut, tmp); } - final List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (final ItemStack tS : tOut) { - if (tS.stackSize > 0) { - tSList.add(tS); - } + 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 - }; - this.updateSlots(); - - /* - * this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), - * tRecipe.getOutput(1)}; updateSlots(); - */ - return true; - } - } - return false; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); + + /* this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots();*/ + return true; + } + } + return false; + } @Override - public int getAmountOfOutputs() { - return 1; - } + 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); + } + } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "IndustrialElectrolyzer.png"); - } - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Electrolyzer", "Size: 3x3x3 (Hollow)", - "Controller (front centered)", "1x Input Bus (anywhere)", "1x Output Bus (anywhere)", - "1x Input Hatch (anywhere)", "1x Output Hatch (anywhere)", "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", "1x Muffler (anywhere)", - "Electrolyzer Casings for the rest (16 at least!)", CORE.GT_Tooltip - }; - } + 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, 62)) && (!addMufflerToMachineList(tTileEntity, 62)) && (!addInputToMachineList(tTileEntity, 62)) && (!addOutputToMachineList(tTileEntity, 62)) && (!addEnergyInputToMachineList(tTileEntity, 62))) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (((tBlock != ModBlocks.blockCasingsMisc) || (tMeta != 5))) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } @Override - public int getMaxEfficiency(final ItemStack aStack) { + public int getMaxEfficiency(ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 5], new GT_RenderedTexture(aActive - ? Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE : Textures.BlockIcons.STEAM_TURBINE_SIDE) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 5] - }; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); + public int getAmountOfOutputs() { + return 1; } @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java index 787aa61856..68b2f647ee 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.*; - import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -17,52 +15,182 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -public class GregtechMetaTileEntity_IndustrialMacerator extends GregtechMeta_MultiBlockBase { +public class GregtechMetaTileEntity_IndustrialMacerator +extends GregtechMeta_MultiBlockBase { private static boolean controller; - public GregtechMetaTileEntity_IndustrialMacerator(final int aID, final String aName, final String aNameRegional) { + public GregtechMetaTileEntity_IndustrialMacerator(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialMacerator(final String aName) { + public GregtechMetaTileEntity_IndustrialMacerator(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Maceration Stack", + "Size[WxHxL]: 3x6x3 (Hollow)", + "Controller (Center Bottom)", + "1x Input Bus (Any bottom layer casing)", + "5x Output Bus (Any casing besides bottom layer)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Maceration Stack Casings for the rest (26 at least!)", + CORE.GT_Tooltip}; + } + + @Override + 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[64], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_MatterFab_Active : TexturesGtBlock.Overlay_MatterFab)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MacerationStack.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + } + + /*@Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + }*/ + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, aBaseMetaTileEntity.getYCoord() + 0.3f + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 1.2F - tRandom.nextFloat() * 1.6F, 0.0D, 0.0D, 0.0D); + } + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(201)), 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public void startProcess() { + sendLoopStart((byte) 1); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + + //Get inputs. + 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; + } + } + } + } + + //Temp var + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + //Don't check the recipe if someone got around the output bus size check. + if (this.mOutputBusses.size() != 5){ + return false; + } + + //Make a recipe instance for the rest of the method. + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); + + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { + Utils.LOG_WARNING("Valid Recipe found - size "+tRecipe.mOutputs.length); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + + this.mEUt = (-tRecipe.mEUt); + this.mMaxProgresstime = Math.max(1, (tRecipe.mDuration/5)); + ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; + for (int i = 0; i < tRecipe.mOutputs.length; i++){ + if (i==0) { + Utils.LOG_WARNING("Adding the default output"); + outputs[0] = tRecipe.getOutput(i); + } + else if (getBaseMetaTileEntity().getRandomNumber(7500) < tRecipe.getOutputChance(i)){ + Utils.LOG_WARNING("Adding a bonus output"); + outputs[i] = tRecipe.getOutput(i); + } + else { + Utils.LOG_WARNING("Adding null output"); + outputs[i] = null; + } + } + + this.mOutputItems = outputs; + sendLoopStart((byte) 20); + updateSlots(); + 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; if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { return false; } int tAmount = 0; - GregtechMetaTileEntity_IndustrialMacerator.controller = false; + 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))) + if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 64) - && !this.addInputToMachineList(tTileEntity, 64) - && !this.addOutputToMachineList(tTileEntity, 64) - && !this.addEnergyInputToMachineList(tTileEntity, 64) - && !this.ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 64)) && (!addInputToMachineList(tTileEntity, 64)) && (!addOutputToMachineList(tTileEntity, 64)) && (!addEnergyInputToMachineList(tTileEntity, 64)) && (!ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { Utils.LOG_INFO("Returned False 1"); return false; } @@ -80,18 +208,17 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends GregtechMeta_Mul Utils.LOG_INFO("Returned False 3"); return false; } - final int height = this.getBaseMetaTileEntity().getYCoord(); + int height = this.getBaseMetaTileEntity().getYCoord(); if (this.mInputBusses.get(0).getBaseMetaTileEntity().getYCoord() != height) { - Utils.LOG_INFO("height: " + height + " | Returned False 4"); + Utils.LOG_INFO("height: "+height+" | Returned False 4"); return false; } - final GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; + GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; for (int i = 0; i < this.mOutputBusses.size(); i++) { - final int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; + int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; if (tmpHatches[hatchNumber] == null) { tmpHatches[hatchNumber] = this.mOutputBusses.get(i); - } - else { + } else { Utils.LOG_INFO("Returned False 5"); return false; } @@ -103,181 +230,35 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends GregtechMeta_Mul return tAmount >= 26; } - @Override - public boolean checkRecipe(final ItemStack aStack) { - - // Get inputs. - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - - // Temp var - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - // Don't check the recipe if someone got around the output bus size - // check. - if (this.mOutputBusses.size() != 5) { - return false; - } - - // Make a recipe instance for the rest of the method. - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(this.getBaseMetaTileEntity(), - false, 9223372036854775807L, null, tInputs); - - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); - - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - if (tRecipe != null && tRecipe.isRecipeInputEqual(true, null, tInputs)) { - Utils.LOG_WARNING("Valid Recipe found - size " + tRecipe.mOutputs.length); - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - - this.mEUt = -tRecipe.mEUt; - this.mMaxProgresstime = Math.max(1, tRecipe.mDuration / 5); - final ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; - for (int i = 0; i < tRecipe.mOutputs.length; i++) { - if (i == 0) { - Utils.LOG_WARNING("Adding the default output"); - outputs[0] = tRecipe.getOutput(i); - } - else if (this.getBaseMetaTileEntity().getRandomNumber(7500) < tRecipe.getOutputChance(i)) { - Utils.LOG_WARNING("Adding a bonus output"); - outputs[i] = tRecipe.getOutput(i); - } - else { - Utils.LOG_WARNING("Adding null output"); - outputs[i] = null; - } - } - - this.mOutputItems = outputs; - this.sendLoopStart((byte) 20); - this.updateSlots(); - return true; - } + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; } return false; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 16; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MacerationStack.png"); - } - - /* - * @Override public boolean isCorrectMachinePart(ItemStack aStack) { return - * true; } - */ - - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Maceration Stack", "Size[WxHxL]: 3x6x3 (Hollow)", - "Controller (Center Bottom)", "1x Input Bus (Any bottom layer casing)", - "5x Output Bus (Any casing besides bottom layer)", "1x Maintenance Hatch (Any casing)", - "1x Energy Hatch (Any casing)", "Maceration Stack Casings for the rest (26 at least!)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { + public int getMaxEfficiency(ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + public int getAmountOfOutputs() { + return 16; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[64], new GT_RenderedTexture( - aActive ? TexturesGtBlock.Overlay_MatterFab_Active : TexturesGtBlock.Overlay_MatterFab) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[64] - }; - } - - public boolean ignoreController(final Block tTileEntity) { - if (!GregtechMetaTileEntity_IndustrialMacerator.controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; - } + public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override public boolean isOverclockerUpgradable() { return true; } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); - } - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive() - && aBaseMetaTileEntity.getFrontFacing() != 1 && aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide((byte) 1)) { - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", - aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, - aBaseMetaTileEntity.getYCoord() + 0.3f + tRandom.nextFloat() * 0.2F, - aBaseMetaTileEntity.getZCoord() + 1.2F - tRandom.nextFloat() * 1.6F, 0.0D, 0.0D, 0.0D); - } - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(201)), 10, 1.0F, aX, aY, aZ); - } - } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java index ee15dcd83c..96095698fa 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java @@ -1,8 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -16,200 +14,186 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; + +import java.util.ArrayList; +import java.util.Arrays; + 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 GregtechMetaTileEntity_IndustrialPlatePress extends GregtechMeta_MultiBlockBase { - public GregtechMetaTileEntity_IndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { +public class GregtechMetaTileEntity_IndustrialPlatePress +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialPlatePress(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialPlatePress(final String aName) { + public GregtechMetaTileEntity_IndustrialPlatePress(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final 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)) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 61) - && !this.addMufflerToMachineList(tTileEntity, 61) - && !this.addInputToMachineList(tTileEntity, 61) - && !this.addOutputToMachineList(tTileEntity, 61) - && !this.addEnergyInputToMachineList(tTileEntity, 61)) { - final Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - final byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (tBlock != ModBlocks.blockCasingsMisc || tMeta != 4) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); } @Override - public boolean checkRecipe(final ItemStack aStack) { // TODO - Add Check to - // make sure Fluid - // output isn't full - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBenderRecipes.findRecipe(this.getBaseMetaTileEntity(), - false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null && 2500 >= tRecipe.mSpecialValue - && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.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) - }; - this.updateSlots(); - return true; - } - } - return false; + public String[] getDescription() { + return new String[]{"Controller Block for the Material Press", + "Size: 3x3x3 (Hollow)", + "Controller (front centered)", + "1x Input Bus (anywhere)", + "1x Output Bus (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "1x Muffler (anywhere)", + "Material Press Machine Casings for the rest (16 at least!)", + CORE.GT_Tooltip}; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4]}; } @Override - public int getAmountOfOutputs() { - return 1; + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MaterialPress.png"); } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MaterialPress.png"); + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBenderRecipes; } @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Material Press", "Size: 3x3x3 (Hollow)", "Controller (front centered)", - "1x Input Bus (anywhere)", "1x Output Bus (anywhere)", "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", "1x Muffler (anywhere)", - "Material Press Machine Casings for the rest (16 at least!)", CORE.GT_Tooltip - }; + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; } - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } + @Override + public boolean checkRecipe(ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full + 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); + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBenderRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (2500 >= 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; + } @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } + 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); + } + } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBenderRecipes; - } + 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, 61)) && (!addMufflerToMachineList(tTileEntity, 61)) && (!addInputToMachineList(tTileEntity, 61)) && (!addOutputToMachineList(tTileEntity, 61)) && (!addEnergyInputToMachineList(tTileEntity, 61))) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (((tBlock != ModBlocks.blockCasingsMisc) || (tMeta != 4))) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 4], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 4] - }; + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; + public int getPollutionPerTick(ItemStack aStack) { + return 0; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); + public int getAmountOfOutputs() { + return 1; } @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java index dadb82388d..ee49b7fcb9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java @@ -1,12 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; - 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.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +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; @@ -14,116 +14,167 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_MultiBlockBase { +public class GregtechMetaTileEntity_IndustrialSinter +extends GT_MetaTileEntity_MultiBlockBase { + RenderBlocks asdasd = RenderBlocks.getInstance(); - - public GregtechMetaTileEntity_IndustrialSinter(final int aID, final String aName, final String aNameRegional) { + + public GregtechMetaTileEntity_IndustrialSinter(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialSinter(final String aName) { + public GregtechMetaTileEntity_IndustrialSinter(String aName) { super(aName); } - private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { - return this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()); + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialSinter(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Sinter Furnace", + "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", + "2x Input Bus (side centered)", + "2x Output Bus (side centered)", + "1x Energy Hatch (top or bottom centered)", + "1x Maintenance Hatch (back centered)", + "Sinter Furnace Casings for the rest (32 at least!)", + CORE.GT_Tooltip + }; + } + + @Override + 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[63], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "WireFactory.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; } - private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { - return this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()); + @Override + public 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.sWiremillRecipes.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; } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int controllerX = aBaseMetaTileEntity.getXCoord(); - final int controllerY = aBaseMetaTileEntity.getYCoord(); - final int controllerZ = aBaseMetaTileEntity.getZCoord(); + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int controllerX = aBaseMetaTileEntity.getXCoord(); + int controllerY = aBaseMetaTileEntity.getYCoord(); + int controllerZ = aBaseMetaTileEntity.getZCoord(); - final byte tSide = this.getBaseMetaTileEntity().getBackFacing(); - if (this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 1) - && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 2) - && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), - 3)) { + byte tSide = getBaseMetaTileEntity().getBackFacing(); + if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { 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 (this.getBaseMetaTileEntity().getAirOffset(i, j, k)) { - Utils.LOG_INFO("Found Air at: " + (controllerX + i) + " " + (controllerY + k) + " " - + (controllerZ + k)); - // if (aBaseMetaTileEntity.getWorld().isRemote){ - // asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, - // (controllerX+i), (controllerY+k), - // (controllerZ+k)); - // UtilsRendering.drawBlockInWorld((controllerX+i), - // (controllerY+k), (controllerZ+k), - // Color.YELLOW_GREEN); - // } + if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { + Utils.LOG_INFO("Found Air at: "+(controllerX+i)+" "+(controllerY+k)+" "+(controllerZ+k)); + //if (aBaseMetaTileEntity.getWorld().isRemote){ + //asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, (controllerX+i), (controllerY+k), (controllerZ+k)); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.YELLOW_GREEN); + //} tAirCount++; } } } } if (tAirCount != 10) { - Utils.LOG_INFO("False. Air != 10. Air == " + tAirCount); - // return false; + Utils.LOG_INFO("False. Air != 10. Air == "+tAirCount); + //return false; } for (byte i = 2; i < 6; i = (byte) (i + 1)) { - // UtilsRendering.drawBlockInWorld((controllerX+i), - // (controllerY), (controllerZ), Color.LIME_GREEN); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ), Color.LIME_GREEN); IGregTechTileEntity tTileEntity; - if (null != (tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2)) - && tTileEntity.getFrontFacing() == this.getBaseMetaTileEntity().getFrontFacing() - && tTileEntity.getMetaTileEntity() != null - && tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialSinter) { - // Utils.LOG_INFO("False 1"); + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialSinter))) { + //Utils.LOG_INFO("False 1"); return false; } } - final int tX = this.getBaseMetaTileEntity().getXCoord(); - final int tY = this.getBaseMetaTileEntity().getYCoord(); - final int tZ = this.getBaseMetaTileEntity().getZCoord(); + 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) { + if ((i != 0) || (j != 0)) { for (byte k = 0; k < 5; k = (byte) (k + 1)) { - // UtilsRendering.drawBlockInWorld((controllerX+i), - // (controllerY+k), (controllerZ+k), Color.ORANGE); - if ((i == 0 || j == 0) && (k == 1 || k == 2 || k == 3)) { - // UtilsRendering.drawBlockInWorld((controllerX+i), - // (controllerY+k), (controllerZ+k), - // Color.TOMATO); - if (this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock() - && this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k - : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta()) { - } - else if (!this.addToMachineList(this.getBaseMetaTileEntity().getIGregTechTileEntity( - tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) - && !this.addEnergyInputToMachineList(this.getBaseMetaTileEntity() - .getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)))) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.ORANGE); + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.TOMATO); + 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))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { Utils.LOG_INFO("False 2"); return false; } - } - else if (this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock() - && this.getBaseMetaTileEntity().getMetaID( - tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta()) { - } + } + 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 { Utils.LOG_INFO("False 3"); return false; @@ -139,17 +190,14 @@ public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_M if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { Utils.LOG_INFO("Incorrect amount of Input & Output busses."); return false; - } + } this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity() - .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if (tTileEntity != null && tTileEntity.getMetaTileEntity() != null) { - if (tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance) { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this - .getCasingTextureIndex(); - } - else { + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); return false; } @@ -158,8 +206,7 @@ public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_M Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); return false; } - } - else { + } else { Utils.LOG_INFO("False 5"); return false; } @@ -168,52 +215,18 @@ public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_M } @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (final ItemStack tInput : tInputList) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(this.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 - (this.getIdealStatus() - this.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.updateSlots(); - return true; - } - } - } - return false; + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; + public int getDamageToComponent(ItemStack aStack) { + return 0; } @Override @@ -221,81 +234,30 @@ public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_M return 1; } + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } + public byte getCasingMeta() { return 6; } + public byte getCasingTextureIndex() { return 63; } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "WireFactory.png"); - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Sinter Furnace", "Size: 3x5x3 [WxLxH] (Hollow)", - "Controller (front centered)", "2x Input Bus (side centered)", "2x Output Bus (side centered)", - "1x Energy Hatch (top or bottom centered)", "1x Maintenance Hatch (back centered)", - "Sinter Furnace Casings for the rest (32 at least!)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); } - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[63], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[63] - }; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialSinter(this.mName); + private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { + return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java index f9a633bff5..ca300ba277 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -16,42 +14,117 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; + +import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_MultiBlockBase { - public GregtechMetaTileEntity_IndustrialWireMill(final int aID, final String aName, final String aNameRegional) { +public class GregtechMetaTileEntity_IndustrialWireMill +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialWireMill(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialWireMill(final String aName) { + public GregtechMetaTileEntity_IndustrialWireMill(String aName) { super(aName); } - private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { - return this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()); + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Wire Factory", + "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", + "2x Input Bus (side centered)", + "2x Output Bus (side centered)", + "1x Energy Hatch (top or bottom centered)", + "1x Maintenance Hatch (back centered)", + "Wire Factory Casings for the rest (32 at least!)", + CORE.GT_Tooltip + }; + } + + @Override + 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[63], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63]}; } - private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { - return this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()); + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "WireFactory.png"); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final byte tSide = this.getBaseMetaTileEntity().getBackFacing(); - if (this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 1) - && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 2) - && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), - 3)) { + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + 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.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), new ItemStack[]{tInput}); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + + 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; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + byte tSide = getBaseMetaTileEntity().getBackFacing(); + if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { 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 (this.getBaseMetaTileEntity().getAirOffset(i, j, k)) { + if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { tAirCount++; } } @@ -63,44 +136,30 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult } for (byte i = 2; i < 6; i = (byte) (i + 1)) { IGregTechTileEntity tTileEntity; - if (null != (tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2)) - && tTileEntity.getFrontFacing() == this.getBaseMetaTileEntity().getFrontFacing() - && tTileEntity.getMetaTileEntity() != null - && tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialWireMill) { - // Utils.LOG_INFO("False 1"); + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialWireMill))) { + //Utils.LOG_INFO("False 1"); return false; } } - final int tX = this.getBaseMetaTileEntity().getXCoord(); - final int tY = this.getBaseMetaTileEntity().getYCoord(); - final int tZ = this.getBaseMetaTileEntity().getZCoord(); + 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) { + if ((i != 0) || (j != 0)) { for (byte k = 0; k < 5; k = (byte) (k + 1)) { - if ((i == 0 || j == 0) && (k == 1 || k == 2 || k == 3)) { - if (this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock() - && this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k - : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta()) { - } - else if (!this.addToMachineList(this.getBaseMetaTileEntity().getIGregTechTileEntity( - tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) - && !this.addEnergyInputToMachineList(this.getBaseMetaTileEntity() - .getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)))) { + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { + 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))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { Utils.LOG_INFO("False 2"); return false; } - } - else if (this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock() - && this.getBaseMetaTileEntity().getMetaID( - tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta()) { - } + } + 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 { Utils.LOG_INFO("False 3"); return false; @@ -116,17 +175,14 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { Utils.LOG_INFO("Incorrect amount of Input & Output busses."); return false; - } + } this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity() - .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if (tTileEntity != null && tTileEntity.getMetaTileEntity() != null) { - if (tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance) { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this - .getCasingTextureIndex(); - } - else { + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); return false; } @@ -135,8 +191,7 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); return false; } - } - else { + } else { Utils.LOG_INFO("False 5"); return false; } @@ -145,61 +200,13 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult } @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (final ItemStack tInput : tInputList) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(this.getBaseMetaTileEntity(), - false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[] { - tInput - }); - if (tRecipe != null) { - - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), new ItemStack[] { - tInput - }); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[] { - tInput - })) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.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.updateSlots(); - return true; - } - } - } - } - return false; + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; + public int getPollutionPerTick(ItemStack aStack) { + return 0; } @Override @@ -207,71 +214,30 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult return 1; } + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } + public byte getCasingMeta() { return 6; } + public byte getCasingTextureIndex() { return 63; } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "WireFactory.png"); + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); } - - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Wire Factory", "Size: 3x5x3 [WxLxH] (Hollow)", - "Controller (front centered)", "2x Input Bus (side centered)", "2x Output Bus (side centered)", - "1x Energy Hatch (top or bottom centered)", "1x Maintenance Hatch (back centered)", - "Wire Factory Casings for the rest (32 at least!)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[63], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[63] - }; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); + + private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { + return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java index 1ae8e60885..aa7aecc8c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java @@ -23,460 +23,358 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class GregtechMetaTileEntity_IronBlastFurnace extends MetaTileEntity { - private static final ITexture[] FACING_SIDE = { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) - }; - private static final ITexture[] FACING_FRONT = { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) - }; - private static final ITexture[] FACING_ACTIVE = { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) - }; - public int mMaxProgresstime = 0; - public int mUpdate = 30; - public int mProgresstime = 0; - public boolean mMachine = false; - public ItemStack mOutputItem1; - public ItemStack mOutputItem2; - - public GregtechMetaTileEntity_IronBlastFurnace(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 4); - } - - public GregtechMetaTileEntity_IronBlastFurnace(final String aName) { - super(aName, 4); - } - - 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); - } - } - } - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { - return GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover() - && super.allowCoverOnSide(aSide, aCoverID); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return aIndex > 1; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - if (aIndex < 2) { - } - return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); - } - - private boolean checkMachine() { - final int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 4; j++) { // This is height - for (int k = -1; k < 2; k++) { - if (xDir + i != 0 || j != 0 || zDir + k != 0) { - if (i != 0 || j == -1 || k != 0) { - if (this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, - zDir + k) != ModBlocks.blockCasingsMisc - || this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10) { - return false; - } - } - else if (!GT_Utility.arrayContains( - this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[] { - Blocks.lava, Blocks.flowing_lava, null - }) && !this.getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k)) { - return false; - } - } - } - } - } - return true; - } - - 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 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = 36000; - return true; - } - if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke") - && this.mInventory[1].stackSize >= 2 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = 4800 * 5; - 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 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 9); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = 64800 * 5; - return true; - } - } - else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { - if (this.mInventory[1].getItem() == Items.coal && this.mInventory[1].stackSize >= 2 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, - 2L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = 3600 * 5; - return true; - } - if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke") - && this.mInventory[1].stackSize >= 1 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, - 2L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 1 * 3); - this.mMaxProgresstime = 2400 * 5; - 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 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, - 2L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 9); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = 32400 * 5; - return true; - } - } - else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { - if (this.mInventory[1].getItem() == Items.coal && this.mInventory[1].stackSize >= 36 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 64); - this.mMaxProgresstime = 64800 * 9; - return true; - } - if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke") - && this.mInventory[1].stackSize >= 18 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 18 * 3); - this.mMaxProgresstime = 43200 * 5; - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal") - || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal")) - && this.mInventory[1].stackSize >= 4 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = 64800 * 5; - return true; - } - } - } - this.mOutputItem1 = null; - this.mOutputItem2 = null; - return false; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override +public class GregtechMetaTileEntity_IronBlastFurnace + extends MetaTileEntity { + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; + public int mMaxProgresstime = 0; + public int mUpdate = 30; + public int mProgresstime = 0; + public boolean mMachine = false; + public ItemStack mOutputItem1; + public ItemStack mOutputItem2; + + public GregtechMetaTileEntity_IronBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 4); + } + + public GregtechMetaTileEntity_IronBlastFurnace(String aName) { + super(aName, 4); + } + + @Override public String[] getDescription() { - return new String[] { - "Sloooowly, Skip the Bronze age, Get some Steel!", "Multiblock: 3x3x5 hollow with opening on top", - "40 Iron Plated Bricks required", "----", "Even though Iron melts hotter than bronze,", - "this machine is to help players skip looking", "for tin and copper, which are not as common", - "as Iron is. This machine takes 5x longer than the bronze", "blast furnace as a result.", "----", - CORE.GT_Tooltip - }; - } - - @Override - public int getProgresstime() { - return this.mProgresstime; - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return aActive ? GregtechMetaTileEntity_IronBlastFurnace.FACING_ACTIVE - : GregtechMetaTileEntity_IronBlastFurnace.FACING_FRONT; - } - return GregtechMetaTileEntity_IronBlastFurnace.FACING_SIDE; - } - - @Override - public byte getTileEntityBaseType() { - return 0; - } - - @Override - public int increaseProgress(final int aProgress) { - this.mProgresstime += aProgress; - return this.mMaxProgresstime - this.mProgresstime; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } + return new String[]{"Sloooowly, Skip the Bronze age, Get some Steel!", + "Multiblock: 3x3x5 hollow with opening on top", + "40 Iron Plated Bricks required", + "----", + "Even though Iron melts hotter than bronze,", + "this machine is to help players skip looking", + "for tin and copper, which are not as common", + "as Iron is. This machine takes 5x longer than the bronze", + "blast furnace as a result.", + "----", + CORE.GT_Tooltip}; + } + + @Override + 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; + } + + @Override + public boolean isSteampowered() { + return false; + } - @Override + @Override public boolean isElectric() { - return false; - } + return false; + } - @Override + @Override + public boolean isPneumatic() { + return false; + } + + @Override public boolean isEnetInput() { - return false; - } + return false; + } - @Override + @Override public boolean isEnetOutput() { - return false; - } + return false; + } - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } + @Override + public boolean isInputFacing(byte aSide) { + return false; + } - @Override - public boolean isGivingInformation() { - return false; - } + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } - @Override - public boolean isInputFacing(final byte aSide) { - return false; - } + @Override + public boolean isTeleporterCompatible() { + return false; + } - @Override - public boolean isOutputFacing(final byte aSide) { - return false; - } + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } - @Override - public boolean isPneumatic() { - return false; - } + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } - @Override - public boolean isSteampowered() { - return false; - } + @Override + public int getProgresstime() { + return this.mProgresstime; + } - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mUpdate = 30; - this.mProgresstime = aNBT.getInteger("mProgresstime"); - this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); - this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); - } - - @Override + @Override public int maxProgresstime() { - return this.mMaxProgresstime; - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); - } - - @Override + return this.mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + this.mProgresstime += aProgress; + return this.mMaxProgresstime - this.mProgresstime; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); + } + + @Override + 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); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mUpdate = 30; + this.mProgresstime = aNBT.getInteger("mProgresstime"); + this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); + this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_IronBlastFurnace(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 < 4; j++) { //This is height + 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) != ModBlocks.blockCasingsMisc) || (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; + } + + @Override public void onMachineBlockUpdate() { - this.mUpdate = 30; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { - if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { - aBaseMetaTileEntity.getWorld().spawnParticle("cloud", - 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 = this.checkMachine(); - } - if (this.mMachine) { - if (this.mMaxProgresstime > 0) { - if (++this.mProgresstime >= this.mMaxProgresstime) { - this.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 (final Exception e) { - } - } - } - else if (aBaseMetaTileEntity.isAllowedToWork()) { - this.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; - } - } - } - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mProgresstime", this.mProgresstime); - aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); - if (this.mOutputItem1 != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem1.writeToNBT(tNBT); - aNBT.setTag("mOutputItem1", tNBT); - } - if (this.mOutputItem2 != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem2.writeToNBT(tNBT); - aNBT.setTag("mOutputItem2", tNBT); - } - } - - private boolean spaceForOutput(final ItemStack aStack1, final 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; - } + this.mUpdate = 30; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if ((aBaseMetaTileEntity.isClientSide()) && + (aBaseMetaTileEntity.isActive())) { + aBaseMetaTileEntity.getWorld().spawnParticle("cloud", 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*3); + this.mMaxProgresstime = 36000; + 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*3); + this.mMaxProgresstime = 4800*5; + 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*3); + this.mMaxProgresstime = 64800*5; + 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*3); + this.mMaxProgresstime = 3600*5; + 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*3); + this.mMaxProgresstime = 2400*5; + 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*3); + this.mMaxProgresstime = 32400*5; + 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, 64); + this.mMaxProgresstime = 64800*9; + 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*3); + this.mMaxProgresstime = 43200*5; + 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*3); + this.mMaxProgresstime = 64800*5; + return true; + } + } + } + this.mOutputItem1 = null; + this.mOutputItem2 = null; + return false; + } + + @Override + public boolean isGivingInformation() { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex > 1; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aIndex < 2) { + } + return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); + } + + @Override + public byte getTileEntityBaseType() { + return 0; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java index 15a5224791..cb2996ca97 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java @@ -1,17 +1,17 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - -import org.apache.commons.lang3.ArrayUtils; - -import gregtech.api.enums.*; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.*; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -20,220 +20,125 @@ import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.ArrayUtils; + public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlockBase { - public static int sUUAperUUM = 1; - public static int sUUASpeedBonus = 4; - public static int sDurationMultiplier = 3215; - public static boolean sRequiresUUA = false; - private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); - private int mAmplifierUsed = 0; - private int mMatterProduced = 0; - ItemStack scrapPile = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3215; + public static boolean sRequiresUUA = false; + private int mAmplifierUsed = 0; + private int mMatterProduced = 0; + ItemStack scrapPile = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + ItemStack scrapBox = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + + private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); + FluidStack tempFake = FluidUtils.getFluidStack("uuamplifier", 1); + GT_Recipe fakeRecipe; + + public int getAmplifierUsed(){ + return mAmplifierUsed; + } - ItemStack scrapBox = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); - FluidStack tempFake = FluidUtils.getFluidStack("uuamplifier", 1); - GT_Recipe fakeRecipe; + public int getMatterProduced(){ + return mMatterProduced; + } - public GregtechMetaTileEntity_MassFabricator(final int aID, final String aName, final String aNameRegional) { + public GregtechMetaTileEntity_MassFabricator(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_MassFabricator(final String aName) { + public GregtechMetaTileEntity_MassFabricator(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - final 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++) { - - // Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" - // zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); - - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - h, zDir + j); - /* - * if (tTileEntity != - * Block.getBlockFromItem(UtilsItems.getItem( - * "IC2:blockAlloyGlass"))) { Utils.LOG_INFO("h:"+h+" i:"+i+ - * " j:"+j); double tX = tTileEntity.getXCoord(); double tY - * = tTileEntity.getYCoord(); double tZ = - * tTileEntity.getZCoord(); Utils.LOG_INFO( - * "Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); //return - * false; } - */ - 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) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); - return false; - } - } - else if (h == 3) {// innen decke (ulv casings + input + - // muffler) - if (!this.addMufflerToMachineList(tTileEntity, 66)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - } - } - else {// innen air - if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { - Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); - return false; - } - } - } - else {// Outer 5x5 - if (h == 0) {// au�en boden (controller, output, energy, - // maintainance, rest ulv casings) - if (!this.addMaintenanceToMachineList(tTileEntity, 66) - && !this.addInputToMachineList(tTileEntity, 66) - && !this.addOutputToMachineList(tTileEntity, 66) - && !this.addEnergyInputToMachineList(tTileEntity, 66)) { - if (xDir + i != 0 || zDir + j != 0) {// no - // controller - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges of the bottom layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges of the bottom layer."); - return false; - } - } - } - } - else {// au�en �ber boden (ulv casings) - if (h == 1) { + public String[] getDescription() { + return new String[]{ + "Controller Block for the Matter Fabricator", + "Produces UU-Matter from UU-Amplifier", + "Size(WxHxD): 5x4x5, Controller (Bottom center)", + "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", + "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", + "1x Input Hatch (Any bottom layer casing)", + "1x Output Hatch (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)", + "24x IC2 Reinforced Glass for the walls", + "Matter Fabricator Casings for the edges & top (40 at least!)", + CORE.GT_Tooltip}; + } - if ((i == -2 || i == 2) && (j == -2 || j == 2)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the corners in the second layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the corners in the second layer."); - return false; - } - } + @Override + 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[66], + new GT_RenderedTexture(aActive ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; + } - else if ((i != -2 || i != 2) && (j != -2 || j != 2)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != GregtechMetaTileEntity_MassFabricator.IC2Glass) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); - return false; - } - } - } - if (h == 2) { - if ((i == -2 || i == 2) && (j == -2 || j == 2)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the corners in the third layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the corners in the third layer."); - return false; - } - } + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } - else if ((i != -2 || i != 2) && (j != -2 || j != 2)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != GregtechMetaTileEntity_MassFabricator.IC2Glass) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the third layer."); - return false; - } - } - } - if (h == 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges on the top layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges on the top layer."); - return false; - } - } - } - } - } - } - } - Utils.LOG_INFO("Multiblock Formed."); - return true; + @Override + public void onConfigLoad(GT_Config aConfig) { + super.onConfigLoad(aConfig); + sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUM_Duration_Multiplier", sDurationMultiplier); + sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_per_UUM", sUUAperUUM); + sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Speed_Bonus", sUUASpeedBonus); + sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Requirement", sRequiresUUA); + Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); } @Override - public boolean checkRecipe(final ItemStack aStack) { - //Utils.LOG_INFO("Fabricating Matter."); - if (this.mInputHatches.size() != 1) { - Utils.LOG_INFO("Too many input hatches. Found: " + this.mInputHatches.size() + " | Expected: 1"); + public boolean checkRecipe(ItemStack aStack) { + Utils.LOG_INFO("Fabricating Matter."); + if (mInputHatches.size() != 1){ + Utils.LOG_INFO("Too many input hatches. Found: "+mInputHatches.size()+" | Expected: 1"); return false; } - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); + 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(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + 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 { + } else { tInputList.remove(i--); break; } } } - } + } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); + + + 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(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + 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 { + } else { tFluidList.remove(i--); break; } @@ -241,109 +146,99 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo } } - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, - tFluidList.size()); - - for (int scrapSlots = 0; scrapSlots < tInputs.length; scrapSlots++) { - if (tInputs[scrapSlots].getItem() == this.scrapPile.getItem()) { - if (tInputs[scrapSlots].stackSize >= 9) { - Utils.LOG_INFO("Found enough scrap for a special recipe. x" + tInputs[scrapSlots].stackSize); - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + 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()); + + + for (int scrapSlots=0;scrapSlots<tInputs.length;scrapSlots++){ + if (tInputs[scrapSlots].getItem() == scrapPile.getItem()){ + if (tInputs[scrapSlots].stackSize >= 9 ){ + Utils.LOG_INFO("Found enough scrap for a special recipe. x"+tInputs[scrapSlots].stackSize); + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + if (isValidMetaTileEntity(tHatch)) { Utils.LOG_INFO("Input fluid empty - Time to generate 1UU-A."); - if (tHatch.mFluid == null) { + if (tHatch.mFluid == null){ tHatch.mFluid = FluidUtils.getFluidStack("uuamplifier", 2); } - else { + else{ tHatch.mFluid.amount++; tHatch.mFluid.amount++; } tInputs[scrapSlots].stackSize = tInputs[scrapSlots].stackSize - 9; - Utils.LOG_INFO("Remaining after recipe. x" + tInputs[scrapSlots].stackSize); + Utils.LOG_INFO("Remaining after recipe. x"+tInputs[scrapSlots].stackSize); } } - } + } } } + if (tFluids.length > 0) { Utils.LOG_INFO("Input fluid found"); - for (int i = 0; i < tFluids.length; i++) { - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[] { - tFluids[i] - }, new ItemStack[] {}); + for(int i = 0;i<tFluids.length;i++){ + GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.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 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; + 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 * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = ((tRecipe.mDuration/**sDurationMultiplier*/) / (1 << tTier - 1)); + } else { this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { + this.mMaxProgresstime = (tRecipe.mDuration/**sDurationMultiplier*/); + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 2; this.mMaxProgresstime /= 4; } } if (this.mEUt > 0) { - this.mEUt = -this.mEUt; + this.mEUt = (-this.mEUt); } this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - tRecipe.getOutput(0) - }; + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; this.mOutputFluids = tRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(this.mOutputFluids); - this.mMatterProduced++; - this.mAmplifierUsed++; - this.updateSlots(); - // Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + ArrayUtils.reverse(mOutputFluids); + mMatterProduced++; + mAmplifierUsed++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); return true; } } else { - // Utils.LOG_INFO("Invalid Recipe"); + //Utils.LOG_INFO("Invalid Recipe"); return false; } } } else if (tFluids.length == 0) { Utils.LOG_INFO("Input fluid not found"); - this.fakeRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(this.getBaseMetaTileEntity(), - false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[] { - this.tempFake - }, new ItemStack[] {}); + fakeRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tempFake}, new ItemStack[]{}); - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; this.mEUt = 32; - this.mMaxProgresstime = 160 * 20; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { + this.mMaxProgresstime = (160*20); + 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.mEUt = (-this.mEUt); } - if (this.fakeRecipe != null) { + if (fakeRecipe != null) { this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - this.fakeRecipe.getOutput(0) - }; - this.mOutputFluids = this.fakeRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(this.mOutputFluids); - this.mMatterProduced++; - this.updateSlots(); - // Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + this.mOutputItems = new ItemStack[]{fakeRecipe.getOutput(0)}; + this.mOutputFluids = fakeRecipe.mFluidOutputs.clone(); + ArrayUtils.reverse(mOutputFluids); + mMatterProduced++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); return true; } } @@ -355,85 +250,147 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 10; - } + 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++) { - public int getAmplifierUsed() { - return this.mAmplifierUsed; - } + //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { + Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); + double tX = tTileEntity.getXCoord(); + double tY = tTileEntity.getYCoord(); + double tZ = tTileEntity.getZCoord(); + Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); + //return false; + }*/ + 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) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); + return false; + } + } else if (h == 3) {// innen decke (ulv casings + input + muffler) + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + } + } else {// innen air + if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { + Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); + return false; + } + } + } else {// Outer 5x5 + if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) + if ((!addMaintenanceToMachineList(tTileEntity, 66)) && (!addInputToMachineList(tTileEntity, 66)) && (!addOutputToMachineList(tTileEntity, 66)) && (!addEnergyInputToMachineList(tTileEntity, 66))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); + return false; + } + } + } + } else {// au�en �ber boden (ulv casings) + if (h == 1) { - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); - } + if ((i == -2 || i == 2) && (j == -2 || j == 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + return false; + } + } - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Matter Fabricator", "Produces UU-Matter from UU-Amplifier", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", - "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", - "1x Input Hatch (Any bottom layer casing)", "1x Output Hatch (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)", "24x IC2 Reinforced Glass for the walls", - "Matter Fabricator Casings for the edges & top (40 at least!)", CORE.GT_Tooltip - }; - } + else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { + Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); + return false; + } + } + } + if (h == 2) { + if ((i == -2 || i == 2) && (j == -2 || j == 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); + return false; + } + } - public int getMatterProduced() { - return this.mMatterProduced; + else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { + Utils.LOG_INFO("Glass Casings Missing from somewhere in the third layer."); + return false; + } + } + } + if (h == 3) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); + return false; + } + } + } + } + } + } + } + Utils.LOG_INFO("Multiblock Formed."); + return true; } @Override - public int getMaxEfficiency(final ItemStack aStack) { + public int getMaxEfficiency(ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[66], new GT_RenderedTexture( - aActive ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[66] - }; + public int getAmountOfOutputs() { + return 10; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_MassFabricator(this.mName); + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } @Override - public void onConfigLoad(final GT_Config aConfig) { - super.onConfigLoad(aConfig); - GregtechMetaTileEntity_MassFabricator.sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, - "Massfabricator.UUM_Duration_Multiplier", GregtechMetaTileEntity_MassFabricator.sDurationMultiplier); - GregtechMetaTileEntity_MassFabricator.sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, - "Massfabricator.UUA_per_UUM", GregtechMetaTileEntity_MassFabricator.sUUAperUUM); - GregtechMetaTileEntity_MassFabricator.sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, - "Massfabricator.UUA_Speed_Bonus", GregtechMetaTileEntity_MassFabricator.sUUASpeedBonus); - GregtechMetaTileEntity_MassFabricator.sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, - "Massfabricator.UUA_Requirement", GregtechMetaTileEntity_MassFabricator.sRequiresUUA); - Materials.UUAmplifier.mChemicalFormula = "Mass Fabricator Eff/Speed Bonus: x" - + GregtechMetaTileEntity_MassFabricator.sUUASpeedBonus; + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MassFabricator(this.mName); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java index b4f272bdf3..069652f40d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; @@ -17,6 +14,10 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -24,399 +25,365 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_MultiTank extends GregtechMeta_MultiBlockBase { - private long fluidStored = 0; - - private short multiblockCasingCount = 0; - private short storageMultiplier = this.getStorageMultiplier(); - private long maximumFluidStorage = this.getMaximumTankStorage(); - private FluidStack internalStorageTank = null; - public GregtechMetaTileEntity_MultiTank(final int aID, final String aName, final String aNameRegional) { +public class GregtechMetaTileEntity_MultiTank +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_MultiTank(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_MultiTank(final String aName) { + private long fluidStored = 0; + private short multiblockCasingCount = 0; + private short storageMultiplier = getStorageMultiplier(); + private long maximumFluidStorage = getMaximumTankStorage(); + private FluidStack internalStorageTank = null; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setInteger("mEfficiency", mEfficiency); + aNBT.setInteger("mPollution", mPollution); + aNBT.setInteger("mRuntime", mRuntime); + aNBT.setLong("mFluidStored", fluidStored); + aNBT.setShort("mStorageMultiplier", storageMultiplier); + aNBT.setLong("mMaxFluidStored", maximumFluidStorage); + aNBT.setShort("mCasingCount", multiblockCasingCount); + + if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++) + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + + aNBT.setBoolean("mWrench", mWrench); + aNBT.setBoolean("mScrewdriver", mScrewdriver); + aNBT.setBoolean("mSoftHammer", mSoftHammer); + aNBT.setBoolean("mHardHammer", mHardHammer); + aNBT.setBoolean("mSolderingTool", mSolderingTool); + aNBT.setBoolean("mCrowbar", mCrowbar); + } + + private short getStorageMultiplier(){ + int tempstorageMultiplier = (1*multiblockCasingCount); + if (tempstorageMultiplier <= 0){ + return 1; + } + return (short) tempstorageMultiplier; + } + + private long getMaximumTankStorage(){ + int multiplier = getStorageMultiplier(); + Utils.LOG_WARNING("x = "+multiplier+" * 96000"); + long tempTankStorageMax = (96000*multiplier); + Utils.LOG_WARNING("x = "+tempTankStorageMax); + if (tempTankStorageMax <= 0){ + return 96000; + } + return tempTankStorageMax; + } + + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mEUt = aNBT.getInteger("mEUt"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + if (mMaxProgresstime > 0) mRunningOnLoad = true; + mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + mEfficiency = aNBT.getInteger("mEfficiency"); + mPollution = aNBT.getInteger("mPollution"); + mRuntime = aNBT.getInteger("mRuntime"); + fluidStored = aNBT.getLong("mFluidStored"); + storageMultiplier = aNBT.getShort("mStorageMultiplier"); + maximumFluidStorage = aNBT.getLong("mMaxFluidStored"); + multiblockCasingCount = aNBT.getShort("mCasingCount"); + mOutputItems = new ItemStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + mOutputFluids = new FluidStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputFluids.length; i++) + mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + mWrench = aNBT.getBoolean("mWrench"); + mScrewdriver = aNBT.getBoolean("mScrewdriver"); + mSoftHammer = aNBT.getBoolean("mSoftHammer"); + mHardHammer = aNBT.getBoolean("mHardHammer"); + mSolderingTool = aNBT.getBoolean("mSolderingTool"); + mCrowbar = aNBT.getBoolean("mCrowbar"); + } + + public GregtechMetaTileEntity_MultiTank(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - Utils.LOG_INFO("Must be hollow."); - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 19; h++) { - if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 68) - && !this.addInputToMachineList(tTileEntity, 68) - && !this.addOutputToMachineList(tTileEntity, 68) - && !this.addEnergyInputToMachineList(tTileEntity, 68)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - if (h < 3) { - Utils.LOG_INFO("Casing Expected."); - return false; - } - else if (h >= 3) { - // Utils.LOG_WARNING("Your Multitank can be - // 20 blocks tall."); - } - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { - if (h < 3) { - Utils.LOG_INFO("Wrong Meta."); - return false; - } - else if (h >= 3) { - // Utils.LOG_WARNING("Your Multitank can be - // 20 blocks tall."); - } - } - if (h < 3) { - tAmount++; - } - else if (h >= 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air - || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getUnlocalizedName().contains("residual")) { - Utils.LOG_INFO("Found air"); - } - else { - Utils.LOG_INFO("Layer " + (h + 2) + " is complete. Adding " + 64000 * 9 - + "L storage to the tank."); - tAmount++; - } - } - } - } - } - } + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MultiTank(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Multitank", + "Size: 3xHx3 (Block behind controller must be air)", + "Structure must be at least 4 blocks tall, maximum 20.", + "Each casing within the structure adds 96000L storage.", + "Controller (front centered)", + "1x Input hatch (anywhere)", + "1x Output hatch (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "Multitank Exterior Casings for the rest (16 at least!)", + "Stored Fluid: "+fluidStored}; + } + + @Override + 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[68], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Screen_Logo : TexturesGtBlock.Overlay_Machine_Screen_Logo)}; } - this.multiblockCasingCount = (short) tAmount; - Utils.LOG_INFO("Your Multitank can be 20 blocks tall."); - Utils.LOG_INFO("Casings Count: " + tAmount + " Valid Multiblock: " + (tAmount >= 16) + " Tank Storage Capacity:" - + this.getMaximumTankStorage() + "L"); - return tAmount >= 16; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[68]}; } @Override - public boolean checkRecipe(final ItemStack aStack) { - Utils.LOG_INFO("Okay"); + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); + } - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + Utils.LOG_INFO("Okay"); + + + + 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(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + 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 { + } else { tInputList.remove(i--); break; } } } } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); + 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(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + 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 { + } else { tFluidList.remove(i--); break; } } } } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); - - if (tFluids.length >= 2) { + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); + + if (tFluids.length >= 2){ Utils.LOG_INFO("Bad"); return false; } - - final ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>>(); + + ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>>(); int slotInputCount = 0; - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { boolean containsFluid = false; - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + if (isValidMetaTileEntity(tHatch)) { slotInputCount++; - for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { - if (tHatch.canTankBeEmptied()) { - containsFluid = true; - } + for (int i=0; i<tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { + if (tHatch.canTankBeEmptied()){containsFluid=true;} } rList.add(new Pair<GT_MetaTileEntity_Hatch_Input, Boolean>(tHatch, containsFluid)); } } - if (tFluids.length <= 0 || slotInputCount > 1) { + if (tFluids.length <= 0 || slotInputCount > 1){ Utils.LOG_INFO("Bad"); return false; } - - Utils.LOG_INFO("Okay - 2"); - if (this.internalStorageTank == null) { - if (rList.get(0).getKey().mFluid != null && rList.get(0).getKey().mFluid.amount > 0) { - Utils.LOG_INFO( - "Okay - 1" + " rList.get(0).getKey().mFluid.amount: " + rList.get(0).getKey().mFluid.amount - + " internalStorageTank:" + this.internalStorageTank.amount); - this.internalStorageTank = rList.get(0).getKey().mFluid; - this.internalStorageTank.amount = rList.get(0).getKey().mFluid.amount; + + Utils.LOG_INFO("Okay - 2"); + if (internalStorageTank == null){ + if (rList.get(0).getKey().mFluid != null && rList.get(0).getKey().mFluid.amount > 0){ + Utils.LOG_INFO("Okay - 1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount +" internalStorageTank:"+internalStorageTank.amount); + internalStorageTank = rList.get(0).getKey().mFluid; + internalStorageTank.amount = rList.get(0).getKey().mFluid.amount; rList.get(0).getKey().mFluid.amount = 0; - Utils.LOG_INFO( - "Okay - 1.1" + " rList.get(0).getKey().mFluid.amount: " + rList.get(0).getKey().mFluid.amount - + " internalStorageTank:" + this.internalStorageTank.amount); + Utils.LOG_INFO("Okay - 1.1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount +" internalStorageTank:"+internalStorageTank.amount); return true; } Utils.LOG_INFO("No Fluid in hatch."); - return false; + return false; } - else if (this.internalStorageTank.isFluidEqual(rList.get(0).getKey().mFluid)) { - Utils.LOG_INFO("Storing " + rList.get(0).getKey().mFluid.amount + "L"); - Utils.LOG_INFO("Contains " + this.internalStorageTank.amount + "L"); - + else if (internalStorageTank.isFluidEqual(rList.get(0).getKey().mFluid)){ + Utils.LOG_INFO("Storing "+rList.get(0).getKey().mFluid.amount+"L"); + Utils.LOG_INFO("Contains "+internalStorageTank.amount+"L"); + int tempAdd = 0; tempAdd = rList.get(0).getKey().getFluidAmount(); - rList.get(0).getKey().mFluid = null; - Utils.LOG_INFO("adding " + tempAdd); - this.internalStorageTank.amount = this.internalStorageTank.amount + tempAdd; - Utils.LOG_INFO("Tank now Contains " + this.internalStorageTank.amount + "L of " - + this.internalStorageTank.getFluid().getName() + "."); - - if (this.mOutputHatches.get(0).mFluid == null || this.mOutputHatches.isEmpty()) { - Utils.LOG_INFO("Okay - 3"); - final int tempCurrentStored = this.internalStorageTank.amount; - int tempSubtract = 0; - int tempResult = 0; - final int tempHatchSize = this.mOutputHatches.get(0).getCapacity(); - final FluidStack tempOutputFluid = this.internalStorageTank; - if (tempHatchSize > tempCurrentStored) { - Utils.LOG_INFO("Okay - 3.1.1" + " hatchCapacity: " + tempHatchSize + " tempCurrentStored:" - + tempCurrentStored); - tempOutputFluid.amount = tempHatchSize; - tempSubtract = tempHatchSize; - tempResult = tempCurrentStored - tempSubtract; - Utils.LOG_INFO( - "Okay - 3.1.2" + " result: " + tempResult + " tempCurrentStored:" + tempCurrentStored); - this.mOutputHatches.get(0).mFluid = tempOutputFluid; - this.internalStorageTank.amount = tempResult; - } - else if (tempCurrentStored >= 5000) { - Utils.LOG_INFO("Okay - 3.2"); - tempOutputFluid.amount = tempCurrentStored; - tempSubtract = tempOutputFluid.amount; - tempResult = tempCurrentStored - tempSubtract; - this.mOutputHatches.get(0).mFluid = tempOutputFluid; - this.internalStorageTank.amount = tempResult; - } - Utils.LOG_INFO("Tank"); - return true; - } - else if (this.mOutputHatches.get(0).mFluid.isFluidEqual(this.internalStorageTank)) { - Utils.LOG_INFO("Okay - 4"); - final int tempCurrentStored = this.internalStorageTank.amount; - int tempSubtract = 0; - int tempResult = 0; - final int tempHatchSize = this.mOutputHatches.get(0).getCapacity(); - final FluidStack tempOutputFluid = this.internalStorageTank; - if (tempHatchSize > tempCurrentStored) { - tempOutputFluid.amount = tempHatchSize; - tempSubtract = tempOutputFluid.amount; - tempResult = tempCurrentStored - tempSubtract; - this.mOutputHatches.get(0).mFluid = tempOutputFluid; - this.internalStorageTank.amount = tempResult; - } - else if (tempCurrentStored >= 5000) { - tempOutputFluid.amount = tempCurrentStored; - tempSubtract = tempOutputFluid.amount; - tempResult = tempCurrentStored - tempSubtract; - this.mOutputHatches.get(0).mFluid = tempOutputFluid; - this.internalStorageTank.amount = tempResult; + rList.get(0).getKey().mFluid = null; + Utils.LOG_INFO("adding "+tempAdd); + internalStorageTank.amount = internalStorageTank.amount + tempAdd; + Utils.LOG_INFO("Tank now Contains "+internalStorageTank.amount+"L of "+internalStorageTank.getFluid().getName()+"."); + + if (mOutputHatches.get(0).mFluid == null || mOutputHatches.isEmpty()){ + Utils.LOG_INFO("Okay - 3"); + int tempCurrentStored = internalStorageTank.amount; + int tempSubtract = 0; + int tempResult = 0; + int tempHatchSize = mOutputHatches.get(0).getCapacity(); + FluidStack tempOutputFluid = internalStorageTank; + if (tempHatchSize > tempCurrentStored){ + Utils.LOG_INFO("Okay - 3.1.1"+" hatchCapacity: "+tempHatchSize +" tempCurrentStored:"+tempCurrentStored); + tempOutputFluid.amount = tempHatchSize; + tempSubtract = tempHatchSize; + tempResult = tempCurrentStored - tempSubtract; + Utils.LOG_INFO("Okay - 3.1.2"+" result: "+tempResult +" tempCurrentStored:"+tempCurrentStored); + mOutputHatches.get(0).mFluid = tempOutputFluid; + internalStorageTank.amount = tempResult; + } + else if (tempCurrentStored >= 5000){ + Utils.LOG_INFO("Okay - 3.2"); + tempOutputFluid.amount = tempCurrentStored; + tempSubtract = tempOutputFluid.amount; + tempResult = tempCurrentStored - tempSubtract; + mOutputHatches.get(0).mFluid = tempOutputFluid; + internalStorageTank.amount = tempResult; + } + Utils.LOG_INFO("Tank"); + return true; } + else if (mOutputHatches.get(0).mFluid.isFluidEqual(internalStorageTank)){ + Utils.LOG_INFO("Okay - 4"); + int tempCurrentStored = internalStorageTank.amount; + int tempSubtract = 0; + int tempResult = 0; + int tempHatchSize = mOutputHatches.get(0).getCapacity(); + FluidStack tempOutputFluid = internalStorageTank; + if (tempHatchSize > tempCurrentStored){ + tempOutputFluid.amount = tempHatchSize; + tempSubtract = tempOutputFluid.amount; + tempResult = tempCurrentStored - tempSubtract; + mOutputHatches.get(0).mFluid = tempOutputFluid; + internalStorageTank.amount = tempResult; + } + else if (tempCurrentStored >= 5000){ + tempOutputFluid.amount = tempCurrentStored; + tempSubtract = tempOutputFluid.amount; + tempResult = tempCurrentStored - tempSubtract; + mOutputHatches.get(0).mFluid = tempOutputFluid; + internalStorageTank.amount = tempResult; + } + Utils.LOG_INFO("Tank"); + return true; + } Utils.LOG_INFO("Tank"); - return true; - } - Utils.LOG_INFO("Tank"); return true; } else { - Utils.LOG_INFO("Tank Contains " + this.internalStorageTank.amount + "L of " - + this.internalStorageTank.getFluid().getName() + "."); + Utils.LOG_INFO("Tank Contains "+internalStorageTank.amount+"L of "+internalStorageTank.getFluid().getName()+"."); } - // this.getBaseMetaTileEntity().(tFluids[0].amount, true); + //this.getBaseMetaTileEntity().(tFluids[0].amount, true); Utils.LOG_INFO("Tank"); return false; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "VacuumFreezer.png"); - } - - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Multitank", "Size: 3xHx3 (Block behind controller must be air)", - "Structure must be at least 4 blocks tall, maximum 20.", - "Each casing within the structure adds 96000L storage.", "Controller (front centered)", - "1x Input hatch (anywhere)", "1x Output hatch (anywhere)", "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", "Multitank Exterior Casings for the rest (16 at least!)", - "Stored Fluid: " + this.fluidStored - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - private long getMaximumTankStorage() { - final int multiplier = this.getStorageMultiplier(); - Utils.LOG_WARNING("x = " + multiplier + " * 96000"); - final long tempTankStorageMax = 96000 * multiplier; - Utils.LOG_WARNING("x = " + tempTankStorageMax); - if (tempTankStorageMax <= 0) { - return 96000; - } - return tempTankStorageMax; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - private short getStorageMultiplier() { - final int tempstorageMultiplier = 1 * this.multiblockCasingCount; - if (tempstorageMultiplier <= 0) { - return 1; + 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)) { + Utils.LOG_INFO("Must be hollow."); + return false; } - return (short) tempstorageMultiplier; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[68], new GT_RenderedTexture(aActive - ? TexturesGtBlock.Overlay_Machine_Screen_Logo : TexturesGtBlock.Overlay_Machine_Screen_Logo) - }; + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 19; 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, 68)) && (!addInputToMachineList(tTileEntity, 68)) && (!addOutputToMachineList(tTileEntity, 68)) && (!addEnergyInputToMachineList(tTileEntity, 68))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + if (h < 3){ + Utils.LOG_INFO("Casing Expected."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { + if (h < 3){ + Utils.LOG_INFO("Wrong Meta."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (h < 3){ + tAmount++; + } + else if (h >= 3){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ + Utils.LOG_INFO("Found air"); + } + else { + Utils.LOG_INFO("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); + tAmount++; + } + } + } + } + } + } } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[68] - }; + multiblockCasingCount = (short) tAmount; + Utils.LOG_INFO("Your Multitank can be 20 blocks tall."); + Utils.LOG_INFO("Casings Count: "+tAmount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+getMaximumTankStorage()+"L"); + return tAmount >= 16; } @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mEUt = aNBT.getInteger("mEUt"); - this.mProgresstime = aNBT.getInteger("mProgresstime"); - this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - if (this.mMaxProgresstime > 0) { - this.mRunningOnLoad = true; - } - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mEfficiency = aNBT.getInteger("mEfficiency"); - this.mPollution = aNBT.getInteger("mPollution"); - this.mRuntime = aNBT.getInteger("mRuntime"); - this.fluidStored = aNBT.getLong("mFluidStored"); - this.storageMultiplier = aNBT.getShort("mStorageMultiplier"); - this.maximumFluidStorage = aNBT.getLong("mMaxFluidStored"); - this.multiblockCasingCount = aNBT.getShort("mCasingCount"); - this.mOutputItems = new ItemStack[this.getAmountOfOutputs()]; - for (int i = 0; i < this.mOutputItems.length; i++) { - this.mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - } - this.mOutputFluids = new FluidStack[this.getAmountOfOutputs()]; - for (int i = 0; i < this.mOutputFluids.length; i++) { - this.mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); - } - this.mWrench = aNBT.getBoolean("mWrench"); - this.mScrewdriver = aNBT.getBoolean("mScrewdriver"); - this.mSoftHammer = aNBT.getBoolean("mSoftHammer"); - this.mHardHammer = aNBT.getBoolean("mHardHammer"); - this.mSolderingTool = aNBT.getBoolean("mSolderingTool"); - this.mCrowbar = aNBT.getBoolean("mCrowbar"); + public int getPollutionPerTick(ItemStack aStack) { + return 0; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_MultiTank(this.mName); + public int getAmountOfOutputs() { + return 1; } @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mEUt", this.mEUt); - aNBT.setInteger("mProgresstime", this.mProgresstime); - aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); - aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); - aNBT.setInteger("mEfficiency", this.mEfficiency); - aNBT.setInteger("mPollution", this.mPollution); - aNBT.setInteger("mRuntime", this.mRuntime); - aNBT.setLong("mFluidStored", this.fluidStored); - aNBT.setShort("mStorageMultiplier", this.storageMultiplier); - aNBT.setLong("mMaxFluidStored", this.maximumFluidStorage); - aNBT.setShort("mCasingCount", this.multiblockCasingCount); - - if (this.mOutputItems != null) { - for (int i = 0; i < this.mOutputItems.length; i++) { - if (this.mOutputItems[i] != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItems[i].writeToNBT(tNBT); - aNBT.setTag("mOutputItem" + i, tNBT); - } - } - } - if (this.mOutputFluids != null) { - for (int i = 0; i < this.mOutputFluids.length; i++) { - if (this.mOutputFluids[i] != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputFluids[i].writeToNBT(tNBT); - aNBT.setTag("mOutputFluids" + i, tNBT); - } - } - } - - aNBT.setBoolean("mWrench", this.mWrench); - aNBT.setBoolean("mScrewdriver", this.mScrewdriver); - aNBT.setBoolean("mSoftHammer", this.mSoftHammer); - aNBT.setBoolean("mHardHammer", this.mHardHammer); - aNBT.setBoolean("mSolderingTool", this.mSolderingTool); - aNBT.setBoolean("mCrowbar", this.mCrowbar); + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java index 1006f68da7..45635ea74d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java @@ -17,144 +17,131 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTileEntity_MultiBlockBase { - private final int recipeCounter = 0; + private int recipeCounter = 0; - public GregtechMetaTileEntity_PowerSubStationController(final int aID, final String aName, - final String aNameRegional) { + public GregtechMetaTileEntity_PowerSubStationController(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_PowerSubStationController(final String aName) { + public GregtechMetaTileEntity_PowerSubStationController(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + public String[] getDescription() { + return new String[]{ + "Controller Block for the Power Sub-Station", + "Stores quite a lot of power.", + "Size(WxHxD): 1x5x1, Controller (One above the Bottom)", + CORE.GT_Tooltip}; + } + + @Override + 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[67], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[67]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) { + super.onConfigLoad(aConfig); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + return false; + } + + @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 = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { for (int h = 0; h < 4; h++) { - // Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" - // zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); - - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - h, zDir + j); - /* - * if (tTileEntity != - * Block.getBlockFromItem(UtilsItems.getItem( - * "IC2:blockAlloyGlass"))) { Utils.LOG_INFO("h:"+h+" i:"+i+ - * " j:"+j); double tX = tTileEntity.getXCoord(); double tY - * = tTileEntity.getYCoord(); double tZ = - * tTileEntity.getZCoord(); Utils.LOG_INFO( - * "Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); //return - * false; } - */ - if (i != -2 && i != 2 && j != -2 && j != 2) {// innerer 3x3 - // ohne h�he - if (h == 0 && i != 0 && j != 0) {// innen boden (kantal - // coils) - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Block"); - Utils.LOG_INFO("Found: " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName() - + " at x:" + (xDir + i) + " y:" + h + " z:" + (zDir + j)); - // tTileEntity.getWorld().setBlock(xDir+i, h, - // zDir+j, Blocks.diamond_block); - // Utils.LOG_INFO("Changed into : - // "+aBaseMetaTileEntity.getBlockOffset(xDir + - // i, h, zDir + j).getUnlocalizedName()); + //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { + Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); + double tX = tTileEntity.getXCoord(); + double tY = tTileEntity.getYCoord(); + double tZ = tTileEntity.getZCoord(); + Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); + //return false; + }*/ + if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he + if (h == 0 && i != 0 && j != 0) {// innen boden (kantal coils) + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Block"); + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); + //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO( - "Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Meta"); + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Meta"); return false; } - } - else if (h == 3 && i != 0 && j != 0) {// innen decke - // (ulv casings - // + input + - // muffler) - // if(j == 0 && i == 0) { - - if (!this.addMufflerToMachineList(tTileEntity, 66)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Found: " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getUnlocalizedName() - + " at x:" + (xDir + i) + " y:" + h + " z:" + (zDir + j)); - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO("Found: " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getUnlocalizedName() - + " at x:" + (xDir + i) + " y:" + h + " z:" + (zDir + j)); - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } + } + else if (h == 3 && i != 0 && j != 0) {// innen decke (ulv casings + input + muffler) + //if(j == 0 && i == 0) { + + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + } + //} + + } /*else {// top air + if ((i != -2 && i != 2) && (j != -2 && j != 2) && h == 3) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Block"); + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); + //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); + return false; } - // } - - } /* - * else {// top air if ((i != -2 && i != 2) && (j != - * -2 && j != 2) && h == 3) { if - * (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - * zDir + j) != ModBlocks.blockCasingsMisc) { - * Utils.LOG_INFO( - * "Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Block" - * ); Utils.LOG_INFO("Found: " - * +aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - * zDir + j).getUnlocalizedName()+" at x:"+(xDir + - * i)+" y:" +h+" z:"+(zDir + j)); - * //tTileEntity.getWorld().setBlock(xDir+i, h, - * zDir+j, Blocks.diamond_block); //Utils.LOG_INFO( - * "Changed into : " - * +aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - * zDir + j).getUnlocalizedName()); return false; } - * if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, - * h, zDir + j) != 4) { Utils.LOG_INFO( - * "Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Meta" - * ); return false; } } } - */ - } - else {// Outer 5x5 - if (h == 0) {// au�en boden (controller, output, energy, - // maintainance, rest ulv casings) - if (!this.addEnergyInputToMachineList(tTileEntity, 66) - && !this.addDynamoToMachineList(tTileEntity, 66)) { - if (xDir + i != 0 || zDir + j != 0) {// no - // controller - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Found: " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getUnlocalizedName() - + " at x:" + (xDir + i) + " y:" + h + " z:" + (zDir + j)); - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges of the bottom layer. " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getLocalizedName()); + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { + Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Meta"); + return false; + } + } + }*/ + } else {// Outer 5x5 + if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) + if ((!addEnergyInputToMachineList(tTileEntity, 66) && (!addDynamoToMachineList(tTileEntity, 66)))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer. "+(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName())); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges of the bottom layer. 2"); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer. 2"); return false; } } } - } - else { - + } else { + } } } @@ -165,77 +152,38 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil } @Override - public boolean checkRecipe(final ItemStack aStack) { - return false; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public int getDamageToComponent(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Power Sub-Station", "Stores quite a lot of power.", - "Size(WxHxD): 1x5x1, Controller (One above the Bottom)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getDamageToComponent(ItemStack aStack) { return 0; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[67], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[67] - }; + public int getAmountOfOutputs() { + return 1; } @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GregtechMetaTileEntity_PowerSubStationController(this.mName); } - @Override - public void onConfigLoad(final GT_Config aConfig) { - super.onConfigLoad(aConfig); - } - }
\ No newline at end of file |