diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-09-07 16:36:25 +1000 |
commit | 221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch) | |
tree | d6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/xmod/gregtech/common/tileentities | |
parent | 5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff) | |
download | GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2 GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip |
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities')
15 files changed, 3596 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java new file mode 100644 index 0000000000..c2cadab478 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GT_MetaTileEntity_Boiler_Solar.java @@ -0,0 +1,144 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.common.gui.GT_Container_Boiler; +import gregtech.common.gui.GT_GUIContainer_Boiler; +import gregtech.common.tileentities.boilers.GT_MetaTileEntity_Boiler; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +public class GT_MetaTileEntity_Boiler_Solar + extends GT_MetaTileEntity_Boiler { + public GT_MetaTileEntity_Boiler_Solar(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, "Steam Power by the Sun", new ITexture[0]); + } + + public GT_MetaTileEntity_Boiler_Solar(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[4][17][]; + for (byte i = -1; i < 16; i = (byte) (i + 1)) { + ITexture[] tmp0 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; + rTextures[0][(i + 1)] = tmp0; + ITexture[] tmp1 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_SOLAR)}; + rTextures[1][(i + 1)] = tmp1; + ITexture[] tmp2 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; + rTextures[2][(i + 1)] = tmp2; + ITexture[] tmp3 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE)}; + rTextures[3][(i + 1)] = tmp3; + } + return rTextures; + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[aSide >= 2 ? ((byte) (aSide != aFacing ? 2 : 3)) : aSide][aColorIndex + 1]; + } + + public int maxProgresstime() { + return 500; + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 16000); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Solar(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + private int mRunTime = 0; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mRunTime", this.mRunTime); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mRunTime = aNBT.getInteger("mRunTime"); + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { + if (this.mTemperature <= 20) { + this.mTemperature = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 45) { + this.mTemperature -= 1; + this.mLossTimer = 0; + } + if (this.mSteam != null) { + byte i = aBaseMetaTileEntity.getFrontFacing(); + IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + if (tTileEntity != null) { + FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); + if (tDrained != null) { + int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); + if (tFilledAmount > 0) { + tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); + } + } + } + } + if (aTick % 25L == 0L) { + if (this.mTemperature > 100) { + if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { + this.mHadNoWater = true; + } else { + if (this.mHadNoWater) { + aBaseMetaTileEntity.doExplosion(2048L); + return; + } + this.mFluid.amount -= 1; + mRunTime += 1; + int tOutput = 150; + if(mRunTime > 10000){ + tOutput = Math.max(50, 150 - ((mRunTime-10000)/100)); + } + if (this.mSteam == null) { + this.mSteam = GT_ModHandler.getSteam(tOutput); + } else if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += tOutput; + } else { + this.mSteam = GT_ModHandler.getSteam(tOutput); + } + } + } else { + this.mHadNoWater = false; + } + } + if ((this.mSteam != null) && + (this.mSteam.amount > 16000)) { + sendSound((byte) 1); + this.mSteam.amount = 12000; + } + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 256L == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { + boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && aBaseMetaTileEntity.getBiome().rainfall > 0.0F; + mProcessingEnergy += bRain && aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4 || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; + } + if ((this.mTemperature < 500) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) { + this.mProcessingEnergy -= 1; + this.mTemperature += 1; + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java new file mode 100644 index 0000000000..20ebd611a2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -0,0 +1,119 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; + +public class GregtechMetaTileEntityRocketFuelGenerator + extends GregtechRocketFuelGeneratorBase { + + public int mEfficiency; + + public GregtechMetaTileEntityRocketFuelGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires liquid Fuel", new ITexture[0]); + onConfigLoad(); + } + + public GregtechMetaTileEntityRocketFuelGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + + @Override + public int getCapacity() { + return 32000; + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, (100 - this.mTier * 8)); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(ItemStack aStack) { + int rValue = Math.max(GT_ModHandler.getFuelCanValue(aStack) * 6 / 5, super.getFuelValue(aStack)); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3); + } + return rValue; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK)}; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM)}; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP)}; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE)}; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE)}; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE)}; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE)}; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE)}; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java new file mode 100644 index 0000000000..c41c1851fa --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java @@ -0,0 +1,174 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import static gregtech.api.enums.GT_Values.V; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_SolarGenerator; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_SolarGenerator; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechMetaSolarGenerator; +import net.minecraft.entity.player.InventoryPlayer; + +public class GregtechMetaTileEntitySolarGenerator extends GregtechMetaSolarGenerator { + + public GregtechMetaTileEntitySolarGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Feasts on the power of the Sun!", new ITexture[0]); + onConfigLoad(); + } + + public GregtechMetaTileEntitySolarGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, 16000); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntitySolarGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "SunAbsorber.efficiency.tier." + this.mTier, 100 - this.mTier * 10); + + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() + && aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()) { + + if (this.mSolarCharge <= 20) { + //Utils.LOG_WARNING("1."); + this.mSolarCharge = 20; + this.mLossTimer = 0; + } + if (++this.mLossTimer > 45) { + //Utils.LOG_WARNING("2."); + this.mSolarCharge -= 1; + this.mLossTimer = 0; + } + + if (aTick % 10L == 0L) { + + Utils.LOG_WARNING("getUniversalEnergyStored: "+aBaseMetaTileEntity.getUniversalEnergyStored() + " maxEUOutput * 20 + getMinimumStoredEU: " + (maxEUOutput() * 20 + getMinimumStoredEU())); + + if ((this.mSolarCharge > 100) && (aBaseMetaTileEntity.isAllowedToWork()) && + (!aBaseMetaTileEntity.getWorld().isThundering()) && + aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUStore() - getMinimumStoredEU())) { + getBaseMetaTileEntity().increaseStoredEnergyUnits(sEnergyPerTick * getEfficiency(), true); + } + } + + if ((this.mSolarCharge < 500) && (this.mProcessingEnergy != 0) && (aTick % 32L == 0L)) { + Utils.LOG_WARNING("Adding Solar Charge. Currently "+mSolarCharge); + this.mProcessingEnergy -= 1; + this.mSolarCharge += 1; + } + + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 64L == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { + Utils.LOG_WARNING("Adding Processing Energy. Currently "+mProcessingEnergy); + boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && aBaseMetaTileEntity.getBiome().rainfall > 0.0F; + mProcessingEnergy += bRain && aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4 || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; + } + + if (aBaseMetaTileEntity.isServerSide()){ + //Utils.LOG_WARNING("6."); + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); + } + } + } + + @Override + public void inValidate() { + + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[mTier] * 16000 + getMinimumStoredEU()); + } + + + ITexture SolarArray[] = {new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_8V), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_MV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_HV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_EV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV), + new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_ZPM), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_UV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java new file mode 100644 index 0000000000..5d1befbbad --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java @@ -0,0 +1,104 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.generators; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GregtechMetaSuperConductorNodeBase; + +public class GregtechMetaTileEntitySuperCondensor + extends GregtechMetaSuperConductorNodeBase { + + public int mEfficiency; + + public GregtechMetaTileEntitySuperCondensor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires liquid Nitrogen/Helium", new ITexture[0]); + onConfigLoad(); + } + + public GregtechMetaTileEntitySuperCondensor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntitySuperCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipes() { + return GT_Recipe.GT_Recipe_Map.sDieselFuels; + } + + @Override + public int getCapacity() { + return 64000; + } + + public void onConfigLoad() { + this.mEfficiency = 100; + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP)}; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE)}; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTENuclearReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTENuclearReactor.java new file mode 100644 index 0000000000..32bae133ba --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTENuclearReactor.java @@ -0,0 +1,287 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_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.UtilsItems; +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 GregtechMTENuclearReactor 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 int recipeCounter = 0; + private static Block IC2Glass = Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass")); + //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); + + public GregtechMTENuclearReactor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMTENuclearReactor(String aName) { + super(aName); + } + + @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", + "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 = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + for (int h = 0; h < 4; h++) { + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + + if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he + if (h == 0) {// inner floor 3x3 + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Coils missings from the bottom layer, inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { + Utils.LOG_INFO("Coils missings from the bottom layer, inner 3x3."); + return false; + } + } else if (h == 3) {//Roofing blocks 3x3 (casings + input + muffler) + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Casings Missing from one of the top layers inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Casings Missing from one of the top layers inner 3x3."); + return false; + } + } + } else {// Inner Air section, may require blocks here. + 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) { + + 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; + } + } + + 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; + } + } + + 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 boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMTENuclearReactor(this.mName); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java new file mode 100644 index 0000000000..13ae8e424f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCentrifuge.java @@ -0,0 +1,326 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.CORE.configSwitches; +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 java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.server.MinecraftServer; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.ArrayUtils; + +public class GregtechMetaTileEntityIndustrialCentrifuge +extends GregtechMeta_MultiBlockBase { + private static boolean controller; + private static boolean isDisabled = false; + private static ITexture frontFace; + private static ITexture frontFaceActive; + private static Textures.BlockIcons.CustomIcon GT9_5_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST_ACTIVE5"); + private static Textures.BlockIcons.CustomIcon GT9_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ST5"); + private static Textures.BlockIcons.CustomIcon GT8_5_Active = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE_ACTIVE5"); + private static Textures.BlockIcons.CustomIcon GT8_5 = new Textures.BlockIcons.CustomIcon("iconsets/LARGETURBINE5"); + //public static double recipesComplete = 0; + + public GregtechMetaTileEntityIndustrialCentrifuge(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + frontFaceActive = new GT_RenderedTexture(GT9_5_Active); + frontFace = new GT_RenderedTexture(GT9_5); + } + else{ + frontFaceActive = new GT_RenderedTexture(GT8_5_Active); + frontFace = new GT_RenderedTexture(GT8_5); + } + } + + public GregtechMetaTileEntityIndustrialCentrifuge(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrialCentrifuge(this.mName); + } + + @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}; + } + + + + @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 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"); + 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"); + 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) { + 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"); + mLastRecipe = tRecipe; + this.mEUt = 0; + this.mOutputItems = null; + this.mOutputFluids = null; + if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { + + Utils.LOG_WARNING("False: 1"); + return false; + } + + this.mMaxProgresstime = tRecipe.mDuration; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + 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 { + 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)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + 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); + } + ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; + for (int h = 0; h < tRecipe.mOutputs.length; h++) { + tOut[h] = tRecipe.getOutput(h).copy(); + tOut[h].stackSize = 0; + } + FluidStack tFOut = null; + if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); + for (int f = 0; f < tOut.length; f++) { + if (tRecipe.mOutputs[f] != null && tOut[f] != null) { + for (int g = 0; g < 1; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + if (tFOut != null) { + int tSize = tFOut.amount; + tFOut.amount = tSize * 6; + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mMaxProgresstime /= 4; + if (this.mMaxProgresstime <= 0){ + this.mMaxProgresstime++; + } + 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) { + ItemStack tmp = tOut[f].copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); + overStacks.add(tmp); + } + } + } + if (overStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[overStacks.size()]; + tmp = overStacks.toArray(tmp); + tOut = ArrayUtils.addAll(tOut, tmp); + } + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOut) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOut = tSList.toArray(new ItemStack[tSList.size()]); + this.mOutputItems = tOut; + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); + Utils.LOG_WARNING("Centrifuge: True"); + return true; + } + } + Utils.LOG_WARNING("Centrifuge: Recipe was invalid."); + return false; + } + + @SuppressWarnings("static-method") + public Block getCasingBlock() { + return ModBlocks.blockCasingsMisc; + } + + @SuppressWarnings("static-method") + public byte getCasingMeta() { + return 0; + } + + @SuppressWarnings("static-method") + public byte getCasingTextureIndex() { + return 0; + } + + @Override + 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) + Utils.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; + } + + @SuppressWarnings("static-method") + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; + } + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java new file mode 100644 index 0000000000..9c67502cae --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialCokeOven.java @@ -0,0 +1,272 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +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.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.xmod.gregtech.api.gui.GUI_MultiMachine; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; + +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 GregtechMetaTileEntityIndustrialCokeOven + extends GregtechMeta_MultiBlockBase { + private int mLevel = 0; + + public GregtechMetaTileEntityIndustrialCokeOven(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityIndustrialCokeOven(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrialCokeOven(this.mName); + } + + @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}; + } + + @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]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "CokeOven.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; + + } + + /* @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() > 0) { + 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())); + + 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 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); + + 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 int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + /* @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + }*/ + + @Override + public int getAmountOfOutputs() { + return 24; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialElectrolyzer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialElectrolyzer.java new file mode 100644 index 0000000000..e300de3d88 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialElectrolyzer.java @@ -0,0 +1,258 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +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; + +import org.apache.commons.lang3.ArrayUtils; + +public class GregtechMetaTileEntityIndustrialElectrolyzer +extends GT_MetaTileEntity_MultiBlockBase { + public GregtechMetaTileEntityIndustrialElectrolyzer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityIndustrialElectrolyzer(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrialElectrolyzer(this.mName); + } + + @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}; + } + + @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)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialElectrolyzer.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + ArrayList<ItemStack> tInputList = getStoredInputs(); + GT_Recipe mLastRecipe; + + @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); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.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(); + for (int f = 0; f < tOut.length; f++) { + if (tRecipe.mOutputs[f] != null && tOut[f] != null) { + for (int g = 0; g < 1; g++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; + } + } + } + if (tFOut != null) { + int tSize = tFOut.amount; + tFOut.amount = tSize * 1; + } + + List<ItemStack> overStacks = new ArrayList<ItemStack>(); + for (int f = 0; f < tOut.length; f++) { + if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { + while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { + ItemStack tmp = tOut[f].copy(); + tmp.stackSize = tmp.getMaxStackSize(); + tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); + overStacks.add(tmp); + } + } + } + if (overStacks.size() > 0) { + ItemStack[] tmp = new ItemStack[overStacks.size()]; + tmp = overStacks.toArray(tmp); + tOut = ArrayUtils.addAll(tOut, tmp); + } + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOut) { + if (tS.stackSize > 0) tSList.add(tS); + } + tOut = tSList.toArray(new ItemStack[tSList.size()]); + this.mOutputItems = tOut; + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); + + /* this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots();*/ + return true; + } + } + return false; + } + + @Override + 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 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(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialMacerator.java new file mode 100644 index 0000000000..ff8b6c7f22 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialMacerator.java @@ -0,0 +1,278 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +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 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 GregtechMetaTileEntityIndustrialMacerator +extends GregtechMeta_MultiBlockBase { + private static boolean controller; + + public GregtechMetaTileEntityIndustrialMacerator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityIndustrialMacerator(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrialMacerator(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 ? Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_STEAM_MACERATOR)}; + } + 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) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + if (tInputList.size() > 0) { + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + this.mEUt = (-tRecipe.mEUt); + this.mMaxProgresstime = Math.max(1, (tRecipe.mDuration/5)); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + 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; + controller = false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 6; h++) { + if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) + { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 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; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 7) { + Utils.LOG_INFO("Returned False 2"); + return false; + } + tAmount++; + } + } + } + } + } + if (this.mOutputHatches.size() != 0 || this.mInputBusses.size() != 1 || this.mOutputBusses.size() != 5) { + Utils.LOG_INFO("Returned False 3"); + return false; + } + int height = this.getBaseMetaTileEntity().getYCoord(); + if (this.mInputBusses.get(0).getBaseMetaTileEntity().getYCoord() != height) { + Utils.LOG_INFO("height: "+height+" | Returned False 4"); + return false; + } + GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; + for (int i = 0; i < this.mOutputBusses.size(); i++) { + int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; + if (tmpHatches[hatchNumber] == null) { + tmpHatches[hatchNumber] = this.mOutputBusses.get(i); + } else { + Utils.LOG_INFO("Returned False 5"); + return false; + } + } + this.mOutputBusses.clear(); + for (int i = 0; i < tmpHatches.length; i++) { + this.mOutputBusses.add(tmpHatches[i]); + } + return tAmount >= 26; + } + + /*public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + int tAmount = 0; + controller = false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = 0; h < 6; h++) { + if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) + { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 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) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 1) { + return false; + } + tAmount++; + } + } + } + } + } + if (this.mOutputBusses.size() != 5 || this.mInputBusses.size() != 1) { + return false; + } + int height = this.getBaseMetaTileEntity().getYCoord(); + if (this.mInputHatches.get(0).getBaseMetaTileEntity().getYCoord() != height) { + return false; + } + GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; + for (int i = 0; i < this.mOutputBusses.size(); i++) { + int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; + if (tmpHatches[hatchNumber] == null) { + tmpHatches[hatchNumber] = this.mOutputBusses.get(i); + } else { + return false; + } + } + this.mOutputBusses.clear(); + for (int i = 0; i < tmpHatches.length; i++) { + this.mOutputBusses.add(tmpHatches[i]); + } + return tAmount >= 26; + }*/ + + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; + } + return false; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + /*@Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + }*/ + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java new file mode 100644 index 0000000000..df60138c60 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialPlatePress.java @@ -0,0 +1,204 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +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; + +public class GregtechMetaTileEntityIndustrialPlatePress +extends GT_MetaTileEntity_MultiBlockBase { + public GregtechMetaTileEntityIndustrialPlatePress(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityIndustrialPlatePress(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrialPlatePress(this.mName); + } + + @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}; + } + + @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+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 Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MaterialPress.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBenderRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @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); + if (tInputList.size() > 0) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.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 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 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 int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java new file mode 100644 index 0000000000..ca5e102521 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java @@ -0,0 +1,263 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +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 GregtechMetaTileEntityIndustrialSinter +extends GT_MetaTileEntity_MultiBlockBase { + + + RenderBlocks asdasd = RenderBlocks.getInstance(); + + public GregtechMetaTileEntityIndustrialSinter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityIndustrialSinter(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrialSinter(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; + } + + @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(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int controllerX = aBaseMetaTileEntity.getXCoord(); + int controllerY = aBaseMetaTileEntity.getYCoord(); + int controllerZ = aBaseMetaTileEntity.getZCoord(); + + 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 (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; + } + for (byte i = 2; i < 6; i = (byte) (i + 1)) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ), Color.LIME_GREEN); + IGregTechTileEntity tTileEntity; + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntityIndustrialSinter))) { + //Utils.LOG_INFO("False 1"); + return false; + } + } + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 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 (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 (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; + } + } + } + } + } + if (this.mOutputHatches.size() != 0 || this.mInputHatches.size() != 0) { + Utils.LOG_INFO("Use Busses, Not Hatches for Input/Output."); + return false; + } + if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { + Utils.LOG_INFO("Incorrect amount of Input & Output busses."); + return false; + } + this.mMaintenanceHatches.clear(); + 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 = getCasingTextureIndex(); + } else { + Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); + return false; + } + } + if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1) { + Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); + return false; + } + } else { + Utils.LOG_INFO("False 5"); + return false; + } + Utils.LOG_INFO("True"); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 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; + } + + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + } + + private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { + return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialWireMill.java new file mode 100644 index 0000000000..b0bc87c74a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialWireMill.java @@ -0,0 +1,246 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +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.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class GregtechMetaTileEntityIndustrialWireMill +extends GT_MetaTileEntity_MultiBlockBase { + public GregtechMetaTileEntityIndustrialWireMill(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityIndustrialWireMill(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityIndustrialWireMill(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]}; + } + + @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; + } + + @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(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 (getBaseMetaTileEntity().getAirOffset(i, j, k)) { + tAirCount++; + } + } + } + } + if (tAirCount != 10) { + Utils.LOG_INFO("False 1"); + return false; + } + for (byte i = 2; i < 6; i = (byte) (i + 1)) { + IGregTechTileEntity tTileEntity; + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntityIndustrialWireMill))) { + //Utils.LOG_INFO("False 1"); + return false; + } + } + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); + for (byte i = -1; i < 2; i = (byte) (i + 1)) { + for (byte j = -1; j < 2; j = (byte) (j + 1)) { + if ((i != 0) || (j != 0)) { + for (byte k = 0; k < 5; k = (byte) (k + 1)) { + 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 (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; + } + } + } + } + } + if (this.mOutputHatches.size() != 0 || this.mInputHatches.size() != 0) { + Utils.LOG_INFO("Use Busses, Not Hatches for Input/Output."); + return false; + } + if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { + Utils.LOG_INFO("Incorrect amount of Input & Output busses."); + return false; + } + this.mMaintenanceHatches.clear(); + 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 = getCasingTextureIndex(); + } else { + Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); + return false; + } + } + if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1) { + Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); + return false; + } + } else { + Utils.LOG_INFO("False 5"); + return false; + } + Utils.LOG_INFO("True"); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 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; + } + + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + } + + private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { + return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java new file mode 100644 index 0000000000..3edb17efcb --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIronBlastFurnace.java @@ -0,0 +1,380 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_IronBlastFurnace; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_IronBlastFurnace; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMetaTileEntityIronBlastFurnace + extends MetaTileEntity { + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT)}; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE)}; + public int mMaxProgresstime = 0; + public int mUpdate = 30; + public int mProgresstime = 0; + public boolean mMachine = false; + public ItemStack mOutputItem1; + public ItemStack mOutputItem2; + + public GregtechMetaTileEntityIronBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 4); + } + + public GregtechMetaTileEntityIronBlastFurnace(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 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 + public boolean isElectric() { + return false; + } + + @Override + public boolean isPneumatic() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isInputFacing(byte aSide) { + return false; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public int getProgresstime() { + return this.mProgresstime; + } + + @Override + public int maxProgresstime() { + 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 GregtechMetaTileEntityIronBlastFurnace(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(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/GregtechMetaTileEntityMassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMassFabricator.java new file mode 100644 index 0000000000..2cd7164fe1 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityMassFabricator.java @@ -0,0 +1,352 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +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_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +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.fluid.FluidUtils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; + +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 GregtechMetaTileEntityMassFabricator 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 int mAmplifierUsed = 0; + private int mMatterProduced = 0; + private static Block IC2Glass = Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass")); + FluidStack tempFake = FluidUtils.getFluidStack("uuamplifier", 1); + GT_Recipe fakeRecipe; + + public int getAmplifierUsed(){ + return mAmplifierUsed; + } + + public int getMatterProduced(){ + return mMatterProduced; + } + + //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); + + public GregtechMetaTileEntityMassFabricator(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityMassFabricator(String aName) { + super(aName); + } + + @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}; + } + + @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_MatterFab(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } + + @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(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) { + //Utils.LOG_INFO("Input fluid found"); + 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); + mMatterProduced++; + mAmplifierUsed++; + updateSlots(); + Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + return true; + } + } + else { + Utils.LOG_INFO("Invalid Recipe"); + return false; + } + } + } + else if (tFluids.length == 0) { + //Utils.LOG_INFO("Input fluid not found"); + 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 - (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.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + if (fakeRecipe != null) { + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + 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; + } + } + else { + //Utils.LOG_INFO("Invalid no input 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 = -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); + + 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) { + + 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; + } + } + + 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; + } + } + + 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 boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityMassFabricator(this.mName); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityPowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityPowerSubStationController.java new file mode 100644 index 0000000000..b85e011115 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityPowerSubStationController.java @@ -0,0 +1,189 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Config; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +public class GregtechMetaTileEntityPowerSubStationController extends GT_MetaTileEntity_MultiBlockBase { + + private int recipeCounter = 0; + + public GregtechMetaTileEntityPowerSubStationController(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntityPowerSubStationController(String aName) { + super(aName); + } + + @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 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) { + 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); + + 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"); + 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; + } + 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"); + return false; + } + } + } + } else { + + } + } + } + } + } + Utils.LOG_INFO("Multiblock Formed."); + return true; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 1; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityPowerSubStationController(this.mName); + } + +}
\ No newline at end of file |