diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-11-06 19:32:27 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-11-06 19:32:27 +1000 |
commit | cbe0e497be8e466c380a5b4fa781b314ede9ada3 (patch) | |
tree | b85848b432adf458e3abda466ee46d9dfc3e454b /src/Java/gtPlusPlus/xmod/gregtech/common/tileentities | |
parent | c40416b036c0e89451e1558253ccf07bbee028d0 (diff) | |
download | GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.gz GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.bz2 GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.zip |
Revert "$ Cleaned up the entire project."
This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747.
# Conflicts:
# src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java
# src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java
Revert "% Cleaned up Imports."
This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities')
23 files changed, 4063 insertions, 4692 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java index a1093d67d3..0338871482 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractGenerator.java @@ -1,14 +1,16 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.automation; +import static gtPlusPlus.core.lib.CORE.sTesseractGenerators; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.*; +import gregtech.api.interfaces.tileentity.IDigitalChest; +import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -20,486 +22,521 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; - -public class GT_MetaTileEntity_TesseractGenerator extends GT_MetaTileEntity_BasicTank { - public static int TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; - public static int TESSERACT_ENERGY_COST = 1024; - public byte isWorking = 0; - public int oFrequency = 0; - public int mNeededEnergy = 0; - public int mFrequency = 0; - - public GT_MetaTileEntity_TesseractGenerator(final int aID, final String aName, final String aNameRegional, - final int aTier) { +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class GT_MetaTileEntity_TesseractGenerator +extends GT_MetaTileEntity_BasicTank +{ + public static int TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; + public static int TESSERACT_ENERGY_COST = 1024; + public byte isWorking = 0; + public int oFrequency = 0; + public int mNeededEnergy = 0; + public int mFrequency = 0; + + public GT_MetaTileEntity_TesseractGenerator(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 3, ""); } - public GT_MetaTileEntity_TesseractGenerator(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { + public GT_MetaTileEntity_TesseractGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 3, aDescription, aTextures); - } + } - public boolean addEnergyConsumption(final GT_MetaTileEntity_TesseractTerminal aTerminal) { - if (!this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - this.mNeededEnergy += aTerminal.getBaseMetaTileEntity().getWorld() == this.getBaseMetaTileEntity().getWorld() - ? GT_MetaTileEntity_TesseractGenerator.TESSERACT_ENERGY_COST - : GT_MetaTileEntity_TesseractGenerator.TESSERACT_ENERGY_COST_DIMENSIONAL; - return true; - } - - public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractGenerator(mName, mTier, mDescription, mTextures); } @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; + public boolean isTransformerUpgradable() + { + return true; } @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { + public boolean isOverclockerUpgradable() + { return false; } @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - return tTileEntity.canDrain(aSide, aFluid); + public boolean isSimpleMachine() + { + return false; } @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - if (tTileEntity instanceof ISidedInventory) { - return ((ISidedInventory) tTileEntity).canExtractItem(aIndex, aStack, aSide); - } + public boolean isFacingValid(byte aFacing) + { return true; } @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - return tTileEntity.canFill(aSide, aFluid); - } - - @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - if (tTileEntity instanceof ISidedInventory) { - return ((ISidedInventory) tTileEntity).canInsertItem(aIndex, aStack, aSide); - } + public boolean isEnetInput() + { return true; } @Override - public boolean canTankBeEmptied() { + public boolean isEnetOutput() + { return false; } @Override - public boolean canTankBeFilled() { - return false; + public boolean isInputFacing(byte aSide) + { + return true; } @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; - } - return tTileEntity.decrStackSize(aIndex, aAmount); + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getBackFacing(); } @Override - public boolean displaysItemStack() { + public boolean isValidSlot(int aIndex) + { return false; } @Override - public boolean displaysStackSize() { - return false; + public long getMinimumStoredEU() + { + return getBaseMetaTileEntity().getEUCapacity() / 2; } @Override - public boolean doesEmptyContainers() { - return false; + public long maxEUInput() + { + return 2048; } - // To-Do? @Override - public boolean doesFillContainers() { - return false; + public long maxEUOutput() + { + return 0; } @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; - } - return tTileEntity.drain(aSide, aFluid, doDrain); + public long maxEUStore() + { + return 100000; } @Override - public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; - } - return tTileEntity.drain(aDirection, maxDrain, doDrain); + public long maxSteamStore() + { + return maxEUStore(); } @Override - public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return 0; - } - return tTileEntity.fill(aDirection, aFluid, doFill); + public boolean isAccessAllowed(EntityPlayer aPlayer) + { + return true; } @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return new int[0]; - } - if (tTileEntity instanceof ISidedInventory) { - return ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(aSide); - } - final int[] rArray = new int[this.getSizeInventory()]; - for (int i = 0; i < this.getSizeInventory(); i++) { - rArray[i] = i; - } - return rArray; + public boolean ownerControl() + { + return true; } @Override - public String[] getDescription() { - return new String[] { - "Generates a Tesseract for the attached Inventory" - }; + public int getProgresstime() + { + return (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) && (this.isWorking >= 20) ? 999 : 0; } @Override - public String[] getInfoData() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity != null && this.getBaseMetaTileEntity().isAllowedToWork() - && tTileEntity instanceof IGregTechDeviceInformation - && ((IGregTechDeviceInformation) tTileEntity).isGivingInformation()) { - return ((IGregTechDeviceInformation) tTileEntity).getInfoData(); - } - return new String[] { - "Tesseract Generator", "Freqency:", "" + this.mFrequency, - CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this && this.isWorking >= 20 - ? "Active" : "Inactive" - }; + public int maxProgresstime() + { + return 1000; } @Override - public String getInventoryName() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return ""; - } - return tTileEntity.getInventoryName(); + public void saveNBTData(NBTTagCompound aNBT) + { + aNBT.setInteger("mFrequency", this.mFrequency); } @Override - public int getInventoryStackLimit() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return 0; - } - return tTileEntity.getInventoryStackLimit(); + public void loadNBTData(NBTTagCompound aNBT) + { + this.mFrequency = aNBT.getInteger("mFrequency"); } @Override - public int getMaxItemCount() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity != null && this.getBaseMetaTileEntity().isAllowedToWork() - && tTileEntity instanceof IDigitalChest) { - return ((IDigitalChest) tTileEntity).getMaxItemCount(); - } - return 0; + public void onConfigLoad(GT_Config aConfig) + { + TESSERACT_ENERGY_COST = 1024; + TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; } @Override - public long getMinimumStoredEU() { - return this.getBaseMetaTileEntity().getEUCapacity() / 2; + public void onServerStart() + { + sTesseractGenerators.clear(); } - @Override - public int getProgresstime() { - return CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this && this.isWorking >= 20 ? 999 - : 0; + public void onServerStop() + { + sTesseractGenerators.clear(); } - + @Override - public int getSizeInventory() { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return 0; - } - return tTileEntity.getSizeInventory(); + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ){ + if (aSide == getBaseMetaTileEntity().getFrontFacing()){ + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))){ + case 0: + Utils.LOG_INFO("Freq. -1 | " + this.mFrequency); + this.mFrequency -= 1; + break; + case 1: + Utils.LOG_INFO("Freq. +1 | " + this.mFrequency); + this.mFrequency += 1; + default: + //Utils.LOG_INFO("Did not click the correct place."); + break; + } + PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + PlayerUtils.messagePlayer(aPlayer, ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null) && (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this) ? EnumChatFormatting.RED + " (Occupied)" : "")); + } + return true; } @Override - public ItemStack getStackInSlot(final int aIndex) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) + { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) + { + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))) + { + case 0: + this.mFrequency -= 64; + break; + case 1: + this.mFrequency += 64; + break; + case 2: + this.mFrequency -= 512; + break; + case 3: + this.mFrequency += 512; + } + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null) && (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this) ? EnumChatFormatting.RED + " (Occupied)" : "")); } - return tTileEntity.getStackInSlot(aIndex); } - @Override - public ItemStack[] getStoredItemData() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity != null && this.getBaseMetaTileEntity().isAllowedToWork() - && tTileEntity instanceof IDigitalChest) { - return ((IDigitalChest) tTileEntity).getStoredItemData(); - } - return null; + public boolean allowCoverOnSide(byte aSide, int aCoverID) + { + return aSide != getBaseMetaTileEntity().getFrontFacing(); } @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - final IFluidHandler tTileEntity = this.getBaseMetaTileEntity() - .getITankContainerAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return new FluidTankInfo[0]; + public String[] getInfoData() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IGregTechDeviceInformation)) && (((IGregTechDeviceInformation)tTileEntity).isGivingInformation())) { + return ((IGregTechDeviceInformation)tTileEntity).getInfoData(); } - return tTileEntity.getTankInfo(aSide); + return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) && (this.isWorking >= 20) ? "Active" : "Inactive" }; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return aSide == aFacing ? new ITexture[] { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) - } : new ITexture[] { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(Textures.BlockIcons.VOID) - }; + public boolean isGivingInformation() + { + return true; } - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; + public boolean isSendingInformation() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IGregTechDeviceInformation))) { + return ((IGregTechDeviceInformation)tTileEntity).isGivingInformation(); + } + return false; } @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; + public boolean isDigitalChest() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest)tTileEntity).isDigitalChest(); + } + return false; } @Override - public boolean isDigitalChest() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity != null && this.getBaseMetaTileEntity().isAllowedToWork() - && tTileEntity instanceof IDigitalChest) { - return ((IDigitalChest) tTileEntity).isDigitalChest(); + public ItemStack[] getStoredItemData() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest)tTileEntity).getStoredItemData(); } - return false; + return null; } @Override - public boolean isEnetInput() { - return true; + public void setItemCount(int aCount) + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + ((IDigitalChest)tTileEntity).setItemCount(aCount); + } } @Override - public boolean isEnetOutput() { - return false; + public int getMaxItemCount() + { + TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { + return ((IDigitalChest)tTileEntity).getMaxItemCount(); + } + return 0; } @Override - public boolean isFacingValid(final byte aFacing) { - return true; + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.isItemValidForSlot(aIndex, aStack); } @Override - public boolean isGivingInformation() { - return true; + public int[] getAccessibleSlotsFromSide(int aSide) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return new int[0]; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory)tTileEntity).getAccessibleSlotsFromSide(aSide); + } + int[] rArray = new int[getSizeInventory()]; + for (int i = 0; i < getSizeInventory(); i++) { + rArray[i] = i; + } + return rArray; } @Override - public boolean isInputFacing(final byte aSide) { + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory)tTileEntity).canInsertItem(aIndex, aStack, aSide); + } return true; } @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { return false; } - return tTileEntity.isItemValidForSlot(aIndex, aStack); + if ((tTileEntity instanceof ISidedInventory)) { + return ((ISidedInventory)tTileEntity).canExtractItem(aIndex, aStack, aSide); + } + return true; } @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getBackFacing(); + public int getSizeInventory() + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); } @Override - public boolean isOverclockerUpgradable() { - return false; - } - - public boolean isSendingInformation() { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity != null && this.getBaseMetaTileEntity().isAllowedToWork() - && tTileEntity instanceof IGregTechDeviceInformation) { - return ((IGregTechDeviceInformation) tTileEntity).isGivingInformation(); + public ItemStack getStackInSlot(int aIndex) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; } - return false; + return tTileEntity.getStackInSlot(aIndex); } @Override - public boolean isSimpleMachine() { - return false; + public void setInventorySlotContents(int aIndex, ItemStack aStack) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); } @Override - public boolean isTransformerUpgradable() { - return true; + public ItemStack decrStackSize(int aIndex, int aAmount) + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.decrStackSize(aIndex, aAmount); } @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - public boolean isValidTesseractGenerator(final String aOwnerName, final boolean aWorkIrrelevant) { - return this.getBaseMetaTileEntity() != null && !this.getBaseMetaTileEntity().isInvalidTileEntity() - && this.getBaseMetaTileEntity().isAllowedToWork() - && (aOwnerName == null || this.getBaseMetaTileEntity().getOwnerName().equals(aOwnerName)) - && (aWorkIrrelevant || this.isWorking >= 20); + public String getInventoryName() + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); } @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFrequency = aNBT.getInteger("mFrequency"); + public int getInventoryStackLimit() + { + IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); } @Override - public long maxEUInput() { - return 2048; + public boolean canFill(ForgeDirection aSide, Fluid aFluid) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canFill(aSide, aFluid); } @Override - public long maxEUOutput() { - return 0; + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); } @Override - public long maxEUStore() { - return 100000; + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); } @Override - public int maxProgresstime() { - return 1000; + public int fill_default(ForgeDirection aDirection, FluidStack aFluid, boolean doFill) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); } @Override - public long maxSteamStore() { - return this.maxEUStore(); + public FluidStack drain(ForgeDirection aDirection, int maxDrain, boolean doDrain) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); } @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TesseractGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) + { + IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); } - @Override - public void onConfigLoad(final GT_Config aConfig) { - GT_MetaTileEntity_TesseractGenerator.TESSERACT_ENERGY_COST = 1024; - GT_MetaTileEntity_TesseractGenerator.TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; + public boolean addEnergyConsumption(GT_MetaTileEntity_TesseractTerminal aTerminal) + { + if (!getBaseMetaTileEntity().isAllowedToWork()) { + return false; + } + this.mNeededEnergy += (aTerminal.getBaseMetaTileEntity().getWorld() == getBaseMetaTileEntity().getWorld() ? TESSERACT_ENERGY_COST : TESSERACT_ENERGY_COST_DIMENSIONAL); + return true; } - public void onPostTick() { - if (this.getBaseMetaTileEntity().isServerSide()) { - if (this.mFrequency != this.oFrequency) { + public boolean isValidTesseractGenerator(String aOwnerName, boolean aWorkIrrelevant) + { + return (getBaseMetaTileEntity() != null) && (!getBaseMetaTileEntity().isInvalidTileEntity()) && (getBaseMetaTileEntity().isAllowedToWork()) && ((aOwnerName == null) || (getBaseMetaTileEntity().getOwnerName().equals(aOwnerName))) && ((aWorkIrrelevant) || (this.isWorking >= 20)); + } + public void onPostTick() + { + if (getBaseMetaTileEntity().isServerSide()){ + if (this.mFrequency != this.oFrequency){ + Utils.LOG_INFO("mFreq != oFreq"); - - if (CORE.sTesseractGenerators.get(Integer.valueOf(this.oFrequency)) == this) { - CORE.sTesseractGenerators.remove(Integer.valueOf(this.oFrequency)); - this.getBaseMetaTileEntity().issueBlockUpdate(); + + if (sTesseractGenerators.get(Integer.valueOf(this.oFrequency)) == this) + { + sTesseractGenerators.remove(Integer.valueOf(this.oFrequency)); + getBaseMetaTileEntity().issueBlockUpdate(); Utils.LOG_INFO("this Gen == oFreq on map - do block update"); } Utils.LOG_INFO("mFreq will be set to oFreq"); this.oFrequency = this.mFrequency; } - if (this.getBaseMetaTileEntity().isAllowedToWork() - && this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mNeededEnergy, false)) { + if ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mNeededEnergy, false))) + { Utils.LOG_INFO("Can Work & Has Energy"); - if (CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == null - || !CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) - .isValidTesseractGenerator(null, true)) { + if ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == null) || (!((GT_MetaTileEntity_TesseractGenerator)sTesseractGenerators.get(Integer.valueOf(this.mFrequency))).isValidTesseractGenerator(null, true))) { Utils.LOG_INFO("storing TE I think to mFreq map?"); - CORE.sTesseractGenerators.put(Integer.valueOf(this.mFrequency), this); + sTesseractGenerators.put(Integer.valueOf(this.mFrequency), this); } } - else { - if (CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) { + else + { + if (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) + { Utils.LOG_INFO("this gen == mFreq on map - do block update"); - CORE.sTesseractGenerators.remove(Integer.valueOf(this.mFrequency)); - this.getBaseMetaTileEntity().issueBlockUpdate(); + sTesseractGenerators.remove(Integer.valueOf(this.mFrequency)); + getBaseMetaTileEntity().issueBlockUpdate(); } this.isWorking = 0; } - if (CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) { + if (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) + { Utils.LOG_INFO("mFreq == this - do work related things"); if (this.isWorking < 20) { - this.isWorking = (byte) (this.isWorking + 1); + this.isWorking = ((byte)(this.isWorking + 1)); } - if (this.isWorking == 20) { - this.getBaseMetaTileEntity().issueBlockUpdate(); - this.isWorking = (byte) (this.isWorking + 1); + if (this.isWorking == 20) + { + getBaseMetaTileEntity().issueBlockUpdate(); + this.isWorking = ((byte)(this.isWorking + 1)); } } - else { + else + { this.isWorking = 0; } this.mNeededEnergy = 0; @@ -507,93 +544,60 @@ public class GT_MetaTileEntity_TesseractGenerator extends GT_MetaTileEntity_Basi } @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, - final byte aSide, final float aX, final float aY, final float aZ) { - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + 2 * (byte) (int) (tCoords[1] * 2.0F))) { - case 0: - Utils.LOG_INFO("Freq. -1 | " + this.mFrequency); - this.mFrequency -= 1; - break; - case 1: - Utils.LOG_INFO("Freq. +1 | " + this.mFrequency); - this.mFrequency += 1; - default: - // Utils.LOG_INFO("Did not click the correct place."); - break; - } - PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); - PlayerUtils.messagePlayer(aPlayer, - CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null - && CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this - ? EnumChatFormatting.RED + " (Occupied)" : ""); - } - return true; + public String[] getDescription() + { + return new String[] {"Generates a Tesseract for the attached Inventory"}; } @Override - public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, - final float aZ) { - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + 2 * (byte) (int) (tCoords[1] * 2.0F))) { - case 0: - this.mFrequency -= 64; - break; - case 1: - this.mFrequency += 64; - break; - case 2: - this.mFrequency -= 512; - break; - case 3: - this.mFrequency += 512; - } - GT_Utility.sendChatToPlayer(aPlayer, - "Frequency: " + this.mFrequency - + (CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null - && CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this - ? EnumChatFormatting.RED + " (Occupied)" : "")); - } + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; } @Override - public void onServerStart() { - CORE.sTesseractGenerators.clear(); + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; } - public void onServerStop() { - CORE.sTesseractGenerators.clear(); + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; } @Override - public boolean ownerControl() { - return true; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == aFacing ? new ITexture[]{ new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency)} : new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; } + + //To-Do? @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mFrequency", this.mFrequency); + public boolean doesFillContainers() { + return false; } @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - final IInventory tTileEntity = this.getBaseMetaTileEntity() - .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return; - } - tTileEntity.setInventorySlotContents(aIndex, aStack); + public boolean doesEmptyContainers() { + return false; } @Override - public void setItemCount(final int aCount) { - final TileEntity tTileEntity = this.getBaseMetaTileEntity() - .getTileEntityAtSide(this.getBaseMetaTileEntity().getBackFacing()); - if (tTileEntity != null && this.getBaseMetaTileEntity().isAllowedToWork() - && tTileEntity instanceof IDigitalChest) { - ((IDigitalChest) tTileEntity).setItemCount(aCount); - } + public boolean canTankBeFilled() { + return false; + } + + @Override + public boolean canTankBeEmptied() { + return false; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java index 9a1a89cf47..aa8ddad326 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/automation/GT_MetaTileEntity_TesseractTerminal.java @@ -17,478 +17,512 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; - -public class GT_MetaTileEntity_TesseractTerminal extends GT_MetaTileEntity_BasicTank { - public static boolean sInterDimensionalTesseractAllowed = true; - public int mFrequency = 0; - public boolean mDidWork = false; - - public GT_MetaTileEntity_TesseractTerminal(final int aID, final String aName, final String aNameRegional, - final int aTier) { +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + +public class GT_MetaTileEntity_TesseractTerminal +extends GT_MetaTileEntity_BasicTank +{ + public int mFrequency = 0; + public boolean mDidWork = false; + public static boolean sInterDimensionalTesseractAllowed = true; + + public GT_MetaTileEntity_TesseractTerminal(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 3, ""); } - public GT_MetaTileEntity_TesseractTerminal(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { + public GT_MetaTileEntity_TesseractTerminal(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 3, aDescription, aTextures); - } + } - public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { - return aSide != this.getBaseMetaTileEntity().getFrontFacing(); + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractTerminal(mName, mTier, mDescription, mTextures); } @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { + public boolean isTransformerUpgradable() + { return false; } @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { + public boolean isOverclockerUpgradable() + { return false; } @Override - public boolean canDrain(final ForgeDirection aSide, final Fluid aFluid) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - return tTileEntity.canDrain(aSide, aFluid); + public boolean isSimpleMachine() + { + return false; } @Override - public boolean canExtractItem(final int aIndex, final ItemStack aStack, final int aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - return tTileEntity.canExtractItem(aIndex, aStack, aSide); + public boolean isFacingValid(byte aFacing) + { + return true; } - + @Override - public boolean canFill(final ForgeDirection aSide, final Fluid aFluid) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - return tTileEntity.canFill(aSide, aFluid); + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getBackFacing(); } @Override - public boolean canInsertItem(final int aIndex, final ItemStack aStack, final int aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; - } - return tTileEntity.canInsertItem(aIndex, aStack, aSide); + public boolean isValidSlot(int aIndex) + { + return false; } - + @Override - public boolean canTankBeEmptied() { - return false; + public long getMinimumStoredEU() + { + return getBaseMetaTileEntity().getEUCapacity() / 2; } @Override - public boolean canTankBeFilled() { - return false; + public long maxEUInput() + { + return 2048; } @Override - public ItemStack decrStackSize(final int aIndex, final int aAmount) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; - } - return tTileEntity.decrStackSize(aIndex, aAmount); + public boolean isAccessAllowed(EntityPlayer aPlayer) + { + return true; } - + @Override - public boolean displaysItemStack() { - return false; + public long maxEUStore() + { + return 100000; } @Override - public boolean displaysStackSize() { - return false; + public long maxSteamStore() + { + return maxEUStore(); } @Override - public boolean doesEmptyContainers() { - return false; + public boolean ownerControl() + { + return true; } - // To-Do? @Override - public boolean doesFillContainers() { - return false; + public int getProgresstime() + { + return getTesseract(this.mFrequency, false) != null ? 999 : 0; } @Override - public FluidStack drain(final ForgeDirection aSide, final FluidStack aFluid, final boolean doDrain) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; - } - return tTileEntity.drain(aSide, aFluid, doDrain); + public int maxProgresstime() + { + return 1000; } @Override - public FluidStack drain(final ForgeDirection aDirection, final int maxDrain, final boolean doDrain) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; - } - return tTileEntity.drain(aDirection, maxDrain, doDrain); + public void saveNBTData(NBTTagCompound aNBT) + { + aNBT.setInteger("mFrequency", this.mFrequency); } @Override - public int fill_default(final ForgeDirection aDirection, final FluidStack aFluid, final boolean doFill) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return 0; - } - return tTileEntity.fill(aDirection, aFluid, doFill); + public void loadNBTData(NBTTagCompound aNBT) + { + this.mFrequency = aNBT.getInteger("mFrequency"); } @Override - public int[] getAccessibleSlotsFromSide(final int aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return new int[0]; - } - return tTileEntity.getAccessibleSlotsFromSide(aSide); + public void onConfigLoad(GT_Config aConfig) + { + sInterDimensionalTesseractAllowed = true; } - /* - * public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, - * float aY, float aZ) { if (aSide == - * getBaseMetaTileEntity().getFrontFacing()) { float[] tCoords = - * GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); switch - * ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * - * 2.0F))) { case 0: this.mFrequency -= 1; break; case 1: this.mFrequency += - * 1; } GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency - * + (getTesseract(this.mFrequency, false) == null ? "" : new - * StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)" - * ).toString())); } return true; } - */ + /*public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) + { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) + { + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))) + { + case 0: + this.mFrequency -= 1; + break; + case 1: + this.mFrequency += 1; + } + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); + } + return true; + }*/ + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ){ + if (aSide == getBaseMetaTileEntity().getFrontFacing()){ + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))){ + case 0: + Utils.LOG_INFO("Freq. -1 | " + this.mFrequency); + this.mFrequency -= 1; + break; + case 1: + Utils.LOG_INFO("Freq. +1 | " + this.mFrequency); + this.mFrequency += 1; + default: + //Utils.LOG_INFO("Did not click the correct place."); + break; + } + PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); + PlayerUtils.messagePlayer(aPlayer, (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); + } + return true; + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) + { + if (aSide == getBaseMetaTileEntity().getFrontFacing()) + { + float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); + switch ((byte)((byte)(int)(tCoords[0] * 2.0F) + 2 * (byte)(int)(tCoords[1] * 2.0F))) + { + case 0: + this.mFrequency -= 64; + break; + case 1: + this.mFrequency += 64; + break; + case 2: + this.mFrequency -= 512; + break; + case 3: + this.mFrequency += 512; + } + GT_Utility.sendChatToPlayer(aPlayer, "Frequency: " + this.mFrequency + (getTesseract(this.mFrequency, false) == null ? "" : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); + } + } - @Override - public String[] getDescription() { - return new String[] { - "Accesses Tesseracts remotely" - }; + public boolean allowCoverOnSide(byte aSide, int aCoverID) + { + return aSide != getBaseMetaTileEntity().getFrontFacing(); } - @Override - public String[] getInfoData() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity != null && this.getBaseMetaTileEntity().isAllowedToWork() - && tTileEntity.isSendingInformation()) { - return tTileEntity.getInfoData(); + public GT_MetaTileEntity_TesseractGenerator getTesseract(int aFrequency, boolean aWorkIrrelevant) + { + GT_MetaTileEntity_TesseractGenerator rTesseract = (GT_MetaTileEntity_TesseractGenerator)CORE.sTesseractGenerators.get(Integer.valueOf(aFrequency)); + if (rTesseract == null) { + return null; + } + if (rTesseract.mFrequency != aFrequency) + { + CORE.sTesseractGenerators.put(Integer.valueOf(aFrequency), null);return null; } - return new String[] { - "Tesseract Generator", "Freqency:", "" + this.mFrequency, - this.getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" - }; + if (!rTesseract.isValidTesseractGenerator(getBaseMetaTileEntity().getOwnerName(), aWorkIrrelevant)) { + return null; + } + if ((!sInterDimensionalTesseractAllowed) && (rTesseract.getBaseMetaTileEntity().getWorld() != getBaseMetaTileEntity().getWorld())) { + return null; + } + return rTesseract; } @Override - public String getInventoryName() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return ""; + public String[] getInfoData() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && (tTileEntity.isSendingInformation())) { + return tTileEntity.getInfoData(); } - return tTileEntity.getInventoryName(); + return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" }; } @Override - public int getInventoryStackLimit() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return 0; - } - return tTileEntity.getInventoryStackLimit(); + public boolean isGivingInformation() + { + return true; } @Override - public int getMaxItemCount() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return 0; + public boolean isDigitalChest() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; } - return tTileEntity.getMaxItemCount(); + return tTileEntity.isDigitalChest(); } @Override - public long getMinimumStoredEU() { - return this.getBaseMetaTileEntity().getEUCapacity() / 2; + public ItemStack[] getStoredItemData() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStoredItemData(); } @Override - public int getProgresstime() { - return this.getTesseract(this.mFrequency, false) != null ? 999 : 0; + public void setItemCount(int aCount) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setItemCount(aCount); } @Override - public int getSizeInventory() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + public int getMaxItemCount() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { return 0; } - return tTileEntity.getSizeInventory(); + return tTileEntity.getMaxItemCount(); } @Override - public ItemStack getStackInSlot(final int aIndex) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; + public boolean isItemValidForSlot(int aIndex, ItemStack aStack) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; } - return tTileEntity.getStackInSlot(aIndex); + return tTileEntity.isItemValidForSlot(aIndex, aStack); } @Override - public ItemStack[] getStoredItemData() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return null; + public int[] getAccessibleSlotsFromSide(int aSide) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return new int[0]; } - return tTileEntity.getStoredItemData(); + return tTileEntity.getAccessibleSlotsFromSide(aSide); } @Override - public FluidTankInfo[] getTankInfo(final ForgeDirection aSide) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return new FluidTankInfo[0]; + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; } - return tTileEntity.getTankInfo(aSide); + return tTileEntity.canInsertItem(aIndex, aStack, aSide); } - public GT_MetaTileEntity_TesseractGenerator getTesseract(final int aFrequency, final boolean aWorkIrrelevant) { - final GT_MetaTileEntity_TesseractGenerator rTesseract = CORE.sTesseractGenerators - .get(Integer.valueOf(aFrequency)); - if (rTesseract == null) { - return null; - } - if (rTesseract.mFrequency != aFrequency) { - CORE.sTesseractGenerators.put(Integer.valueOf(aFrequency), null); - return null; - } - if (!rTesseract.isValidTesseractGenerator(this.getBaseMetaTileEntity().getOwnerName(), aWorkIrrelevant)) { - return null; - } - if (!GT_MetaTileEntity_TesseractTerminal.sInterDimensionalTesseractAllowed - && rTesseract.getBaseMetaTileEntity().getWorld() != this.getBaseMetaTileEntity().getWorld()) { - return null; + @Override + public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; } - return rTesseract; + return tTileEntity.canExtractItem(aIndex, aStack, aSide); } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return aSide == aFacing ? new ITexture[] { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency) - } : new ITexture[] { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), - new GT_RenderedTexture(Textures.BlockIcons.VOID) - }; + public int getSizeInventory() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getSizeInventory(); } @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; + public ItemStack getStackInSlot(int aIndex) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); } @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; + public void setInventorySlotContents(int aIndex, ItemStack aStack) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return; + } + tTileEntity.setInventorySlotContents(aIndex, aStack); } @Override - public boolean isDigitalChest() { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return false; + public ItemStack decrStackSize(int aIndex, int aAmount) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; } - return tTileEntity.isDigitalChest(); + return tTileEntity.decrStackSize(aIndex, aAmount); } @Override - public boolean isFacingValid(final byte aFacing) { - return true; + public String getInventoryName() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return ""; + } + return tTileEntity.getInventoryName(); } @Override - public boolean isGivingInformation() { - return true; + public int getInventoryStackLimit() + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.getInventoryStackLimit(); } @Override - public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + public boolean canFill(ForgeDirection aSide, Fluid aFluid) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { return false; } - return tTileEntity.isItemValidForSlot(aIndex, aStack); - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getBackFacing(); + return tTileEntity.canFill(aSide, aFluid); } @Override - public boolean isOverclockerUpgradable() { - return false; + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return false; + } + return tTileEntity.canDrain(aSide, aFluid); } @Override - public boolean isSimpleMachine() { - return false; + public FluidTankInfo[] getTankInfo(ForgeDirection aSide) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return new FluidTankInfo[0]; + } + return tTileEntity.getTankInfo(aSide); } @Override - public boolean isTransformerUpgradable() { - return false; + public int fill_default(ForgeDirection aDirection, FluidStack aFluid, boolean doFill) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return 0; + } + return tTileEntity.fill(aDirection, aFluid, doFill); } @Override - public boolean isValidSlot(final int aIndex) { - return false; + public FluidStack drain(ForgeDirection aDirection, int maxDrain, boolean doDrain) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aDirection, maxDrain, doDrain); } @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mFrequency = aNBT.getInteger("mFrequency"); + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); + if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + return null; + } + return tTileEntity.drain(aSide, aFluid, doDrain); } - @Override - public long maxEUInput() { - return 2048; + public void onPostTick() + { + if ((getBaseMetaTileEntity().isServerSide()) && (getBaseMetaTileEntity().isAllowedToWork())) + { + GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, true); + if (tTileEntity != null) + { + tTileEntity.addEnergyConsumption(this); + if ((!this.mDidWork) && (getTesseract(this.mFrequency, false) != null)) + { + this.mDidWork = true; + getBaseMetaTileEntity().issueBlockUpdate(); + } + } + else if (this.mDidWork == true) + { + this.mDidWork = false; + getBaseMetaTileEntity().issueBlockUpdate(); + } + } } @Override - public long maxEUStore() { - return 100000; + public String[] getDescription() + { + return new String[] {"Accesses Tesseracts remotely"}; } @Override - public int maxProgresstime() { - return 1000; + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; } @Override - public long maxSteamStore() { - return this.maxEUStore(); + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; } @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TesseractTerminal(this.mName, this.mTier, this.mDescription, this.mTextures); + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; } @Override - public void onConfigLoad(final GT_Config aConfig) { - GT_MetaTileEntity_TesseractTerminal.sInterDimensionalTesseractAllowed = true; - } - - public void onPostTick() { - if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, true); - if (tTileEntity != null) { - tTileEntity.addEnergyConsumption(this); - if (!this.mDidWork && this.getTesseract(this.mFrequency, false) != null) { - this.mDidWork = true; - this.getBaseMetaTileEntity().issueBlockUpdate(); - } - } - else if (this.mDidWork == true) { - this.mDidWork = false; - this.getBaseMetaTileEntity().issueBlockUpdate(); - } - } + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == aFacing ? new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Screen_Frequency)} : new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Dimensional), new GT_RenderedTexture(Textures.BlockIcons.VOID)}; } + //To-Do? @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer, - final byte aSide, final float aX, final float aY, final float aZ) { - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + 2 * (byte) (int) (tCoords[1] * 2.0F))) { - case 0: - Utils.LOG_INFO("Freq. -1 | " + this.mFrequency); - this.mFrequency -= 1; - break; - case 1: - Utils.LOG_INFO("Freq. +1 | " + this.mFrequency); - this.mFrequency += 1; - default: - // Utils.LOG_INFO("Did not click the correct place."); - break; - } - PlayerUtils.messagePlayer(aPlayer, "Frequency: " + this.mFrequency); - PlayerUtils.messagePlayer(aPlayer, this.getTesseract(this.mFrequency, false) == null ? "" - : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString()); - } - return true; + public boolean doesFillContainers() { + return false; } @Override - public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, - final float aZ) { - if (aSide == this.getBaseMetaTileEntity().getFrontFacing()) { - final float[] tCoords = GT_Utility.getClickedFacingCoords(aSide, aX, aY, aZ); - switch ((byte) ((byte) (int) (tCoords[0] * 2.0F) + 2 * (byte) (int) (tCoords[1] * 2.0F))) { - case 0: - this.mFrequency -= 64; - break; - case 1: - this.mFrequency += 64; - break; - case 2: - this.mFrequency -= 512; - break; - case 3: - this.mFrequency += 512; - } - GT_Utility.sendChatToPlayer(aPlayer, - "Frequency: " + this.mFrequency + (this.getTesseract(this.mFrequency, false) == null ? "" - : new StringBuilder().append(EnumChatFormatting.GREEN).append(" (Connected)").toString())); - } + public boolean doesEmptyContainers() { + return false; } @Override - public boolean ownerControl() { - return true; + public boolean canTankBeFilled() { + return false; } @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mFrequency", this.mFrequency); + public boolean canTankBeEmptied() { + return false; } @Override - public void setInventorySlotContents(final int aIndex, final ItemStack aStack) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return; - } - tTileEntity.setInventorySlotContents(aIndex, aStack); + public boolean displaysItemStack() { + return false; } @Override - public void setItemCount(final int aCount) { - final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); - if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { - return; - } - tTileEntity.setItemCount(aCount); + public boolean displaysStackSize() { + return false; } } 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 index fee44a962e..c2cadab478 100644 --- 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 @@ -16,164 +16,129 @@ 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 { - private int mRunTime = 0; +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(final int aID, final String aName, final 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 GT_MetaTileEntity_Boiler_Solar(final String aName, final int aTier, final String aDescription, - final 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; + } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); - } + 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]; + } - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 16000); - } + public int maxProgresstime() { + return 500; + } - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[aSide >= 2 ? (byte) (aSide != aFacing ? 2 : 3) : aSide][aColorIndex + 1]; - } + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 16000); + } - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[4][17][]; - for (byte i = -1; i < 16; i = (byte) (i + 1)) { - final ITexture[] tmp0 = { - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM, - Dyes.getModulation(i, Dyes._NULL.mRGBa)) - }; - rTextures[0][i + 1] = tmp0; - final 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; - final ITexture[] tmp2 = { - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, - Dyes.getModulation(i, Dyes._NULL.mRGBa)) - }; - rTextures[2][i + 1] = tmp2; - final 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 Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); + } - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mRunTime = aNBT.getInteger("mRunTime"); - } + 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 int maxProgresstime() { - return 500; - } + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mRunTime = aNBT.getInteger("mRunTime"); + } - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_Solar(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final 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) { - final byte i = aBaseMetaTileEntity.getFrontFacing(); - final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) { - final FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), - Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) { - final 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; - this.mRunTime += 1; - int tOutput = 150; - if (this.mRunTime > 10000) { - tOutput = Math.max(50, 150 - (this.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) { - this.sendSound((byte) 1); - this.mSteam.amount = 12000; - } - if (this.mProcessingEnergy <= 0 && aBaseMetaTileEntity.isAllowedToWork() && aTick % 256L == 0L - && !aBaseMetaTileEntity.getWorld().isThundering()) { - final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() - && aBaseMetaTileEntity.getBiome().rainfall > 0.0F; - this.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); - } - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mRunTime", this.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/GregtechMetaTileEntityDoubleFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java index b05e1cb2a0..65a2892710 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java @@ -1,8 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; -import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +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; @@ -12,152 +13,124 @@ import gregtech.api.util.GT_Recipe; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; -public class GregtechMetaTileEntityDoubleFuelGeneratorBase extends GregtechRocketFuelGeneratorBase { - - public int mEfficiency; - - public GregtechMetaTileEntityDoubleFuelGeneratorBase(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires two liquid Fuels. Fuel A is Fastburn, Fuel B is slowburn.", - new ITexture[0]); - this.onConfigLoad(); - } - - public GregtechMetaTileEntityDoubleFuelGeneratorBase(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { - super.getBack(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent) - }; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { - super.getBackActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast) - }; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { - super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) - }; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { - super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) - }; - } - - @Override - public int getCapacity() { - return 32000; - } +public class GregtechMetaTileEntityDoubleFuelGeneratorBase + extends GregtechRocketFuelGeneratorBase { - private GT_RenderedTexture getCasingTexture() { - if (this.mTier <= 4) { - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - else if (this.mTier == 5) { + public int mEfficiency; - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); - } - else if (this.mTier >= 6) { + public GregtechMetaTileEntityDoubleFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires two liquid Fuels. Fuel A is Fastburn, Fuel B is slowburn.", new ITexture[0]); + onConfigLoad(); + } - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); - } - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } + public GregtechMetaTileEntityDoubleFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { - super.getFront(aColor)[0], this.getCasingTexture(), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] - }; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { - super.getFrontActive(aColor)[0], this.getCasingTexture(), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] - }; - } - - @Override - public int getFuelValue(final 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 + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityDoubleFuelGeneratorBase(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 ITexture[] getSides(final byte aColor) { - return new ITexture[] { - super.getSides(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal) - }; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { - super.getSidesActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active) - }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { - super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) - }; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { - super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) - }; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityDoubleFuelGeneratorBase(this.mName, this.mTier, this.mDescription, - this.mTextures); - } - - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, - "RocketEngine.efficiency.tier." + this.mTier, 100 - this.mTier * 8); - } + 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; + } + + private GT_RenderedTexture getCasingTexture(){ + if (this.mTier <= 4){ + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + else if (this.mTier == 5){ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + else if (this.mTier >= 6){ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent)}; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal)}; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast)}; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active)}; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java index 6c0df9ea99..b45cf93bff 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java @@ -1,8 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; -import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +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; @@ -13,159 +14,132 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; -public class GregtechMetaTileEntityGeothermalGenerator extends GT_MetaTileEntity_BasicGenerator { +public class GregtechMetaTileEntityGeothermalGenerator +extends GT_MetaTileEntity_BasicGenerator +{ public int mEfficiency; - public GregtechMetaTileEntityGeothermalGenerator(final int aID, final String aName, final String aNameRegional, - final int aTier) { + public GregtechMetaTileEntityGeothermalGenerator(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, "Requires Pahoehoe Lava or Normal Lava as Fuel", new ITexture[0]); - this.onConfigLoad(); + onConfigLoad(); } - public GregtechMetaTileEntityGeothermalGenerator(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { + public GregtechMetaTileEntityGeothermalGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } + onConfigLoad(); + } @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { - super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical) - }; - } + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { - super.getBackActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical_Active) - }; + public int getCapacity() { + //return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); + return 5000*this.mTier; } - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { - super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) - }; + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "ThermalGenerator.efficiency.tier." + this.mTier, (100 - this.mTier * 7)); } @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { - super.getBottomActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) - }; + public int getEfficiency() { + return this.mEfficiency; } @Override - public int getCapacity() { - // return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); - return 5000 * this.mTier; + 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 String[] getDescription() { - return new String[] { - "Generates power from Lava/Pahoehoe at " + this.getEfficiency() + "% Efficiency per tick" - }; + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); } @Override - public int getEfficiency() { - return this.mEfficiency; + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityGeothermalGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { - super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] - }; + public ITexture[] getFront(byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; } @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { - super.getFrontActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] - }; + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical)}; } @Override - public int getFuelValue(final 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; + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM)}; } - public int getPollution() { - return 100; + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER)}; } @Override - public GT_Recipe_Map getRecipes() { - return GT_Recipe_Map.sHotFuels; + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT)}; } @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { - super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT) - }; + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; } @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { - super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE) - }; + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Vertical_Active)}; } @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { - super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER) - }; + 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(final byte aColor) { - return new ITexture[] { - super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE) - }; + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_SIDE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_ROCK_BREAKER_ACTIVE)}; } @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE)}; } + @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityGeothermalGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + public String[] getDescription() + { + return new String[] {"Generates power from Lava/Pahoehoe at " + getEfficiency() + "% Efficiency per tick"}; } - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, - "ThermalGenerator.efficiency.tier." + this.mTier, 100 - this.mTier * 7); + @Override + public GT_Recipe_Map getRecipes() + { + return GT_Recipe_Map.sHotFuels; } - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; + + public int getPollution() { + return 100; } }
\ 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 index 95194a5ecb..59e4a1b875 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -1,8 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; -import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +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; @@ -12,150 +13,124 @@ import gregtech.api.util.GT_Recipe; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.registry.GameRegistry; -public class GregtechMetaTileEntityRocketFuelGenerator extends GregtechRocketFuelGeneratorBase { - - public int mEfficiency; - - public GregtechMetaTileEntityRocketFuelGenerator(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires liquid Fuels.", new ITexture[0]); - this.onConfigLoad(); - } - - public GregtechMetaTileEntityRocketFuelGenerator(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { - super.getBack(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent) - }; - } - - @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { - super.getBackActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast) - }; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { - super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) - }; - } - - @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { - super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom) - }; - } - - @Override - public int getCapacity() { - return 32000; - } +public class GregtechMetaTileEntityRocketFuelGenerator + extends GregtechRocketFuelGeneratorBase { - private GT_RenderedTexture getCasingTexture() { - if (this.mTier <= 4) { - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } - else if (this.mTier == 5) { + public int mEfficiency; - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); - } - else if (this.mTier >= 6) { + public GregtechMetaTileEntityRocketFuelGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Requires liquid Fuels.", new ITexture[0]); + onConfigLoad(); + } - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); - } - return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); - } + public GregtechMetaTileEntityRocketFuelGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { - super.getFront(aColor)[0], this.getCasingTexture(), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] - }; - } - - @Override - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { - super.getFrontActive(aColor)[0], this.getCasingTexture(), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier] - }; - } - - @Override - public int getFuelValue(final 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 + @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 ITexture[] getSides(final byte aColor) { - return new ITexture[] { - super.getSides(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal) - }; - } - - @Override - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { - super.getSidesActive(aColor)[0], this.getCasingTexture(), - new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_Active) - }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { - super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) - }; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { - super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) - }; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, - "RocketEngine.efficiency.tier." + this.mTier, 100 - this.mTier * 8); - } + 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; + } + + private GT_RenderedTexture getCasingTexture(){ + if (this.mTier <= 4){ + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + else if (this.mTier == 5){ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + else if (this.mTier >= 6){ + + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[]{super.getFront(aColor)[0], getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent)}; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal)}; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{super.getFrontActive(aColor)[0], getCasingTexture(), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast)}; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Bottom)}; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{super.getSidesActive(aColor)[0], getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Diesel_Horizontal_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 index 50303dbfcd..c41c1851fa 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java @@ -1,7 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; +import static gregtech.api.enums.GT_Values.V; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +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; @@ -14,200 +16,159 @@ import net.minecraft.entity.player.InventoryPlayer; public class GregtechMetaTileEntitySolarGenerator extends GregtechMetaSolarGenerator { - 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) - }; - - public GregtechMetaTileEntitySolarGenerator(final int aID, final String aName, final String aNameRegional, - final int aTier) { + 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]); - this.onConfigLoad(); + onConfigLoad(); } - public GregtechMetaTileEntitySolarGenerator(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { + public GregtechMetaTileEntitySolarGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); + onConfigLoad(); } @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { - super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) - }; + public boolean isOutputFacing(byte aSide) { + return aSide == getBaseMetaTileEntity().getFrontFacing(); } @Override - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { - super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE) - }; + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, 16000); } @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { - super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) - }; + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); } @Override - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { - super.getBottomActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE) - }; + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntitySolarGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "SunAbsorber.efficiency.tier." + this.mTier, 100 - this.mTier * 10); + } @Override - public int getEfficiency() { - return this.mEfficiency; + 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 ITexture[] getFront(final 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] - }; + public void inValidate() { + } @Override - public ITexture[] getFrontActive(final 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] - }; + public int getEfficiency() { + return this.mEfficiency; } @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, 16000); + 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[] getSides(final byte aColor) { - return new ITexture[] { - super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) - }; + 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[] getSidesActive(final byte aColor) { - return new ITexture[] { - super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE) - }; + public ITexture[] getBack(byte aColor) { + return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; } @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { - super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL) - }; + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; } @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { - super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL) - }; + public ITexture[] getTop(byte aColor) { + return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; } @Override - public void inValidate() { - + public ITexture[] getSides(byte aColor) { + return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; } @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + 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 long maxEUStore() { - return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 16000 + this.getMinimumStoredEU()); + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; } @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntitySolarGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; } - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, - "SunAbsorber.efficiency.tier." + this.mTier, 100 - this.mTier * 10); - + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; } @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity - .getUniversalEnergyStored() < this.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: " - + (this.maxEUOutput() * 20 + this.getMinimumStoredEU())); - - if (this.mSolarCharge > 100 && aBaseMetaTileEntity.isAllowedToWork() - && !aBaseMetaTileEntity.getWorld().isThundering() && aBaseMetaTileEntity - .getUniversalEnergyStored() < this.maxEUStore() - this.getMinimumStoredEU()) { - this.getBaseMetaTileEntity().increaseStoredEnergyUnits( - GregtechMetaSolarGenerator.sEnergyPerTick * this.getEfficiency(), true); - } - } - - if (this.mSolarCharge < 500 && this.mProcessingEnergy != 0 && aTick % 32L == 0L) { - Utils.LOG_WARNING("Adding Solar Charge. Currently " + this.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 " + this.mProcessingEnergy); - final boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() - && aBaseMetaTileEntity.getBiome().rainfall > 0.0F; - this.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() >= this.maxEUOutput() + this.getMinimumStoredEU()); - } - } + 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 index be4a51a02f..5d1befbbad 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java @@ -8,129 +8,97 @@ 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(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires liquid Nitrogen/Helium", new ITexture[0]); - this.onConfigLoad(); - } - - public GregtechMetaTileEntitySuperCondensor(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.onConfigLoad(); - } - - @Override - public ITexture[] getBack(final 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[] getBackActive(final 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[] getBottom(final 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[] getBottomActive(final 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 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; - } + return 64000; + } - @Override + public void onConfigLoad() { + this.mEfficiency = 100; + } + + @Override public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public ITexture[] getFront(final 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[] getFrontActive(final 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 GT_Recipe.GT_Recipe_Map getRecipes() { - return GT_Recipe.GT_Recipe_Map.sDieselFuels; - } - - @Override - public ITexture[] getSides(final 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[] getSidesActive(final byte aColor) { - return new ITexture[] { - super.getSidesActive(aColor)[0], - new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), - Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier] - }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { - super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP) - }; - } - - @Override - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { - super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE) - }; - } - - @Override - public boolean isOutputFacing(final byte aSide) { - return aSide == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntitySuperCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - public void onConfigLoad() { - this.mEfficiency = 100; - } + 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/basic/GregtechMetaTileEntityChunkLoader.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java index 9df0d03a1b..0d9fadc6df 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java @@ -1,6 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import gregtech.api.enums.GT_Values; +import static gregtech.api.enums.GT_Values.V; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -13,141 +13,117 @@ import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredMachineBlock { - public int mRange = 16; - - public GregtechMetaTileEntityChunkLoader(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Reprells nasty Creatures. Range: " + (4 + 12 * aTier) - + " unpowered / " + (16 + 48 * aTier) + " powered"); - } - - public GregtechMetaTileEntityChunkLoader(final String aName, final int aTier, final int aInvSlotCount, - final String aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 512; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return new ITexture[] { - Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - aSide != 1 ? null - : aActive ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) - : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER) - }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return null; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return true; - } - - @Override - public boolean isInputFacing(final byte aSide) { - return true; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - } - - @Override - public long maxAmperesIn() { - return 2; - } - - @Override - public long maxEUInput() { - return GT_Values.V[this.mTier]; - } - - @Override - public long maxEUStore() { - return 512 + GT_Values.V[this.mTier] * 50; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityChunkLoader(this.mName, this.mTier, this.mInventory.length, this.mDescription, - this.mTextures); - } - - @Override - public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) { - final int[] tCoords = new int[] { - aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), - aBaseMetaTileEntity.getWorld().provider.dimensionId - }; - GT_SpawnEventHandler.mobReps.add(tCoords); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { - if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide()) { - final int[] tCoords = new int[] { - aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), - aBaseMetaTileEntity.getWorld().provider.dimensionId - }; - if (aTimer % 600 == 0 && !GT_SpawnEventHandler.mobReps.contains(tCoords)) { - GT_SpawnEventHandler.mobReps.add(tCoords); - } - if (aBaseMetaTileEntity.isUniversalEnergyStored(this.getMinimumStoredEU()) - && aBaseMetaTileEntity.decreaseStoredEnergyUnits(1 << this.mTier * 2, false)) { - this.mRange = 16 + 48 * this.mTier; - } - else { - this.mRange = 4 + 12 * this.mTier; - } - } - } - - @Override - public void onRemoval() { - final int[] tCoords = new int[] { - this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), - this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId - }; - GT_SpawnEventHandler.mobReps.remove(tCoords); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - } + public int mRange = 16; + + public GregtechMetaTileEntityChunkLoader(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 0, "Reprells nasty Creatures. Range: " + (4 + (12 * aTier)) + " unpowered / " + (16 + (48 * aTier)) + " powered"); + } + + public GregtechMetaTileEntityChunkLoader(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityChunkLoader(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], (aSide != 1) ? null : aActive ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER)}; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide()) { + int[] tCoords = new int[]{aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), aBaseMetaTileEntity.getWorld().provider.dimensionId}; + if ((aTimer % 600 == 0) && !GT_SpawnEventHandler.mobReps.contains(tCoords)) { + GT_SpawnEventHandler.mobReps.add(tCoords); + } + if (aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && aBaseMetaTileEntity.decreaseStoredEnergyUnits(1 << (this.mTier * 2), false)) { + mRange = 16 + (48 * mTier); + } else { + mRange = 4 + (12 * mTier); + } + } + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + int[] tCoords = new int[]{aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), aBaseMetaTileEntity.getWorld().provider.dimensionId}; + GT_SpawnEventHandler.mobReps.add(tCoords); + } + + @Override + public void onRemoval() { + int[] tCoords = new int[]{this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId}; + GT_SpawnEventHandler.mobReps.remove(tCoords); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return true; + } + + @Override + public boolean isTeleporterCompatible() { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public long maxEUStore() { + return 512 + V[mTier] * 50; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java index 102b79111f..4f893cc556 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java @@ -1,126 +1,200 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - -import org.apache.commons.lang3.ArrayUtils; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.*; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.ArrayUtils; + public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase { - public static int sUUAperUUM = 1; - public static int sUUASpeedBonus = 4; - public static int sDurationMultiplier = 3215; - public static boolean sRequiresUUA = false; - private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); - // public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); - private int recipeCounter = 0; + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3215; + public static boolean sRequiresUUA = false; + private int recipeCounter = 0; + private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); + //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); - public GregtechMTE_NuclearReactor(final int aID, final String aName, final String aNameRegional) { + public GregtechMTE_NuclearReactor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMTE_NuclearReactor(final String aName) { + public GregtechMTE_NuclearReactor(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - for (int i = -3; i < 3; i++) { + public String[] getDescription() { + return new String[]{ + "Controller Block for the Nuclear Reactor", + "Produces heat from Radioactive beta decay.", + "Size(WxHxD): 5x4x5, Controller (Bottom center)", + "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", + "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", + "1x Input Hatch (Any bottom layer casing)", + "1x Output Hatch (Any bottom layer casing)", + "1x Maintenance Hatch (Any bottom layer casing)", + "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", + "1x Energy Hatch (Any bottom layer casing)", + "24x IC2 Reinforced Glass for the walls", + "Matter Fabricator Casings for the edges & top (40 at least!)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) { + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, tFluidList.size()); + if (tFluids.length > 0) { + for(int i = 0;i<tFluids.length;i++){ + GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tFluids[i]}, new ItemStack[]{}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[]{})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = ((tRecipe.mDuration/**sDurationMultiplier*/) / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = (tRecipe.mDuration/**sDurationMultiplier*/); + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + this.mOutputFluids = tRecipe.mFluidOutputs.clone(); + ArrayUtils.reverse(mOutputFluids); + recipeCounter++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+recipeCounter); + return true; + } + } + else { + Utils.LOG_INFO("Invalid Recipe"); + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + for (int i = -3; i < 4; i++) { for (int j = -3; j < 4; j++) { - for (int h = 0; h < 3; h++) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - h, zDir + j); + for (int h = 0; h < 4; h++) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (i != -3 && i != 3 && j != -3 && j != 3) {// Reactor - // Floor/Roof - // inner 7x7 - if (h == 0 || h == 4) {// Reactor Floor & Roof (Inner - // 7x7) + muffler x4 - if (!this.addMufflerToMachineList(tTileEntity, 66)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the top layers inner 3x3."); + if ((i != -3 && i != 3) && (j != -3 && j != 3)) {// Reactor Floor/Roof inner 7x7 + if (h == 0 || h == 4) {// Reactor Floor & Roof (Inner 7x7) + muffler x4 + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the top layers inner 3x3."); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); return false; } } - } - else {// Inside 6 layers, mostly air - if (i != -1 && i != 1 && j != -1 && j != 1) {// Reactor - // Floor/Roof - // inner - // 5x5 + } else {// Inside 6 layers, mostly air + if ((i != -1 && i != 1) && (j != -1 && j != 1)) {// Reactor Floor/Roof inner 5x5 if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); return false; } } - else { // carbon moderation rods are at 1,1 & -1,-1 - // & 1,-1 & -1,1 - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the top layers inner 3x3."); + else { //carbon moderation rods are at 1,1 & -1,-1 & 1,-1 & -1,1 + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the top layers inner 3x3."); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); return false; } - } + } } } // End Inner Workings else {// Reactor Exterior if (h == 1) { - if ((i == -3 || i == 3) && (j == -3 || j == 3)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Block temp = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - Utils.LOG_INFO( - "Reactor Casings Missing from one of the corners in the second layer. Block: "+temp.getLocalizedName() - +" x:"+(aBaseMetaTileEntity.getXCoord()+xDir+i) - +" y:"+(aBaseMetaTileEntity.getYCoord()+h) - +" z:"+(aBaseMetaTileEntity.getZCoord()+zDir+j) - ); + if ((i == -3 || i == 3) && (j == -3 || j == 3)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the corners in the second layer. Meta"); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); return false; } } - else if ((i != -3 || i != 3) && (j != -3 || j != 3)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { + else if ((i != -3 || i != 3) && (j != -3 || j != 3)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); return false; } @@ -131,23 +205,19 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } } if (h == 2) { - if ((i == -3 || i == 3) && (j == -3 || j == 3)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the corners in the third layer."); + if ((i == -3 || i == 3) && (j == -3 || j == 3)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the corners in the third layer."); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); return false; } } - else if ((i != -3 || i != 3) && (j != -3 || j != 3)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { + else if ((i != -3 || i != 3) && (j != -3 || j != 3)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); return false; } @@ -158,15 +228,12 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } } if (h == 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the edges on the top layer."); + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO( - "Reactor Casings Missing from one of the edges on the top layer."); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); return false; } } @@ -181,143 +248,38 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } - } - - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, - tFluidList.size()); - if (tFluids.length > 0) { - for (int i = 0; i < tFluids.length; i++) { - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[] { - tFluids[i] - }, new ItemStack[] {}); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - } - else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - tRecipe.getOutput(0) - }; - this.mOutputFluids = tRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(this.mOutputFluids); - this.recipeCounter++; - this.updateSlots(); - // Utils.LOG_INFO("Recipes Finished: "+recipeCounter); - return true; - } - } - else { - Utils.LOG_INFO("Invalid Recipe"); - } - } - } - return false; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public int getDamageToComponent(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Nuclear Reactor", "Produces heat from Radioactive beta decay.", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", - "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", - "1x Input Hatch (Any bottom layer casing)", "1x Output Hatch (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", - "1x Energy Hatch (Any bottom layer casing)", "24x IC2 Reinforced Glass for the walls", - "Reactor Casings for the edges, bottom & top (40 at least!)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getDamageToComponent(ItemStack aStack) { return 0; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[66], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[66] - }; + public int getAmountOfOutputs() { + return 1; } @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GregtechMTE_NuclearReactor(this.mName); } - @Override - public void onConfigLoad(final GT_Config aConfig) { - } - }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java index 2d9512ce2f..bb7327857a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; @@ -10,242 +7,226 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.*; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.util.Utils; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_AlloyBlastSmelter extends GT_MetaTileEntity_MultiBlockBase { - private int mHeatingCapacity = 0; - - public GregtechMetaTileEntity_AlloyBlastSmelter(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntity_AlloyBlastSmelter(final String aName) { - super(aName); - } - - @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - - // this.mHeatingCapacity = 0; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - return false; - } - if (!aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir)) { - return false; - } - this.addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), 72); - - final byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); - - this.mHeatingCapacity = 20000; - - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i != 0 || j != 0) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 14) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != 14) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 15) { - return false; - } - } - } - } - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (xDir + i != 0 || zDir + j != 0) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - 0, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 72) - && !this.addInputToMachineList(tTileEntity, 72) - && !this.addOutputToMachineList(tTileEntity, 72) - && !this.addEnergyInputToMachineList(tTileEntity, 72)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 15) { - return false; - } - } - } - } - } - this.mHeatingCapacity += 100 * (GT_Utility.getTier(this.getMaxInputVoltage()) - 2); - return true; - } - - @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - if (tInputList.size() > 1) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null && this.mHeatingCapacity >= tRecipe.mSpecialValue - && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - Utils.LOG_WARNING("Found some Valid Inputs."); - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - } - else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputFluids = new FluidStack[] { - tRecipe.getFluidOutput(0) - }; - this.updateSlots(); - return true; - } - } - Utils.LOG_WARNING("Failed to find some Valid Inputs."); - return false; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "ElectricBlastFurnace.png"); - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override +public class GregtechMetaTileEntity_AlloyBlastSmelter + extends GT_MetaTileEntity_MultiBlockBase { + private int mHeatingCapacity = 0; + + public GregtechMetaTileEntity_AlloyBlastSmelter(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GregtechMetaTileEntity_AlloyBlastSmelter(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); + } + + @Override public String[] getDescription() { - return new String[] { - "Controller Block for the Alloy Blast Smelter", // Outputs 144mb - // fluid for - // every - // inputStack.stackSize; - // Time to use - // those hot - // metals. - "Size: 3x3x4 (Hollow)", "Controller (front middle at bottom)", - "16x Blast Smelter Heat Containment Coils (two middle Layers, hollow)", "1x Input bus (one of bottom)", - "1x Output Hatch (one of bottom)", "1x Energy Hatch (one of bottom)", - "1x Maintenance Hatch (one of bottom)", "1x Muffler Hatch (top middle)", - "Blast Smelter Casings for the rest" - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 10; - } - - @Override + return new String[]{ + "Controller Block for the Alloy Blast Smelter", //Outputs 144mb fluid for every inputStack.stackSize; Time to use those hot metals. + "Size: 3x3x4 (Hollow)", + "Controller (front middle at bottom)", + "16x Blast Smelter Heat Containment Coils (two middle Layers, hollow)", + "1x Input bus (one of bottom)", + "1x Output Hatch (one of bottom)", + "1x Energy Hatch (one of bottom)", + "1x Maintenance Hatch (one of bottom)", + "1x Muffler Hatch (top middle)", + "Blast Smelter Casings for the rest"}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[72], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[72]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "ElectricBlastFurnace.png"); + } + + @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[72], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[72] - }; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_AlloyBlastSmelter(this.mName); - } + return Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + if (tInputList.size() > 1) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (this.mHeatingCapacity >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + Utils.LOG_WARNING("Found some Valid Inputs."); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + updateSlots(); + return true; + } + } + Utils.LOG_WARNING("Failed to find some Valid Inputs."); + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + + //this.mHeatingCapacity = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + if (!aBaseMetaTileEntity.getAirOffset(xDir, 2, zDir)) { + return false; + } + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 3, zDir), 72); + + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 2, zDir); + + this.mHeatingCapacity = 20000; + + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 14) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != 14) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j) != 15) { + return false; + } + } + } + } + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((xDir + i != 0) || (zDir + j != 0)) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 72)) && (!addInputToMachineList(tTileEntity, 72)) && (!addOutputToMachineList(tTileEntity, 72)) && (!addEnergyInputToMachineList(tTileEntity, 72))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 15) { + return false; + } + } + } + } + } + this.mHeatingCapacity += 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 10; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public int getAmountOfOutputs() { + return 2; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java index db857a782d..0838bdefbd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -1,10 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.ArrayUtils; - import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -21,137 +16,111 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +import java.util.ArrayList; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_MultiBlockBase { - private static boolean controller; - private static boolean isDisabled = false; - private static ITexture frontFace; - private static ITexture frontFaceActive; - private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); - private static CustomIcon GT9_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); - // public static double recipesComplete = 0; - - ArrayList<ItemStack> tInputList = this.getStoredInputs(); +import org.apache.commons.lang3.ArrayUtils; - GT_Recipe mLastRecipe; +public class GregtechMetaTileEntity_IndustrialCentrifuge +extends GregtechMeta_MultiBlockBase { + private static boolean controller; + private static boolean isDisabled = false; + private static ITexture frontFace; + private static ITexture frontFaceActive; + private static CustomIcon GT9_5_Active = new CustomIcon("iconsets/LARGECENTRIFUGE_ACTIVE5"); + private static CustomIcon GT9_5 = new CustomIcon("iconsets/LARGECENTRIFUGE5"); + //public static double recipesComplete = 0; - public GregtechMetaTileEntity_IndustrialCentrifuge(final int aID, final String aName, final String aNameRegional) { + public GregtechMetaTileEntity_IndustrialCentrifuge(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - GregtechMetaTileEntity_IndustrialCentrifuge.frontFaceActive = new GT_RenderedTexture( - GregtechMetaTileEntity_IndustrialCentrifuge.GT9_5_Active); - GregtechMetaTileEntity_IndustrialCentrifuge.frontFace = new GT_RenderedTexture( - GregtechMetaTileEntity_IndustrialCentrifuge.GT9_5); + frontFaceActive = new GT_RenderedTexture(GT9_5_Active); + frontFace = new GT_RenderedTexture(GT9_5); } - public GregtechMetaTileEntity_IndustrialCentrifuge(final String aName) { + public GregtechMetaTileEntity_IndustrialCentrifuge(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - /* - * if (configSwitches.disableCentrifugeFormation){ EntityPlayerMP player - * = - * MinecraftServer.getServer().getConfigurationManager().func_152612_a( - * this.getBaseMetaTileEntity().getOwnerName()); if - * (!player.getEntityWorld().isRemote && isDisabled == false) - * PlayerUtils.messagePlayer(player, - * "This Multiblock is disabled via the config. [Only re-enable if you're bugtesting.]" - * ); isDisabled = true; return false; } - */ - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - // Utils.LOG_WARNING("X:"+xDir+" Y:"+yDir+" Z:"+zDir); - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { // X-Dir - for (int j = -1; j < 2; j++) { // Z-Dir - for (int h = -1; h < 2; h++) { // Y-Dir - if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { - - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - // Utils.LOG_WARNING("X:"+tTileEntity.getXCoord()+" - // Y:"+tTileEntity.getYCoord()+" - // Z:"+tTileEntity.getZCoord()); - if (!this.addMaintenanceToMachineList(tTileEntity, 57) - && !this.addInputToMachineList(tTileEntity, 57) - && !this.addOutputToMachineList(tTileEntity, 57) - && !this.addEnergyInputToMachineList(tTileEntity, 57)) { - - // Maintenance Hatch - if (tTileEntity != null && tTileEntity.getMetaTileEntity() != null) { - if (tTileEntity.getXCoord() == aBaseMetaTileEntity.getXCoord() - && tTileEntity.getYCoord() == aBaseMetaTileEntity.getYCoord() - && tTileEntity.getZCoord() == aBaseMetaTileEntity.getZCoord() + 2) { - if (tTileEntity - .getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance) { - Utils.LOG_WARNING("MAINT HATCH IN CORRECT PLACE"); - this.mMaintenanceHatches.add( - (GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this - .getCasingTextureIndex(); - } - else { - return false; - } - } - else { - Utils.LOG_WARNING("MAINT HATCH IN WRONG PLACE"); - } - } + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); + } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { - return false; - } - tAmount++; + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Centrifuge", + "Size: 3x3x3 (Hollow)", + "Controller (Front Center) [Orange]", + "1x Maintenance Hatch (Rear Center) [Green]", + "The rest can be placed anywhere except the Front [Red]", + "1x Input Hatch", + "1x Output Hatch", + "1x Input Bus", + "1x Output Bus", + "1x [EV] Energy Hatch (Can be higher Tier) [Blue]", + "Centrifuge Casings for the rest (16 at least)", + CORE.GT_Tooltip}; + } - } - } - } - } - } - return tAmount >= 16; + + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? frontFaceActive : frontFace : Textures.BlockIcons.CASING_BLOCKS[57]}; } + @Override - public boolean checkRecipe(final ItemStack aStack) { - /* - * if (!isCorrectMachinePart(mInventory[1])) { return false; } - */ + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialCentrifuge.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + ArrayList<ItemStack> tInputList = getStoredInputs(); + GT_Recipe mLastRecipe; + + @Override + public boolean checkRecipe(ItemStack aStack) { + /*if (!isCorrectMachinePart(mInventory[1])) { + return false; + }*/ Utils.LOG_WARNING("Centrifuge Debug - 1"); - final GT_Recipe.GT_Recipe_Map map = this.getRecipeMap(); + GT_Recipe.GT_Recipe_Map map = getRecipeMap(); if (map == null) { Utils.LOG_WARNING("Centrifuge Debug - False - No recipe map"); return false; } Utils.LOG_WARNING("Centrifuge Debug - 2"); - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - Utils.LOG_WARNING("Centrifuge Debug - Tier variable: " + tTier); - final ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - final FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + ArrayList<ItemStack> tInputList = getStoredInputs(); + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + Utils.LOG_WARNING("Centrifuge Debug - Tier variable: "+tTier); + ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); + ArrayList<FluidStack> tFluidList = getStoredFluids(); + FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); if (tInputList.size() > 0 || tFluids.length > 0) { - final GT_Recipe tRecipe = map.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, - gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); if (tRecipe != null) { Utils.LOG_WARNING("Recipe was not invalid"); - this.mLastRecipe = tRecipe; + mLastRecipe = tRecipe; this.mEUt = 0; this.mOutputItems = null; this.mOutputFluids = null; @@ -162,34 +131,29 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu } this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - Utils.LOG_WARNING("Centrifuge Debug - 2 - Max Progress Time: " + this.mMaxProgresstime); + Utils.LOG_WARNING("Centrifuge Debug - 2 - Max Progress Time: "+this.mMaxProgresstime); if (tRecipe.mEUt <= 16) { Utils.LOG_WARNING("Centrifuge Debug - Using < 16eu/t"); - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - Utils.LOG_WARNING("Centrifuge Debug - 3.1 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" - + this.mEUt + " Obscure GT Value " + gregtech.api.enums.GT_Values.V[tTier - 1]); - } - else { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + Utils.LOG_WARNING("Centrifuge Debug - 3.1 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); + } else { Utils.LOG_WARNING("Centrifuge Debug - using > 16eu/t"); this.mEUt = tRecipe.mEUt; this.mMaxProgresstime = tRecipe.mDuration; - Utils.LOG_WARNING("Centrifuge Debug - 3.2 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" - + this.mEUt + " Obscure GT Value " + gregtech.api.enums.GT_Values.V[tTier - 1]); - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { + Utils.LOG_WARNING("Centrifuge Debug - 3.2 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt + " Obscure GT Value "+gregtech.api.enums.GT_Values.V[(tTier - 1)]); + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; this.mMaxProgresstime /= 2; - Utils.LOG_WARNING("Centrifuge Debug - 4 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" - + this.mEUt); + Utils.LOG_WARNING("Centrifuge Debug - 4 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); } } this.mEUt *= 1; if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - Utils.LOG_WARNING( - "Centrifuge Debug - 5 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" + this.mEUt); + this.mEUt = (-this.mEUt); + Utils.LOG_WARNING("Centrifuge Debug - 5 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); } ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; for (int h = 0; h < tRecipe.mOutputs.length; h++) { @@ -197,34 +161,30 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu tOut[h].stackSize = 0; } FluidStack tFOut = null; - if (tRecipe.getFluidOutput(0) != null) { - tFOut = tRecipe.getFluidOutput(0).copy(); - } + if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); for (int f = 0; f < tOut.length; f++) { if (tRecipe.mOutputs[f] != null && tOut[f] != null) { for (int g = 0; g < 1; g++) { - if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; - } } } } if (tFOut != null) { - final int tSize = tFOut.amount; + int tSize = tFOut.amount; tFOut.amount = tSize * 6; } this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mMaxProgresstime /= 4; - if (this.mMaxProgresstime <= 0) { + if (this.mMaxProgresstime <= 0){ this.mMaxProgresstime++; } - Utils.LOG_WARNING( - "Centrifuge Debug - 6 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" + this.mEUt); - final List<ItemStack> overStacks = new ArrayList<ItemStack>(); + Utils.LOG_WARNING("Centrifuge Debug - 6 - Max Progress Time: "+this.mMaxProgresstime+" EU/t"+this.mEUt); + List<ItemStack> overStacks = new ArrayList<ItemStack>(); for (int f = 0; f < tOut.length; f++) { if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - final ItemStack tmp = tOut[f].copy(); + ItemStack tmp = tOut[f].copy(); tmp.stackSize = tmp.getMaxStackSize(); tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); overStacks.add(tmp); @@ -236,18 +196,14 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu tmp = overStacks.toArray(tmp); tOut = ArrayUtils.addAll(tOut, tmp); } - final List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (final ItemStack tS : tOut) { - if (tS.stackSize > 0) { - tSList.add(tS); - } + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOut) { + if (tS.stackSize > 0) tSList.add(tS); } tOut = tSList.toArray(new ItemStack[tSList.size()]); this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[] { - tFOut - }; - this.updateSlots(); + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); Utils.LOG_WARNING("Centrifuge: True"); return true; } @@ -256,20 +212,11 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu return false; } - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - @SuppressWarnings("static-method") public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } + @SuppressWarnings("static-method") public byte getCasingMeta() { return 0; @@ -281,66 +228,89 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends GregtechMeta_Mu } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "IndustrialCentrifuge.png"); + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + /*if (configSwitches.disableCentrifugeFormation){ + EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(this.getBaseMetaTileEntity().getOwnerName()); + if (!player.getEntityWorld().isRemote && isDisabled == false) + PlayerUtils.messagePlayer(player, "This Multiblock is disabled via the config. [Only re-enable if you're bugtesting.]"); + isDisabled = true; + return false; + }*/ + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + //Utils.LOG_WARNING("X:"+xDir+" Y:"+yDir+" Z:"+zDir); + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { //X-Dir + for (int j = -1; j < 2; j++) { //Z-Dir + for (int h = -1; h < 2; h++) { //Y-Dir + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + //Utils.LOG_WARNING("X:"+tTileEntity.getXCoord()+" Y:"+tTileEntity.getYCoord()+" Z:"+tTileEntity.getZCoord()); + if ((!addMaintenanceToMachineList(tTileEntity, 57)) && (!addInputToMachineList(tTileEntity, 57)) && (!addOutputToMachineList(tTileEntity, 57)) && (!addEnergyInputToMachineList(tTileEntity, 57))) { + + //Maintenance Hatch + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if (tTileEntity.getXCoord() == aBaseMetaTileEntity.getXCoord() && tTileEntity.getYCoord() == aBaseMetaTileEntity.getYCoord() && tTileEntity.getZCoord() == (aBaseMetaTileEntity.getZCoord()+2)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + Utils.LOG_WARNING("MAINT HATCH IN CORRECT PLACE"); + this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { + return false; + } + } + else { + Utils.LOG_WARNING("MAINT HATCH IN WRONG PLACE"); + } + } + + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 0) { + return false; + } + tAmount++; + + } + } + } + } + } + return tAmount >= 16; } - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Centrifuge", "Size: 3x3x3 (Hollow)", - "Controller (Front Center) [Orange]", "1x Maintenance Hatch (Rear Center) [Green]", - "The rest can be placed anywhere except the Front [Red]", "1x Input Hatch", "1x Output Hatch", - "1x Input Bus", "1x Output Bus", "1x [EV] Energy Hatch (Can be higher Tier) [Blue]", - "Centrifuge Casings for the rest (16 at least)", CORE.GT_Tooltip - }; + @SuppressWarnings("static-method") + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; + } + return false; } @Override - public int getMaxEfficiency(final ItemStack aStack) { + public int getMaxEfficiency(ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; + public int getAmountOfOutputs() { + return 1; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return new ITexture[] { - Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], - aFacing == aSide - ? aActive ? GregtechMetaTileEntity_IndustrialCentrifuge.frontFaceActive - : GregtechMetaTileEntity_IndustrialCentrifuge.frontFace - : Textures.BlockIcons.CASING_BLOCKS[57] - }; - } - - @SuppressWarnings("static-method") - public boolean ignoreController(final Block tTileEntity) { - if (!GregtechMetaTileEntity_IndustrialCentrifuge.controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; - } + public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); - } - }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java index 5d0ceb53e8..c2e2df7a8f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -1,284 +1,278 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.*; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_IndustrialCokeOven extends GregtechMeta_MultiBlockBase { - private int mLevel = 0; - - public GregtechMetaTileEntity_IndustrialCokeOven(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } +public class GregtechMetaTileEntity_IndustrialCokeOven + extends GregtechMeta_MultiBlockBase { + private int mLevel = 0; - public GregtechMetaTileEntity_IndustrialCokeOven(final String aName) { - super(aName); - } + public GregtechMetaTileEntity_IndustrialCokeOven(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } - @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int xr = aBaseMetaTileEntity.getXCoord(); - int yr = aBaseMetaTileEntity.getYCoord(); - int zr = aBaseMetaTileEntity.getZCoord(); - this.mLevel = 0; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { - return false; - } - this.addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), - GregtechMetaCasingBlocks.GTID + 1); + public GregtechMetaTileEntity_IndustrialCokeOven(String aName) { + super(aName); + } - final byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); - switch (tUsedMeta) { - case 2: - this.mLevel = 1; - break; - case 3: - this.mLevel = 2; - break; - default: - return false; - } - this.mOutputItems = new ItemStack[12 * this.mLevel]; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i != 0 || j != 0) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 1) { - return false; - } - } - } - } - for (int i = -1; i < 2; i++) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - // Utils.LOG_WARNING("STEP 1 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); - for (int j = -1; j < 2; j++) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - // Utils.LOG_WARNING("STEP 2 - x ["+xr+"] y ["+yr+"] z - // ["+zr+"]"); - if (xDir + i != 0 || zDir + j != 0) { - xr = aBaseMetaTileEntity.getXCoord(); - yr = aBaseMetaTileEntity.getYCoord(); - zr = aBaseMetaTileEntity.getZCoord(); - // Utils.LOG_WARNING("STEP 3 - x ["+xr+"] y ["+yr+"] z - // ["+zr+"]"); - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - 0, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, GregtechMetaCasingBlocks.GTID + 1) - && !this.addInputToMachineList(tTileEntity, GregtechMetaCasingBlocks.GTID + 1) - && !this.addOutputToMachineList(tTileEntity, GregtechMetaCasingBlocks.GTID + 1) - && !this.addEnergyInputToMachineList(tTileEntity, GregtechMetaCasingBlocks.GTID + 1)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 1) { - return false; - } - } - } - } - } - return true; - } + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); + } - @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + @Override + public String[] getDescription() { + return new String[]{"Processes Logs and Coal into Charcoal and Coal Coke.", + "Controller Block for the Industrial Coke Oven", + "Size: 3x3x3 (Hollow)", + "Controller (front middle at bottom)", + "8x Heat Resistant/Proof Coils (middle Layer, hollow)", + "1x Input (one of bottom)", + "1x Output (one of bottom)", + "1x Energy Hatch (one of bottom)", + "1x Maintenance Hatch (one of bottom)", + "1x Muffler Hatch (top middle)", + "Structural Coke Oven Casings for the rest", + CORE.GT_Tooltip}; + } - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1]}; + } - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "CokeOven.png"); + } - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null && this.mLevel >= tRecipe.mSpecialValue - && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - } - else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - tRecipe.getOutput(0) - }; - this.mOutputFluids = new FluidStack[] { - tRecipe.getFluidOutput(0) - }; - this.updateSlots(); - // Utils.LOG_INFO("Coke oven: True"); - return true; - } - } - // Utils.LOG_INFO("Coke oven: False"); - return false; - } - /* - * public boolean checkRecipe(ItemStack aStack) { ArrayList<ItemStack> - * tInputList = getStoredInputs(); if (!tInputList.isEmpty()) { byte tTier = - * (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); - * - * int j = 0; this.mOutputItems = new ItemStack[12 * this.mLevel]; for (int - * i = 0; (i < 100) && (j < this.mOutputItems.length); i++) { if (null != - * (this.mOutputItems[j] = GT_ModHandler.getSmeltingOutput((ItemStack) - * tInputList.get(i % tInputList.size()), true, null))) { j++; } } if (j > - * 0) { this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * - * 1000); this.mEfficiencyIncrease = 10000; - * - * this.mEUt = (-4 * (1 << tTier - 1) * (1 << tTier - 1) * this.mLevel); - * this.mMaxProgresstime = Math.max(1, 512 / (1 << tTier - 1)); } - * updateSlots(); return true; } return false; } - */ + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; + + } - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } + /* @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + }*/ - @Override - public int getAmountOfOutputs() { - return 24; - } + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "CokeOven.png"); - } + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - /* - * @Override public boolean isCorrectMachinePart(ItemStack aStack) { return - * true; } - */ + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (this.mLevel >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + this.mOutputFluids = new FluidStack[]{tRecipe.getFluidOutput(0)}; + updateSlots(); + //Utils.LOG_INFO("Coke oven: True"); + return true; + } + } + //Utils.LOG_INFO("Coke oven: False"); + return false; + } + /*public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + if (!tInputList.isEmpty()) { + byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); - @Override - public String[] getDescription() { - return new String[] { - "Processes Logs and Coal into Charcoal and Coal Coke.", "Controller Block for the Industrial Coke Oven", - "Size: 3x3x3 (Hollow)", "Controller (front middle at bottom)", - "8x Heat Resistant/Proof Coils (middle Layer, hollow)", "1x Input (one of bottom)", - "1x Output (one of bottom)", "1x Energy Hatch (one of bottom)", "1x Maintenance Hatch (one of bottom)", - "1x Muffler Hatch (top middle)", "Structural Coke Oven Casings for the rest", CORE.GT_Tooltip - }; - } + int j = 0; + this.mOutputItems = new ItemStack[12 * this.mLevel]; + for (int i = 0; (i < 100) && (j < this.mOutputItems.length); i++) { + if (null != (this.mOutputItems[j] = GT_ModHandler.getSmeltingOutput((ItemStack) tInputList.get(i % tInputList.size()), true, null))) { + j++; + } + } + if (j > 0) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } + this.mEUt = (-4 * (1 << tTier - 1) * (1 << tTier - 1) * this.mLevel); + this.mMaxProgresstime = Math.max(1, 512 / (1 << tTier - 1)); + } + updateSlots(); + return true; + } + return false; + }*/ - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int xr = aBaseMetaTileEntity.getXCoord(); + int yr = aBaseMetaTileEntity.getYCoord(); + int zr = aBaseMetaTileEntity.getZCoord(); + this.mLevel = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { + return false; + } + addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 2, zDir), GTID+1); - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; + byte tUsedMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + 1, 1, zDir); + switch (tUsedMeta) { + case 2: + this.mLevel = 1; + break; + case 3: + this.mLevel = 2; + break; + default: + return false; + } + this.mOutputItems = new ItemStack[12 * this.mLevel]; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if ((i != 0) || (j != 0)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != tUsedMeta) { + return false; + } + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != 1) { + return false; + } + } + } + } + for (int i = -1; i < 2; i++) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 1 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + for (int j = -1; j < 2; j++) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 2 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + if ((xDir + i != 0) || (zDir + j != 0)) { + xr = aBaseMetaTileEntity.getXCoord(); + yr = aBaseMetaTileEntity.getYCoord(); + zr = aBaseMetaTileEntity.getZCoord(); + //Utils.LOG_WARNING("STEP 3 - x ["+xr+"] y ["+yr+"] z ["+zr+"]"); + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, GTID+1)) && (!addInputToMachineList(tTileEntity, GTID+1)) && (!addOutputToMachineList(tTileEntity, GTID+1)) && (!addEnergyInputToMachineList(tTileEntity, GTID+1))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != ModBlocks.blockCasingsMisc) { + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != 1) { + return false; + } + } + } + } + } + return true; + } - } + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 1], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 1] - }; - } + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } - /* - * @Override public int getDamageToComponent(ItemStack aStack) { return 0; } - */ + /* @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + }*/ - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } + @Override + public int getAmountOfOutputs() { + return 24; + } - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); - } + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java index 16920395f7..1680006afd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialElectrolyzer.java @@ -1,9 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.*; - -import org.apache.commons.lang3.ArrayUtils; - +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -17,154 +14,160 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_IndustrialElectrolyzer extends GregtechMeta_MultiBlockBase { - ArrayList<ItemStack> tInputList = this.getStoredInputs(); - - GT_Recipe mLastRecipe; +import org.apache.commons.lang3.ArrayUtils; - public GregtechMetaTileEntity_IndustrialElectrolyzer(final int aID, final String aName, - final String aNameRegional) { +public class GregtechMetaTileEntity_IndustrialElectrolyzer +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialElectrolyzer(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialElectrolyzer(final String aName) { + public GregtechMetaTileEntity_IndustrialElectrolyzer(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 62) - && !this.addMufflerToMachineList(tTileEntity, 62) - && !this.addInputToMachineList(tTileEntity, 62) - && !this.addOutputToMachineList(tTileEntity, 62) - && !this.addEnergyInputToMachineList(tTileEntity, 62)) { - final Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - final byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (tBlock != ModBlocks.blockCasingsMisc || tMeta != 5) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); } @Override - public boolean checkRecipe(final ItemStack aStack) { // TODO - Add Check to - // make sure Fluid - // output isn't full - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + public String[] getDescription() { + return new String[]{"Controller Block for the Industrial Electrolyzer", + "Size: 3x3x3 (Hollow)", + "Controller (front centered)", + "1x Input Bus (anywhere)", + "1x Output Bus (anywhere)", + "1x Input Hatch (anywhere)", + "1x Output Hatch (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "1x Muffler (anywhere)", + "Electrolyzer Casings for the rest (16 at least!)", + CORE.GT_Tooltip}; + } - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5], new GT_RenderedTexture(aActive ? Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE : Textures.BlockIcons.STEAM_TURBINE_SIDE)}; } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5]}; + } - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialElectrolyzer.png"); + } - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null && 7500 >= tRecipe.mSpecialValue - && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - } - else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + ArrayList<ItemStack> tInputList = getStoredInputs(); + GT_Recipe mLastRecipe; - ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; + @Override + public boolean checkRecipe(ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (7500 >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + ItemStack[] tOut = new ItemStack[tRecipe.mOutputs.length]; for (int h = 0; h < tRecipe.mOutputs.length; h++) { tOut[h] = tRecipe.getOutput(h).copy(); tOut[h].stackSize = 0; } - FluidStack tFOut = null; - if (tRecipe.getFluidOutput(0) != null) { - tFOut = tRecipe.getFluidOutput(0).copy(); - } + FluidStack tFOut = null; + if (tRecipe.getFluidOutput(0) != null) tFOut = tRecipe.getFluidOutput(0).copy(); for (int f = 0; f < tOut.length; f++) { if (tRecipe.mOutputs[f] != null && tOut[f] != null) { for (int g = 0; g < 1; g++) { - if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; - } } } } if (tFOut != null) { - final int tSize = tFOut.amount; + int tSize = tFOut.amount; tFOut.amount = tSize * 1; } - - final List<ItemStack> overStacks = new ArrayList<ItemStack>(); + + List<ItemStack> overStacks = new ArrayList<ItemStack>(); for (int f = 0; f < tOut.length; f++) { if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - final ItemStack tmp = tOut[f].copy(); + ItemStack tmp = tOut[f].copy(); tmp.stackSize = tmp.getMaxStackSize(); tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); overStacks.add(tmp); @@ -176,100 +179,76 @@ public class GregtechMetaTileEntity_IndustrialElectrolyzer extends GregtechMeta_ tmp = overStacks.toArray(tmp); tOut = ArrayUtils.addAll(tOut, tmp); } - final List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (final ItemStack tS : tOut) { - if (tS.stackSize > 0) { - tSList.add(tS); - } + List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (ItemStack tS : tOut) { + if (tS.stackSize > 0) tSList.add(tS); } tOut = tSList.toArray(new ItemStack[tSList.size()]); this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[] { - tFOut - }; - this.updateSlots(); - - /* - * this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), - * tRecipe.getOutput(1)}; updateSlots(); - */ - return true; - } - } - return false; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } + this.mOutputFluids = new FluidStack[]{tFOut}; + updateSlots(); + + /* this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots();*/ + return true; + } + } + return false; + } @Override - public int getAmountOfOutputs() { - return 1; - } + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); + } + } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "IndustrialElectrolyzer.png"); - } - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Electrolyzer", "Size: 3x3x3 (Hollow)", - "Controller (front centered)", "1x Input Bus (anywhere)", "1x Output Bus (anywhere)", - "1x Input Hatch (anywhere)", "1x Output Hatch (anywhere)", "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", "1x Muffler (anywhere)", - "Electrolyzer Casings for the rest (16 at least!)", CORE.GT_Tooltip - }; - } + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 62)) && (!addMufflerToMachineList(tTileEntity, 62)) && (!addInputToMachineList(tTileEntity, 62)) && (!addOutputToMachineList(tTileEntity, 62)) && (!addEnergyInputToMachineList(tTileEntity, 62))) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (((tBlock != ModBlocks.blockCasingsMisc) || (tMeta != 5))) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } @Override - public int getMaxEfficiency(final ItemStack aStack) { + public int getMaxEfficiency(ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 5], new GT_RenderedTexture(aActive - ? Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE : Textures.BlockIcons.STEAM_TURBINE_SIDE) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 5] - }; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); + public int getAmountOfOutputs() { + return 1; } @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java index 787aa61856..68b2f647ee 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialMacerator.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.*; - import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -17,52 +15,182 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -public class GregtechMetaTileEntity_IndustrialMacerator extends GregtechMeta_MultiBlockBase { +public class GregtechMetaTileEntity_IndustrialMacerator +extends GregtechMeta_MultiBlockBase { private static boolean controller; - public GregtechMetaTileEntity_IndustrialMacerator(final int aID, final String aName, final String aNameRegional) { + public GregtechMetaTileEntity_IndustrialMacerator(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialMacerator(final String aName) { + public GregtechMetaTileEntity_IndustrialMacerator(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Maceration Stack", + "Size[WxHxL]: 3x6x3 (Hollow)", + "Controller (Center Bottom)", + "1x Input Bus (Any bottom layer casing)", + "5x Output Bus (Any casing besides bottom layer)", + "1x Maintenance Hatch (Any casing)", + "1x Energy Hatch (Any casing)", + "Maceration Stack Casings for the rest (26 at least!)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_MatterFab_Active : TexturesGtBlock.Overlay_MatterFab)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[64]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MacerationStack.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + } + + /*@Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + }*/ + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, aBaseMetaTileEntity.getYCoord() + 0.3f + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 1.2F - tRandom.nextFloat() * 1.6F, 0.0D, 0.0D, 0.0D); + } + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(201)), 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public void startProcess() { + sendLoopStart((byte) 1); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + + //Get inputs. + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + + //Temp var + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + //Don't check the recipe if someone got around the output bus size check. + if (this.mOutputBusses.size() != 5){ + return false; + } + + //Make a recipe instance for the rest of the method. + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); + + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, null, tInputs))) { + Utils.LOG_WARNING("Valid Recipe found - size "+tRecipe.mOutputs.length); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + + this.mEUt = (-tRecipe.mEUt); + this.mMaxProgresstime = Math.max(1, (tRecipe.mDuration/5)); + ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; + for (int i = 0; i < tRecipe.mOutputs.length; i++){ + if (i==0) { + Utils.LOG_WARNING("Adding the default output"); + outputs[0] = tRecipe.getOutput(i); + } + else if (getBaseMetaTileEntity().getRandomNumber(7500) < tRecipe.getOutputChance(i)){ + Utils.LOG_WARNING("Adding a bonus output"); + outputs[i] = tRecipe.getOutput(i); + } + else { + Utils.LOG_WARNING("Adding null output"); + outputs[i] = null; + } + } + + this.mOutputItems = outputs; + sendLoopStart((byte) 20); + updateSlots(); + return true; + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; if (!aBaseMetaTileEntity.getAirOffset(xDir, 1, zDir)) { return false; } int tAmount = 0; - GregtechMetaTileEntity_IndustrialMacerator.controller = false; + controller = false; for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { for (int h = 0; h < 6; h++) { - if (!(i == 0 && j == 0 && h > 0 && h < 5))// ((h > - // 0)&&(h<5)) || - // (((xDir + i - // != 0) || - // (zDir + j != - // 0)) && ((i != - // 0) || (j != - // 0))) + if (!(i == 0 && j == 0 && (h > 0 && h < 5)))//((h > 0)&&(h<5)) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0))) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 64) - && !this.addInputToMachineList(tTileEntity, 64) - && !this.addOutputToMachineList(tTileEntity, 64) - && !this.addEnergyInputToMachineList(tTileEntity, 64) - && !this.ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 64)) && (!addInputToMachineList(tTileEntity, 64)) && (!addOutputToMachineList(tTileEntity, 64)) && (!addEnergyInputToMachineList(tTileEntity, 64)) && (!ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { Utils.LOG_INFO("Returned False 1"); return false; } @@ -80,18 +208,17 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends GregtechMeta_Mul Utils.LOG_INFO("Returned False 3"); return false; } - final int height = this.getBaseMetaTileEntity().getYCoord(); + int height = this.getBaseMetaTileEntity().getYCoord(); if (this.mInputBusses.get(0).getBaseMetaTileEntity().getYCoord() != height) { - Utils.LOG_INFO("height: " + height + " | Returned False 4"); + Utils.LOG_INFO("height: "+height+" | Returned False 4"); return false; } - final GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; + GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; for (int i = 0; i < this.mOutputBusses.size(); i++) { - final int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; + int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; if (tmpHatches[hatchNumber] == null) { tmpHatches[hatchNumber] = this.mOutputBusses.get(i); - } - else { + } else { Utils.LOG_INFO("Returned False 5"); return false; } @@ -103,181 +230,35 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends GregtechMeta_Mul return tAmount >= 26; } - @Override - public boolean checkRecipe(final ItemStack aStack) { - - // Get inputs. - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - - // Temp var - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - // Don't check the recipe if someone got around the output bus size - // check. - if (this.mOutputBusses.size() != 5) { - return false; - } - - // Make a recipe instance for the rest of the method. - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe(this.getBaseMetaTileEntity(), - false, 9223372036854775807L, null, tInputs); - - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); - - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - if (tRecipe != null && tRecipe.isRecipeInputEqual(true, null, tInputs)) { - Utils.LOG_WARNING("Valid Recipe found - size " + tRecipe.mOutputs.length); - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - - this.mEUt = -tRecipe.mEUt; - this.mMaxProgresstime = Math.max(1, tRecipe.mDuration / 5); - final ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; - for (int i = 0; i < tRecipe.mOutputs.length; i++) { - if (i == 0) { - Utils.LOG_WARNING("Adding the default output"); - outputs[0] = tRecipe.getOutput(i); - } - else if (this.getBaseMetaTileEntity().getRandomNumber(7500) < tRecipe.getOutputChance(i)) { - Utils.LOG_WARNING("Adding a bonus output"); - outputs[i] = tRecipe.getOutput(i); - } - else { - Utils.LOG_WARNING("Adding null output"); - outputs[i] = null; - } - } - - this.mOutputItems = outputs; - this.sendLoopStart((byte) 20); - this.updateSlots(); - return true; - } + public boolean ignoreController(Block tTileEntity) { + if (!controller && tTileEntity == GregTech_API.sBlockMachines) { + return true; } return false; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 16; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MacerationStack.png"); - } - - /* - * @Override public boolean isCorrectMachinePart(ItemStack aStack) { return - * true; } - */ - - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Maceration Stack", "Size[WxHxL]: 3x6x3 (Hollow)", - "Controller (Center Bottom)", "1x Input Bus (Any bottom layer casing)", - "5x Output Bus (Any casing besides bottom layer)", "1x Maintenance Hatch (Any casing)", - "1x Energy Hatch (Any casing)", "Maceration Stack Casings for the rest (26 at least!)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { + public int getMaxEfficiency(ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; + public int getAmountOfOutputs() { + return 16; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[64], new GT_RenderedTexture( - aActive ? TexturesGtBlock.Overlay_MatterFab_Active : TexturesGtBlock.Overlay_MatterFab) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[64] - }; - } - - public boolean ignoreController(final Block tTileEntity) { - if (!GregtechMetaTileEntity_IndustrialMacerator.controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; - } + public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override public boolean isOverclockerUpgradable() { return true; } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialMacerator(this.mName); - } - - @Override - public void onPreTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive() - && aBaseMetaTileEntity.getFrontFacing() != 1 && aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide((byte) 1)) { - final Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", - aBaseMetaTileEntity.getXCoord() + 0.8F - tRandom.nextFloat() * 0.6F, - aBaseMetaTileEntity.getYCoord() + 0.3f + tRandom.nextFloat() * 0.2F, - aBaseMetaTileEntity.getZCoord() + 1.2F - tRandom.nextFloat() * 1.6F, 0.0D, 0.0D, 0.0D); - } - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(201)), 10, 1.0F, aX, aY, aZ); - } - } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java index ee15dcd83c..96095698fa 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialPlatePress.java @@ -1,8 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - +import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -16,200 +14,186 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_IndustrialPlatePress extends GregtechMeta_MultiBlockBase { - public GregtechMetaTileEntity_IndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { +public class GregtechMetaTileEntity_IndustrialPlatePress +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialPlatePress(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialPlatePress(final String aName) { + public GregtechMetaTileEntity_IndustrialPlatePress(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 2; h++) { - if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 61) - && !this.addMufflerToMachineList(tTileEntity, 61) - && !this.addInputToMachineList(tTileEntity, 61) - && !this.addOutputToMachineList(tTileEntity, 61) - && !this.addEnergyInputToMachineList(tTileEntity, 61)) { - final Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - final byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (tBlock != ModBlocks.blockCasingsMisc || tMeta != 4) { - return false; - } - tAmount++; - } - } - } - } - } - return tAmount >= 16; + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); } @Override - public boolean checkRecipe(final ItemStack aStack) { // TODO - Add Check to - // make sure Fluid - // output isn't full - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (int i = 0; i < tInputList.size() - 1; i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } - else { - tInputList.remove(i--); - break; - } - } - } - } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); - } - else { - tFluidList.remove(i--); - break; - } - } - } - } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); - - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBenderRecipes.findRecipe(this.getBaseMetaTileEntity(), - false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); - if (tRecipe != null && 2500 >= tRecipe.mSpecialValue - && tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - } - else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - tRecipe.getOutput(0), tRecipe.getOutput(1) - }; - this.updateSlots(); - return true; - } - } - return false; + public String[] getDescription() { + return new String[]{"Controller Block for the Material Press", + "Size: 3x3x3 (Hollow)", + "Controller (front centered)", + "1x Input Bus (anywhere)", + "1x Output Bus (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "1x Muffler (anywhere)", + "Material Press Machine Casings for the rest (16 at least!)", + CORE.GT_Tooltip}; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4]}; } @Override - public int getAmountOfOutputs() { - return 1; + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MaterialPress.png"); } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MaterialPress.png"); + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBenderRecipes; } @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Material Press", "Size: 3x3x3 (Hollow)", "Controller (front centered)", - "1x Input Bus (anywhere)", "1x Output Bus (anywhere)", "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", "1x Muffler (anywhere)", - "Material Press Machine Casings for the rest (16 at least!)", CORE.GT_Tooltip - }; + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; } - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } + @Override + public boolean checkRecipe(ItemStack aStack) { //TODO - Add Check to make sure Fluid output isn't full + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (int i = 0; i < tInputList.size() - 1; i++) { + for (int j = i + 1; j < tInputList.size(); j++) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + tInputList.remove(j--); + } else { + tInputList.remove(i--); + break; + } + } + } + } + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + for (int i = 0; i < tFluidList.size() - 1; i++) { + for (int j = i + 1; j < tFluidList.size(); j++) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + tFluidList.remove(j--); + } else { + tFluidList.remove(i--); + break; + } + } + } + } + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sBenderRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + if ((tRecipe != null) && (2500 >= tRecipe.mSpecialValue) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; + updateSlots(); + return true; + } + } + return false; + } @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); + } + } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBenderRecipes; - } + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + return false; + } + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 61)) && (!addMufflerToMachineList(tTileEntity, 61)) && (!addInputToMachineList(tTileEntity, 61)) && (!addOutputToMachineList(tTileEntity, 61)) && (!addEnergyInputToMachineList(tTileEntity, 61))) { + Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + if (((tBlock != ModBlocks.blockCasingsMisc) || (tMeta != 4))) { + return false; + } + tAmount++; + } + } + } + } + } + return tAmount >= 16; + } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 4], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[GregtechMetaCasingBlocks.GTID + 4] - }; + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; + public int getPollutionPerTick(ItemStack aStack) { + return 0; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); + public int getAmountOfOutputs() { + return 1; } @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java index dadb82388d..ee49b7fcb9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialSinter.java @@ -1,12 +1,12 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -14,116 +14,167 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; + +import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_MultiBlockBase { +public class GregtechMetaTileEntity_IndustrialSinter +extends GT_MetaTileEntity_MultiBlockBase { + RenderBlocks asdasd = RenderBlocks.getInstance(); - - public GregtechMetaTileEntity_IndustrialSinter(final int aID, final String aName, final String aNameRegional) { + + public GregtechMetaTileEntity_IndustrialSinter(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialSinter(final String aName) { + public GregtechMetaTileEntity_IndustrialSinter(String aName) { super(aName); } - private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { - return this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()); + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialSinter(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Sinter Furnace", + "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", + "2x Input Bus (side centered)", + "2x Output Bus (side centered)", + "1x Energy Hatch (top or bottom centered)", + "1x Maintenance Hatch (back centered)", + "Sinter Furnace Casings for the rest (32 at least!)", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "WireFactory.png"); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; } - private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { - return this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()); + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + updateSlots(); + return true; + } + } + } + return false; } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int controllerX = aBaseMetaTileEntity.getXCoord(); - final int controllerY = aBaseMetaTileEntity.getYCoord(); - final int controllerZ = aBaseMetaTileEntity.getZCoord(); + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int controllerX = aBaseMetaTileEntity.getXCoord(); + int controllerY = aBaseMetaTileEntity.getYCoord(); + int controllerZ = aBaseMetaTileEntity.getZCoord(); - final byte tSide = this.getBaseMetaTileEntity().getBackFacing(); - if (this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 1) - && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 2) - && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), - 3)) { + byte tSide = getBaseMetaTileEntity().getBackFacing(); + if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { int tAirCount = 0; for (byte i = -1; i < 2; i = (byte) (i + 1)) { for (byte j = -1; j < 2; j = (byte) (j + 1)) { for (byte k = -1; k < 2; k = (byte) (k + 1)) { - if (this.getBaseMetaTileEntity().getAirOffset(i, j, k)) { - Utils.LOG_INFO("Found Air at: " + (controllerX + i) + " " + (controllerY + k) + " " - + (controllerZ + k)); - // if (aBaseMetaTileEntity.getWorld().isRemote){ - // asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, - // (controllerX+i), (controllerY+k), - // (controllerZ+k)); - // UtilsRendering.drawBlockInWorld((controllerX+i), - // (controllerY+k), (controllerZ+k), - // Color.YELLOW_GREEN); - // } + if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { + Utils.LOG_INFO("Found Air at: "+(controllerX+i)+" "+(controllerY+k)+" "+(controllerZ+k)); + //if (aBaseMetaTileEntity.getWorld().isRemote){ + //asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, (controllerX+i), (controllerY+k), (controllerZ+k)); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.YELLOW_GREEN); + //} tAirCount++; } } } } if (tAirCount != 10) { - Utils.LOG_INFO("False. Air != 10. Air == " + tAirCount); - // return false; + Utils.LOG_INFO("False. Air != 10. Air == "+tAirCount); + //return false; } for (byte i = 2; i < 6; i = (byte) (i + 1)) { - // UtilsRendering.drawBlockInWorld((controllerX+i), - // (controllerY), (controllerZ), Color.LIME_GREEN); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ), Color.LIME_GREEN); IGregTechTileEntity tTileEntity; - if (null != (tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2)) - && tTileEntity.getFrontFacing() == this.getBaseMetaTileEntity().getFrontFacing() - && tTileEntity.getMetaTileEntity() != null - && tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialSinter) { - // Utils.LOG_INFO("False 1"); + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialSinter))) { + //Utils.LOG_INFO("False 1"); return false; } } - final int tX = this.getBaseMetaTileEntity().getXCoord(); - final int tY = this.getBaseMetaTileEntity().getYCoord(); - final int tZ = this.getBaseMetaTileEntity().getZCoord(); + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); for (byte i = -1; i < 2; i = (byte) (i + 1)) { for (byte j = -1; j < 2; j = (byte) (j + 1)) { - if (i != 0 || j != 0) { + if ((i != 0) || (j != 0)) { for (byte k = 0; k < 5; k = (byte) (k + 1)) { - // UtilsRendering.drawBlockInWorld((controllerX+i), - // (controllerY+k), (controllerZ+k), Color.ORANGE); - if ((i == 0 || j == 0) && (k == 1 || k == 2 || k == 3)) { - // UtilsRendering.drawBlockInWorld((controllerX+i), - // (controllerY+k), (controllerZ+k), - // Color.TOMATO); - if (this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock() - && this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k - : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta()) { - } - else if (!this.addToMachineList(this.getBaseMetaTileEntity().getIGregTechTileEntity( - tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) - && !this.addEnergyInputToMachineList(this.getBaseMetaTileEntity() - .getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)))) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.ORANGE); + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.TOMATO); + if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } + else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { Utils.LOG_INFO("False 2"); return false; } - } - else if (this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock() - && this.getBaseMetaTileEntity().getMetaID( - tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta()) { - } + } + else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } else { Utils.LOG_INFO("False 3"); return false; @@ -139,17 +190,14 @@ public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_M if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { Utils.LOG_INFO("Incorrect amount of Input & Output busses."); return false; - } + } this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity() - .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if (tTileEntity != null && tTileEntity.getMetaTileEntity() != null) { - if (tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance) { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this - .getCasingTextureIndex(); - } - else { + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); return false; } @@ -158,8 +206,7 @@ public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_M Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); return false; } - } - else { + } else { Utils.LOG_INFO("False 5"); return false; } @@ -168,52 +215,18 @@ public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_M } @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (final ItemStack tInput : tInputList) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(this.getBaseMetaTileEntity(), - false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[] { - tInput - }); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[] { - tInput - })) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - } - else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - tRecipe.getOutput(0) - }; - this.updateSlots(); - return true; - } - } - } - return false; + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; + public int getDamageToComponent(ItemStack aStack) { + return 0; } @Override @@ -221,81 +234,30 @@ public class GregtechMetaTileEntity_IndustrialSinter extends GT_MetaTileEntity_M return 1; } + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } + public byte getCasingMeta() { return 6; } + public byte getCasingTextureIndex() { return 63; } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "WireFactory.png"); - } - - @Override - public int getDamageToComponent(final ItemStack aStack) { - return 0; - } - - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Sinter Furnace", "Size: 3x5x3 [WxLxH] (Hollow)", - "Controller (front centered)", "2x Input Bus (side centered)", "2x Output Bus (side centered)", - "1x Energy Hatch (top or bottom centered)", "1x Maintenance Hatch (back centered)", - "Sinter Furnace Casings for the rest (32 at least!)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); } - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[63], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[63] - }; - } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialSinter(this.mName); + private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { + return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java index f9a633bff5..ca300ba277 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialWireMill.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -16,42 +14,117 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; + +import java.util.ArrayList; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_MultiBlockBase { - public GregtechMetaTileEntity_IndustrialWireMill(final int aID, final String aName, final String aNameRegional) { +public class GregtechMetaTileEntity_IndustrialWireMill +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialWireMill(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialWireMill(final String aName) { + public GregtechMetaTileEntity_IndustrialWireMill(String aName) { super(aName); } - private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { - return this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()); + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Industrial Wire Factory", + "Size: 3x5x3 [WxLxH] (Hollow)", "Controller (front centered)", + "2x Input Bus (side centered)", + "2x Output Bus (side centered)", + "1x Energy Hatch (top or bottom centered)", + "1x Maintenance Hatch (back centered)", + "Wire Factory Casings for the rest (32 at least!)", + CORE.GT_Tooltip + }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[63]}; } - private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { - return this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex()) - || this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()); + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "WireFactory.png"); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final byte tSide = this.getBaseMetaTileEntity().getBackFacing(); - if (this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 1) - && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 2) - && this.getBaseMetaTileEntity().getAirAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), - 3)) { + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + ArrayList<ItemStack> tInputList = getStoredInputs(); + for (ItemStack tInput : tInputList) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); + if (tRecipe != null) { + + int tValidOutputSlots = this.getValidOutputSlots(getRecipeMap(), new ItemStack[]{tInput}); + Utils.LOG_WARNING("Valid Output Slots: "+tValidOutputSlots); + //More than or one input + if (tInputList.size() > 0 && tValidOutputSlots >= 1) { + + if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + if (tRecipe.mEUt <= 16) { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); + } else { + this.mEUt = tRecipe.mEUt; + this.mMaxProgresstime = tRecipe.mDuration; + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; + updateSlots(); + return true; + } + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + byte tSide = getBaseMetaTileEntity().getBackFacing(); + if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { int tAirCount = 0; for (byte i = -1; i < 2; i = (byte) (i + 1)) { for (byte j = -1; j < 2; j = (byte) (j + 1)) { for (byte k = -1; k < 2; k = (byte) (k + 1)) { - if (this.getBaseMetaTileEntity().getAirOffset(i, j, k)) { + if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { tAirCount++; } } @@ -63,44 +136,30 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult } for (byte i = 2; i < 6; i = (byte) (i + 1)) { IGregTechTileEntity tTileEntity; - if (null != (tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2)) - && tTileEntity.getFrontFacing() == this.getBaseMetaTileEntity().getFrontFacing() - && tTileEntity.getMetaTileEntity() != null - && tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialWireMill) { - // Utils.LOG_INFO("False 1"); + if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && + (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && + ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialWireMill))) { + //Utils.LOG_INFO("False 1"); return false; } } - final int tX = this.getBaseMetaTileEntity().getXCoord(); - final int tY = this.getBaseMetaTileEntity().getYCoord(); - final int tZ = this.getBaseMetaTileEntity().getZCoord(); + int tX = getBaseMetaTileEntity().getXCoord(); + int tY = getBaseMetaTileEntity().getYCoord(); + int tZ = getBaseMetaTileEntity().getZCoord(); for (byte i = -1; i < 2; i = (byte) (i + 1)) { for (byte j = -1; j < 2; j = (byte) (j + 1)) { - if (i != 0 || j != 0) { + if ((i != 0) || (j != 0)) { for (byte k = 0; k < 5; k = (byte) (k + 1)) { - if ((i == 0 || j == 0) && (k == 1 || k == 2 || k == 3)) { - if (this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock() - && this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k - : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta()) { - } - else if (!this.addToMachineList(this.getBaseMetaTileEntity().getIGregTechTileEntity( - tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) - && !this.addEnergyInputToMachineList(this.getBaseMetaTileEntity() - .getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)))) { + if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { + if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } + else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { Utils.LOG_INFO("False 2"); return false; } - } - else if (this.getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), - tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingBlock() - && this.getBaseMetaTileEntity().getMetaID( - tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, - tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == this.getCasingMeta()) { - } + } + else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { + } else { Utils.LOG_INFO("False 3"); return false; @@ -116,17 +175,14 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { Utils.LOG_INFO("Incorrect amount of Input & Output busses."); return false; - } + } this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity() - .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if (tTileEntity != null && tTileEntity.getMetaTileEntity() != null) { - if (tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance) { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); + if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { + if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this - .getCasingTextureIndex(); - } - else { + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); + } else { Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); return false; } @@ -135,8 +191,7 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); return false; } - } - else { + } else { Utils.LOG_INFO("False 5"); return false; } @@ -145,61 +200,13 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult } @Override - public boolean checkRecipe(final ItemStack aStack) { - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); - for (final ItemStack tInput : tInputList) { - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - final GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(this.getBaseMetaTileEntity(), - false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[] { - tInput - }); - if (tRecipe != null) { - - final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), new ItemStack[] { - tInput - }); - Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); - // More than or one input - if (tInputList.size() > 0 && tValidOutputSlots >= 1) { - - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[] { - tInput - })) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - } - else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - tRecipe.getOutput(0) - }; - this.updateSlots(); - return true; - } - } - } - } - return false; + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; + public int getPollutionPerTick(ItemStack aStack) { + return 0; } @Override @@ -207,71 +214,30 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_Mult return 1; } + @Override + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; + } + public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } + public byte getCasingMeta() { return 6; } + public byte getCasingTextureIndex() { return 63; } - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "WireFactory.png"); + private boolean addToMachineList(IGregTechTileEntity tTileEntity) { + return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); } - - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Industrial Wire Factory", "Size: 3x5x3 [WxLxH] (Hollow)", - "Controller (front centered)", "2x Input Bus (side centered)", "2x Output Bus (side centered)", - "1x Energy Hatch (top or bottom centered)", "1x Maintenance Hatch (back centered)", - "Wire Factory Casings for the rest (32 at least!)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[63], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[63] - }; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); + + private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { + return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java index 1ae8e60885..aa7aecc8c5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IronBlastFurnace.java @@ -23,460 +23,358 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class GregtechMetaTileEntity_IronBlastFurnace extends MetaTileEntity { - private static final ITexture[] FACING_SIDE = { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) - }; - private static final ITexture[] FACING_FRONT = { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) - }; - private static final ITexture[] FACING_ACTIVE = { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) - }; - public int mMaxProgresstime = 0; - public int mUpdate = 30; - public int mProgresstime = 0; - public boolean mMachine = false; - public ItemStack mOutputItem1; - public ItemStack mOutputItem2; - - public GregtechMetaTileEntity_IronBlastFurnace(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 4); - } - - public GregtechMetaTileEntity_IronBlastFurnace(final String aName) { - super(aName, 4); - } - - private void addOutputProducts() { - if (this.mOutputItem1 != null) { - if (this.mInventory[2] == null) { - this.mInventory[2] = GT_Utility.copy(new Object[] { - this.mOutputItem1 - }); - } - else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { - this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), - this.mOutputItem1.stackSize + this.mInventory[2].stackSize); - } - } - if (this.mOutputItem2 != null) { - if (this.mInventory[3] == null) { - this.mInventory[3] = GT_Utility.copy(new Object[] { - this.mOutputItem2 - }); - } - else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { - this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), - this.mOutputItem2.stackSize + this.mInventory[3].stackSize); - } - } - } - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { - return GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover() - && super.allowCoverOnSide(aSide, aCoverID); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - return aIndex > 1; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, - final ItemStack aStack) { - if (aIndex < 2) { - } - return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); - } - - private boolean checkMachine() { - final int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 4; j++) { // This is height - for (int k = -1; k < 2; k++) { - if (xDir + i != 0 || j != 0 || zDir + k != 0) { - if (i != 0 || j == -1 || k != 0) { - if (this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, - zDir + k) != ModBlocks.blockCasingsMisc - || this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10) { - return false; - } - } - else if (!GT_Utility.arrayContains( - this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[] { - Blocks.lava, Blocks.flowing_lava, null - }) && !this.getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k)) { - return false; - } - } - } - } - } - return true; - } - - private boolean checkRecipe() { - if (!this.mMachine) { - return false; - } - if (this.mInventory[0] != null && this.mInventory[1] != null && this.mInventory[0].stackSize >= 1) { - if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron") - || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron")) { - if (this.mInventory[1].getItem() == Items.coal && this.mInventory[1].stackSize >= 4 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = 36000; - return true; - } - if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke") - && this.mInventory[1].stackSize >= 2 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = 4800 * 5; - return true; - } - if (this.mInventory[0].stackSize >= 9 - && (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal") - || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal")) - && this.mInventory[1].stackSize >= 4 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 9); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = 64800 * 5; - return true; - } - } - else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { - if (this.mInventory[1].getItem() == Items.coal && this.mInventory[1].stackSize >= 2 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, - 2L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = 3600 * 5; - return true; - } - if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke") - && this.mInventory[1].stackSize >= 1 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, - 2L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 1 * 3); - this.mMaxProgresstime = 2400 * 5; - return true; - } - if (this.mInventory[0].stackSize >= 9 - && (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal") - || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal")) - && this.mInventory[1].stackSize >= 2 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, - 2L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 9); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = 32400 * 5; - return true; - } - } - else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { - if (this.mInventory[1].getItem() == Items.coal && this.mInventory[1].stackSize >= 36 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 64); - this.mMaxProgresstime = 64800 * 9; - return true; - } - if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke") - && this.mInventory[1].stackSize >= 18 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 18 * 3); - this.mMaxProgresstime = 43200 * 5; - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal") - || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal")) - && this.mInventory[1].stackSize >= 4 - && this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, - 4L))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = 64800 * 5; - return true; - } - } - } - this.mOutputItem1 = null; - this.mOutputItem2 = null; - return false; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override +public class GregtechMetaTileEntity_IronBlastFurnace + extends MetaTileEntity { + private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top)}; + private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off)}; + private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On)}; + public int mMaxProgresstime = 0; + public int mUpdate = 30; + public int mProgresstime = 0; + public boolean mMachine = false; + public ItemStack mOutputItem1; + public ItemStack mOutputItem2; + + public GregtechMetaTileEntity_IronBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 4); + } + + public GregtechMetaTileEntity_IronBlastFurnace(String aName) { + super(aName, 4); + } + + @Override public String[] getDescription() { - return new String[] { - "Sloooowly, Skip the Bronze age, Get some Steel!", "Multiblock: 3x3x5 hollow with opening on top", - "40 Iron Plated Bricks required", "----", "Even though Iron melts hotter than bronze,", - "this machine is to help players skip looking", "for tin and copper, which are not as common", - "as Iron is. This machine takes 5x longer than the bronze", "blast furnace as a result.", "----", - CORE.GT_Tooltip - }; - } - - @Override - public int getProgresstime() { - return this.mProgresstime; - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return aActive ? GregtechMetaTileEntity_IronBlastFurnace.FACING_ACTIVE - : GregtechMetaTileEntity_IronBlastFurnace.FACING_FRONT; - } - return GregtechMetaTileEntity_IronBlastFurnace.FACING_SIDE; - } - - @Override - public byte getTileEntityBaseType() { - return 0; - } - - @Override - public int increaseProgress(final int aProgress) { - this.mProgresstime += aProgress; - return this.mMaxProgresstime - this.mProgresstime; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } + return new String[]{"Sloooowly, Skip the Bronze age, Get some Steel!", + "Multiblock: 3x3x5 hollow with opening on top", + "40 Iron Plated Bricks required", + "----", + "Even though Iron melts hotter than bronze,", + "this machine is to help players skip looking", + "for tin and copper, which are not as common", + "as Iron is. This machine takes 5x longer than the bronze", + "blast furnace as a result.", + "----", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return aActive ? FACING_ACTIVE : FACING_FRONT; + } + return FACING_SIDE; + } + + @Override + public boolean isSteampowered() { + return false; + } - @Override + @Override public boolean isElectric() { - return false; - } + return false; + } - @Override + @Override + public boolean isPneumatic() { + return false; + } + + @Override public boolean isEnetInput() { - return false; - } + return false; + } - @Override + @Override public boolean isEnetOutput() { - return false; - } + return false; + } - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } + @Override + public boolean isInputFacing(byte aSide) { + return false; + } - @Override - public boolean isGivingInformation() { - return false; - } + @Override + public boolean isOutputFacing(byte aSide) { + return false; + } - @Override - public boolean isInputFacing(final byte aSide) { - return false; - } + @Override + public boolean isTeleporterCompatible() { + return false; + } - @Override - public boolean isOutputFacing(final byte aSide) { - return false; - } + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } - @Override - public boolean isPneumatic() { - return false; - } + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } - @Override - public boolean isSteampowered() { - return false; - } + @Override + public int getProgresstime() { + return this.mProgresstime; + } - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mUpdate = 30; - this.mProgresstime = aNBT.getInteger("mProgresstime"); - this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); - this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); - } - - @Override + @Override public int maxProgresstime() { - return this.mMaxProgresstime; - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); - } - - @Override + return this.mMaxProgresstime; + } + + @Override + public int increaseProgress(int aProgress) { + this.mProgresstime += aProgress; + return this.mMaxProgresstime - this.mProgresstime; + } + + @Override + public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { + return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mProgresstime", this.mProgresstime); + aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); + if (this.mOutputItem1 != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem1.writeToNBT(tNBT); + aNBT.setTag("mOutputItem1", tNBT); + } + if (this.mOutputItem2 != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + this.mOutputItem2.writeToNBT(tNBT); + aNBT.setTag("mOutputItem2", tNBT); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mUpdate = 30; + this.mProgresstime = aNBT.getInteger("mProgresstime"); + this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); + this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_IronBlastFurnace(aPlayerInventory, aBaseMetaTileEntity); + } + + private boolean checkMachine() { + int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 4; j++) { //This is height + for (int k = -1; k < 2; k++) { + if ((xDir + i != 0) || (j != 0) || (zDir + k != 0)) { + if ((i != 0) || (j == -1) || (k != 0)) { + if ((getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) != ModBlocks.blockCasingsMisc) || (getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) { + return false; + } + } else if ((!GT_Utility.arrayContains(getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), new Object[]{Blocks.lava, Blocks.flowing_lava, null})) && (!getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { + return false; + } + } + } + } + } + return true; + } + + @Override public void onMachineBlockUpdate() { - this.mUpdate = 30; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { - if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { - aBaseMetaTileEntity.getWorld().spawnParticle("cloud", - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), - aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, - 0.0D); - } - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate-- == 0) { - this.mMachine = this.checkMachine(); - } - if (this.mMachine) { - if (this.mMaxProgresstime > 0) { - if (++this.mProgresstime >= this.mMaxProgresstime) { - this.addOutputProducts(); - this.mOutputItem1 = null; - this.mOutputItem2 = null; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - try { - // GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), - // "steel"); - } - catch (final Exception e) { - } - } - } - else if (aBaseMetaTileEntity.isAllowedToWork()) { - this.checkRecipe(); - } - } - aBaseMetaTileEntity.setActive(this.mMaxProgresstime > 0 && this.mMachine); - if (aBaseMetaTileEntity.isActive()) { - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord() + 1, - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord() + 1, - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); - this.mUpdate = 1; - } - } - else { - if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord() + 1, - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord() + 1, - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); - this.mUpdate = 1; - } - } - } - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mProgresstime", this.mProgresstime); - aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); - if (this.mOutputItem1 != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem1.writeToNBT(tNBT); - aNBT.setTag("mOutputItem1", tNBT); - } - if (this.mOutputItem2 != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem2.writeToNBT(tNBT); - aNBT.setTag("mOutputItem2", tNBT); - } - } - - private boolean spaceForOutput(final ItemStack aStack1, final ItemStack aStack2) { - if ((this.mInventory[2] == null || aStack1 == null - || this.mInventory[2].stackSize + aStack1.stackSize <= this.mInventory[2].getMaxStackSize() - && GT_Utility.areStacksEqual(this.mInventory[2], aStack1)) - && (this.mInventory[3] == null || aStack2 == null - || this.mInventory[3].stackSize + aStack2.stackSize <= this.mInventory[3].getMaxStackSize() - && GT_Utility.areStacksEqual(this.mInventory[3], aStack2))) { - return true; - } - return false; - } + this.mUpdate = 30; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if ((aBaseMetaTileEntity.isClientSide()) && + (aBaseMetaTileEntity.isActive())) { + aBaseMetaTileEntity.getWorld().spawnParticle("cloud", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, 0.0D); + } + if (aBaseMetaTileEntity.isServerSide()) { + if (this.mUpdate-- == 0) { + this.mMachine = checkMachine(); + } + if (this.mMachine) { + if (this.mMaxProgresstime > 0) { + if (++this.mProgresstime >= this.mMaxProgresstime) { + addOutputProducts(); + this.mOutputItem1 = null; + this.mOutputItem2 = null; + this.mProgresstime = 0; + this.mMaxProgresstime = 0; + try { + // GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel"); + } catch (Exception e) { + } + } + } else if (aBaseMetaTileEntity.isAllowedToWork()) { + checkRecipe(); + } + } + aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); + if (aBaseMetaTileEntity.isActive()) { + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); + this.mUpdate = 1; + } + } else { + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); + this.mUpdate = 1; + } + if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { + aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); + this.mUpdate = 1; + } + } + } + } + + private void addOutputProducts() { + if (this.mOutputItem1 != null) { + if (this.mInventory[2] == null) { + this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1}); + } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { + this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize); + } + } + if (this.mOutputItem2 != null) { + if (this.mInventory[3] == null) { + this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2}); + } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { + this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize); + } + } + } + + private boolean spaceForOutput(ItemStack aStack1, ItemStack aStack2) { + if (((this.mInventory[2] == null) || (aStack1 == null) || ((this.mInventory[2].stackSize + aStack1.stackSize <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && ( + (this.mInventory[3] == null) || (aStack2 == null) || ((this.mInventory[3].stackSize + aStack2.stackSize <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { + return true; + } + return false; + } + + private boolean checkRecipe() { + if (!this.mMachine) { + return false; + } + if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = 36000; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = 4800*5; + return true; + } + if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 9); + getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = 64800*5; + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = 3600*5; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 1*3); + this.mMaxProgresstime = 2400*5; + return true; + } + if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { + getBaseMetaTileEntity().decrStackSize(0, 9); + getBaseMetaTileEntity().decrStackSize(1, 2*3); + this.mMaxProgresstime = 32400*5; + return true; + } + } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { + if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 64); + this.mMaxProgresstime = 64800*9; + return true; + } + if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 18*3); + this.mMaxProgresstime = 43200*5; + return true; + } + if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { + getBaseMetaTileEntity().decrStackSize(0, 1); + getBaseMetaTileEntity().decrStackSize(1, 4*3); + this.mMaxProgresstime = 64800*5; + return true; + } + } + } + this.mOutputItem1 = null; + this.mOutputItem2 = null; + return false; + } + + @Override + public boolean isGivingInformation() { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex > 1; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (aIndex < 2) { + } + return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); + } + + @Override + public byte getTileEntityBaseType() { + return 0; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java index 15a5224791..cb2996ca97 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java @@ -1,17 +1,17 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - -import org.apache.commons.lang3.ArrayUtils; - -import gregtech.api.enums.*; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.*; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -20,220 +20,125 @@ import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MatterFab; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.apache.commons.lang3.ArrayUtils; + public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlockBase { - public static int sUUAperUUM = 1; - public static int sUUASpeedBonus = 4; - public static int sDurationMultiplier = 3215; - public static boolean sRequiresUUA = false; - private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); - private int mAmplifierUsed = 0; - private int mMatterProduced = 0; - ItemStack scrapPile = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + public static int sUUAperUUM = 1; + public static int sUUASpeedBonus = 4; + public static int sDurationMultiplier = 3215; + public static boolean sRequiresUUA = false; + private int mAmplifierUsed = 0; + private int mMatterProduced = 0; + ItemStack scrapPile = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + ItemStack scrapBox = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + + private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); + FluidStack tempFake = FluidUtils.getFluidStack("uuamplifier", 1); + GT_Recipe fakeRecipe; + + public int getAmplifierUsed(){ + return mAmplifierUsed; + } - ItemStack scrapBox = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); - FluidStack tempFake = FluidUtils.getFluidStack("uuamplifier", 1); - GT_Recipe fakeRecipe; + public int getMatterProduced(){ + return mMatterProduced; + } - public GregtechMetaTileEntity_MassFabricator(final int aID, final String aName, final String aNameRegional) { + public GregtechMetaTileEntity_MassFabricator(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_MassFabricator(final String aName) { + public GregtechMetaTileEntity_MassFabricator(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - for (int i = -2; i < 3; i++) { - for (int j = -2; j < 3; j++) { - for (int h = 0; h < 4; h++) { - - // Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" - // zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); - - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - h, zDir + j); - /* - * if (tTileEntity != - * Block.getBlockFromItem(UtilsItems.getItem( - * "IC2:blockAlloyGlass"))) { Utils.LOG_INFO("h:"+h+" i:"+i+ - * " j:"+j); double tX = tTileEntity.getXCoord(); double tY - * = tTileEntity.getYCoord(); double tZ = - * tTileEntity.getZCoord(); Utils.LOG_INFO( - * "Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); //return - * false; } - */ - if (i != -2 && i != 2 && j != -2 && j != 2) {// innerer 3x3 - // ohne h�he - if (h == 0) {// innen boden (kantal coils) - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); - return false; - } - } - else if (h == 3) {// innen decke (ulv casings + input + - // muffler) - if (!this.addMufflerToMachineList(tTileEntity, 66)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - } - } - else {// innen air - if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { - Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); - return false; - } - } - } - else {// Outer 5x5 - if (h == 0) {// au�en boden (controller, output, energy, - // maintainance, rest ulv casings) - if (!this.addMaintenanceToMachineList(tTileEntity, 66) - && !this.addInputToMachineList(tTileEntity, 66) - && !this.addOutputToMachineList(tTileEntity, 66) - && !this.addEnergyInputToMachineList(tTileEntity, 66)) { - if (xDir + i != 0 || zDir + j != 0) {// no - // controller - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges of the bottom layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges of the bottom layer."); - return false; - } - } - } - } - else {// au�en �ber boden (ulv casings) - if (h == 1) { + public String[] getDescription() { + return new String[]{ + "Controller Block for the Matter Fabricator", + "Produces UU-Matter from UU-Amplifier", + "Size(WxHxD): 5x4x5, Controller (Bottom center)", + "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", + "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", + "1x Input Hatch (Any bottom layer casing)", + "1x Output Hatch (Any bottom layer casing)", + "1x Maintenance Hatch (Any bottom layer casing)", + "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", + "1x Energy Hatch (Any bottom layer casing)", + "24x IC2 Reinforced Glass for the walls", + "Matter Fabricator Casings for the edges & top (40 at least!)", + CORE.GT_Tooltip}; + } - if ((i == -2 || i == 2) && (j == -2 || j == 2)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the corners in the second layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the corners in the second layer."); - return false; - } - } + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66], + new GT_RenderedTexture(aActive ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; + } - else if ((i != -2 || i != 2) && (j != -2 || j != 2)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != GregtechMetaTileEntity_MassFabricator.IC2Glass) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); - return false; - } - } - } - if (h == 2) { - if ((i == -2 || i == 2) && (j == -2 || j == 2)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the corners in the third layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the corners in the third layer."); - return false; - } - } + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } - else if ((i != -2 || i != 2) && (j != -2 || j != 2)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != GregtechMetaTileEntity_MassFabricator.IC2Glass) { - Utils.LOG_INFO("Glass Casings Missing from somewhere in the third layer."); - return false; - } - } - } - if (h == 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges on the top layer."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges on the top layer."); - return false; - } - } - } - } - } - } - } - Utils.LOG_INFO("Multiblock Formed."); - return true; + @Override + public void onConfigLoad(GT_Config aConfig) { + super.onConfigLoad(aConfig); + sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUM_Duration_Multiplier", sDurationMultiplier); + sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_per_UUM", sUUAperUUM); + sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Speed_Bonus", sUUASpeedBonus); + sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, "Massfabricator.UUA_Requirement", sRequiresUUA); + Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); } @Override - public boolean checkRecipe(final ItemStack aStack) { - //Utils.LOG_INFO("Fabricating Matter."); - if (this.mInputHatches.size() != 1) { - Utils.LOG_INFO("Too many input hatches. Found: " + this.mInputHatches.size() + " | Expected: 1"); + public boolean checkRecipe(ItemStack aStack) { + Utils.LOG_INFO("Fabricating Matter."); + if (mInputHatches.size() != 1){ + Utils.LOG_INFO("Too many input hatches. Found: "+mInputHatches.size()+" | Expected: 1"); return false; } - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); + ArrayList<ItemStack> tInputList = getStoredInputs(); for (int i = 0; i < tInputList.size() - 1; i++) { for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { tInputList.remove(j--); - } - else { + } else { tInputList.remove(i--); break; } } } - } + } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); + + + ArrayList<FluidStack> tFluidList = getStoredFluids(); for (int i = 0; i < tFluidList.size() - 1; i++) { for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { tFluidList.remove(j--); - } - else { + } else { tFluidList.remove(i--); break; } @@ -241,109 +146,99 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo } } - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, - tFluidList.size()); - - for (int scrapSlots = 0; scrapSlots < tInputs.length; scrapSlots++) { - if (tInputs[scrapSlots].getItem() == this.scrapPile.getItem()) { - if (tInputs[scrapSlots].stackSize >= 9) { - Utils.LOG_INFO("Found enough scrap for a special recipe. x" + tInputs[scrapSlots].stackSize); - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, tFluidList.size()); + + + for (int scrapSlots=0;scrapSlots<tInputs.length;scrapSlots++){ + if (tInputs[scrapSlots].getItem() == scrapPile.getItem()){ + if (tInputs[scrapSlots].stackSize >= 9 ){ + Utils.LOG_INFO("Found enough scrap for a special recipe. x"+tInputs[scrapSlots].stackSize); + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + if (isValidMetaTileEntity(tHatch)) { Utils.LOG_INFO("Input fluid empty - Time to generate 1UU-A."); - if (tHatch.mFluid == null) { + if (tHatch.mFluid == null){ tHatch.mFluid = FluidUtils.getFluidStack("uuamplifier", 2); } - else { + else{ tHatch.mFluid.amount++; tHatch.mFluid.amount++; } tInputs[scrapSlots].stackSize = tInputs[scrapSlots].stackSize - 9; - Utils.LOG_INFO("Remaining after recipe. x" + tInputs[scrapSlots].stackSize); + Utils.LOG_INFO("Remaining after recipe. x"+tInputs[scrapSlots].stackSize); } } - } + } } } + if (tFluids.length > 0) { Utils.LOG_INFO("Input fluid found"); - for (int i = 0; i < tFluids.length; i++) { - final GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe( - this.getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[] { - tFluids[i] - }, new ItemStack[] {}); + for(int i = 0;i<tFluids.length;i++){ + GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tFluids[i]}, new ItemStack[]{}); if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; + if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[]{})) { + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; if (tRecipe.mEUt <= 16) { - this.mEUt = tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1); - this.mMaxProgresstime = tRecipe.mDuration / (1 << tTier - 1); - } - else { + this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = ((tRecipe.mDuration/**sDurationMultiplier*/) / (1 << tTier - 1)); + } else { this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { + this.mMaxProgresstime = (tRecipe.mDuration/**sDurationMultiplier*/); + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 2; this.mMaxProgresstime /= 4; } } if (this.mEUt > 0) { - this.mEUt = -this.mEUt; + this.mEUt = (-this.mEUt); } this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - tRecipe.getOutput(0) - }; + this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; this.mOutputFluids = tRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(this.mOutputFluids); - this.mMatterProduced++; - this.mAmplifierUsed++; - this.updateSlots(); - // Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + ArrayUtils.reverse(mOutputFluids); + mMatterProduced++; + mAmplifierUsed++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); return true; } } else { - // Utils.LOG_INFO("Invalid Recipe"); + //Utils.LOG_INFO("Invalid Recipe"); return false; } } } else if (tFluids.length == 0) { Utils.LOG_INFO("Input fluid not found"); - this.fakeRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(this.getBaseMetaTileEntity(), - false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[] { - this.tempFake - }, new ItemStack[] {}); + fakeRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tempFake}, new ItemStack[]{}); - this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; this.mEUt = 32; - this.mMaxProgresstime = 160 * 20; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[tTier - 1]) { + this.mMaxProgresstime = (160*20); + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { this.mEUt *= 4; this.mMaxProgresstime /= 2; } if (this.mEUt > 0) { - this.mEUt = -this.mEUt; + this.mEUt = (-this.mEUt); } - if (this.fakeRecipe != null) { + if (fakeRecipe != null) { this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[] { - this.fakeRecipe.getOutput(0) - }; - this.mOutputFluids = this.fakeRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(this.mOutputFluids); - this.mMatterProduced++; - this.updateSlots(); - // Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + this.mOutputItems = new ItemStack[]{fakeRecipe.getOutput(0)}; + this.mOutputFluids = fakeRecipe.mFluidOutputs.clone(); + ArrayUtils.reverse(mOutputFluids); + mMatterProduced++; + updateSlots(); + //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); return true; } } @@ -355,85 +250,147 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 10; - } + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + for (int i = -2; i < 3; i++) { + for (int j = -2; j < 3; j++) { + for (int h = 0; h < 4; h++) { - public int getAmplifierUsed() { - return this.mAmplifierUsed; - } + //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { + Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); + double tX = tTileEntity.getXCoord(); + double tY = tTileEntity.getYCoord(); + double tZ = tTileEntity.getZCoord(); + Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); + //return false; + }*/ + if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he + if (h == 0) {// innen boden (kantal coils) + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 8) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3."); + return false; + } + } else if (h == 3) {// innen decke (ulv casings + input + muffler) + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + } + } else {// innen air + if (!aBaseMetaTileEntity.getAirOffset(xDir + i, h, zDir + j)) { + Utils.LOG_INFO("Make sure the inner 3x3 of the Multiblock is Air."); + return false; + } + } + } else {// Outer 5x5 + if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) + if ((!addMaintenanceToMachineList(tTileEntity, 66)) && (!addInputToMachineList(tTileEntity, 66)) && (!addOutputToMachineList(tTileEntity, 66)) && (!addEnergyInputToMachineList(tTileEntity, 66))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer."); + return false; + } + } + } + } else {// au�en �ber boden (ulv casings) + if (h == 1) { - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); - } + if ((i == -2 || i == 2) && (j == -2 || j == 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + return false; + } + } - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Matter Fabricator", "Produces UU-Matter from UU-Amplifier", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", - "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", - "1x Input Hatch (Any bottom layer casing)", "1x Output Hatch (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", - "1x Energy Hatch (Any bottom layer casing)", "24x IC2 Reinforced Glass for the walls", - "Matter Fabricator Casings for the edges & top (40 at least!)", CORE.GT_Tooltip - }; - } + else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { + Utils.LOG_INFO("Glass Casings Missing from somewhere in the second layer."); + return false; + } + } + } + if (h == 2) { + if ((i == -2 || i == 2) && (j == -2 || j == 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the third layer."); + return false; + } + } - public int getMatterProduced() { - return this.mMatterProduced; + else if ((i != -2 || i != 2) && (j != -2 || j != 2)){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != IC2Glass) { + Utils.LOG_INFO("Glass Casings Missing from somewhere in the third layer."); + return false; + } + } + } + if (h == 3) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 9) { + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges on the top layer."); + return false; + } + } + } + } + } + } + } + Utils.LOG_INFO("Multiblock Formed."); + return true; } @Override - public int getMaxEfficiency(final ItemStack aStack) { + public int getMaxEfficiency(ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[66], new GT_RenderedTexture( - aActive ? TexturesGtBlock.Casing_Machine_Screen_3 : TexturesGtBlock.Casing_Machine_Screen_1) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[66] - }; + public int getAmountOfOutputs() { + return 10; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_MassFabricator(this.mName); + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } @Override - public void onConfigLoad(final GT_Config aConfig) { - super.onConfigLoad(aConfig); - GregtechMetaTileEntity_MassFabricator.sDurationMultiplier = aConfig.get(ConfigCategories.machineconfig, - "Massfabricator.UUM_Duration_Multiplier", GregtechMetaTileEntity_MassFabricator.sDurationMultiplier); - GregtechMetaTileEntity_MassFabricator.sUUAperUUM = aConfig.get(ConfigCategories.machineconfig, - "Massfabricator.UUA_per_UUM", GregtechMetaTileEntity_MassFabricator.sUUAperUUM); - GregtechMetaTileEntity_MassFabricator.sUUASpeedBonus = aConfig.get(ConfigCategories.machineconfig, - "Massfabricator.UUA_Speed_Bonus", GregtechMetaTileEntity_MassFabricator.sUUASpeedBonus); - GregtechMetaTileEntity_MassFabricator.sRequiresUUA = aConfig.get(ConfigCategories.machineconfig, - "Massfabricator.UUA_Requirement", GregtechMetaTileEntity_MassFabricator.sRequiresUUA); - Materials.UUAmplifier.mChemicalFormula = "Mass Fabricator Eff/Speed Bonus: x" - + GregtechMetaTileEntity_MassFabricator.sUUASpeedBonus; + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MassFabricator(this.mName); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java index b4f272bdf3..069652f40d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; -import java.util.Arrays; - import gregtech.api.enums.Textures; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; @@ -17,6 +14,10 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; + +import java.util.ArrayList; +import java.util.Arrays; + import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -24,399 +25,365 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_MultiTank extends GregtechMeta_MultiBlockBase { - private long fluidStored = 0; - - private short multiblockCasingCount = 0; - private short storageMultiplier = this.getStorageMultiplier(); - private long maximumFluidStorage = this.getMaximumTankStorage(); - private FluidStack internalStorageTank = null; - public GregtechMetaTileEntity_MultiTank(final int aID, final String aName, final String aNameRegional) { +public class GregtechMetaTileEntity_MultiTank +extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_MultiTank(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_MultiTank(final String aName) { + private long fluidStored = 0; + private short multiblockCasingCount = 0; + private short storageMultiplier = getStorageMultiplier(); + private long maximumFluidStorage = getMaximumTankStorage(); + private FluidStack internalStorageTank = null; + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mEUt", mEUt); + aNBT.setInteger("mProgresstime", mProgresstime); + aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setInteger("mEfficiency", mEfficiency); + aNBT.setInteger("mPollution", mPollution); + aNBT.setInteger("mRuntime", mRuntime); + aNBT.setLong("mFluidStored", fluidStored); + aNBT.setShort("mStorageMultiplier", storageMultiplier); + aNBT.setLong("mMaxFluidStored", maximumFluidStorage); + aNBT.setShort("mCasingCount", multiblockCasingCount); + + if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++) + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++) + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + + aNBT.setBoolean("mWrench", mWrench); + aNBT.setBoolean("mScrewdriver", mScrewdriver); + aNBT.setBoolean("mSoftHammer", mSoftHammer); + aNBT.setBoolean("mHardHammer", mHardHammer); + aNBT.setBoolean("mSolderingTool", mSolderingTool); + aNBT.setBoolean("mCrowbar", mCrowbar); + } + + private short getStorageMultiplier(){ + int tempstorageMultiplier = (1*multiblockCasingCount); + if (tempstorageMultiplier <= 0){ + return 1; + } + return (short) tempstorageMultiplier; + } + + private long getMaximumTankStorage(){ + int multiplier = getStorageMultiplier(); + Utils.LOG_WARNING("x = "+multiplier+" * 96000"); + long tempTankStorageMax = (96000*multiplier); + Utils.LOG_WARNING("x = "+tempTankStorageMax); + if (tempTankStorageMax <= 0){ + return 96000; + } + return tempTankStorageMax; + } + + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mEUt = aNBT.getInteger("mEUt"); + mProgresstime = aNBT.getInteger("mProgresstime"); + mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); + if (mMaxProgresstime > 0) mRunningOnLoad = true; + mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + mEfficiency = aNBT.getInteger("mEfficiency"); + mPollution = aNBT.getInteger("mPollution"); + mRuntime = aNBT.getInteger("mRuntime"); + fluidStored = aNBT.getLong("mFluidStored"); + storageMultiplier = aNBT.getShort("mStorageMultiplier"); + maximumFluidStorage = aNBT.getLong("mMaxFluidStored"); + multiblockCasingCount = aNBT.getShort("mCasingCount"); + mOutputItems = new ItemStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + mOutputFluids = new FluidStack[getAmountOfOutputs()]; + for (int i = 0; i < mOutputFluids.length; i++) + mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + mWrench = aNBT.getBoolean("mWrench"); + mScrewdriver = aNBT.getBoolean("mScrewdriver"); + mSoftHammer = aNBT.getBoolean("mSoftHammer"); + mHardHammer = aNBT.getBoolean("mHardHammer"); + mSolderingTool = aNBT.getBoolean("mSolderingTool"); + mCrowbar = aNBT.getBoolean("mCrowbar"); + } + + public GregtechMetaTileEntity_MultiTank(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { - Utils.LOG_INFO("Must be hollow."); - return false; - } - int tAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - for (int h = -1; h < 19; h++) { - if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity - .getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if (!this.addMaintenanceToMachineList(tTileEntity, 68) - && !this.addInputToMachineList(tTileEntity, 68) - && !this.addOutputToMachineList(tTileEntity, 68) - && !this.addEnergyInputToMachineList(tTileEntity, 68)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - if (h < 3) { - Utils.LOG_INFO("Casing Expected."); - return false; - } - else if (h >= 3) { - // Utils.LOG_WARNING("Your Multitank can be - // 20 blocks tall."); - } - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { - if (h < 3) { - Utils.LOG_INFO("Wrong Meta."); - return false; - } - else if (h >= 3) { - // Utils.LOG_WARNING("Your Multitank can be - // 20 blocks tall."); - } - } - if (h < 3) { - tAmount++; - } - else if (h >= 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air - || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getUnlocalizedName().contains("residual")) { - Utils.LOG_INFO("Found air"); - } - else { - Utils.LOG_INFO("Layer " + (h + 2) + " is complete. Adding " + 64000 * 9 - + "L storage to the tank."); - tAmount++; - } - } - } - } - } - } + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MultiTank(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Multitank", + "Size: 3xHx3 (Block behind controller must be air)", + "Structure must be at least 4 blocks tall, maximum 20.", + "Each casing within the structure adds 96000L storage.", + "Controller (front centered)", + "1x Input hatch (anywhere)", + "1x Output hatch (anywhere)", + "1x Energy Hatch (anywhere)", + "1x Maintenance Hatch (anywhere)", + "Multitank Exterior Casings for the rest (16 at least!)", + "Stored Fluid: "+fluidStored}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[68], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Screen_Logo : TexturesGtBlock.Overlay_Machine_Screen_Logo)}; } - this.multiblockCasingCount = (short) tAmount; - Utils.LOG_INFO("Your Multitank can be 20 blocks tall."); - Utils.LOG_INFO("Casings Count: " + tAmount + " Valid Multiblock: " + (tAmount >= 16) + " Tank Storage Capacity:" - + this.getMaximumTankStorage() + "L"); - return tAmount >= 16; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[68]}; } @Override - public boolean checkRecipe(final ItemStack aStack) { - Utils.LOG_INFO("Okay"); + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); + } - final ArrayList<ItemStack> tInputList = this.getStoredInputs(); + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing > 1; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + Utils.LOG_INFO("Okay"); + + + + ArrayList<ItemStack> tInputList = getStoredInputs(); for (int i = 0; i < tInputList.size() - 1; i++) { for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { + if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { tInputList.remove(j--); - } - else { + } else { tInputList.remove(i--); break; } } } } - final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - final ArrayList<FluidStack> tFluidList = this.getStoredFluids(); + ArrayList<FluidStack> tFluidList = getStoredFluids(); for (int i = 0; i < tFluidList.size() - 1; i++) { for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { + if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { tFluidList.remove(j--); - } - else { + } else { tFluidList.remove(i--); break; } } } } - final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); - - if (tFluids.length >= 2) { + FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); + + if (tFluids.length >= 2){ Utils.LOG_INFO("Bad"); return false; } - - final ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>>(); + + ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>>(); int slotInputCount = 0; - for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { + for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { boolean containsFluid = false; - if (GregtechMeta_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + if (isValidMetaTileEntity(tHatch)) { slotInputCount++; - for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { - if (tHatch.canTankBeEmptied()) { - containsFluid = true; - } + for (int i=0; i<tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { + if (tHatch.canTankBeEmptied()){containsFluid=true;} } rList.add(new Pair<GT_MetaTileEntity_Hatch_Input, Boolean>(tHatch, containsFluid)); } } - if (tFluids.length <= 0 || slotInputCount > 1) { + if (tFluids.length <= 0 || slotInputCount > 1){ Utils.LOG_INFO("Bad"); return false; } - - Utils.LOG_INFO("Okay - 2"); - if (this.internalStorageTank == null) { - if (rList.get(0).getKey().mFluid != null && rList.get(0).getKey().mFluid.amount > 0) { - Utils.LOG_INFO( - "Okay - 1" + " rList.get(0).getKey().mFluid.amount: " + rList.get(0).getKey().mFluid.amount - + " internalStorageTank:" + this.internalStorageTank.amount); - this.internalStorageTank = rList.get(0).getKey().mFluid; - this.internalStorageTank.amount = rList.get(0).getKey().mFluid.amount; + + Utils.LOG_INFO("Okay - 2"); + if (internalStorageTank == null){ + if (rList.get(0).getKey().mFluid != null && rList.get(0).getKey().mFluid.amount > 0){ + Utils.LOG_INFO("Okay - 1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount +" internalStorageTank:"+internalStorageTank.amount); + internalStorageTank = rList.get(0).getKey().mFluid; + internalStorageTank.amount = rList.get(0).getKey().mFluid.amount; rList.get(0).getKey().mFluid.amount = 0; - Utils.LOG_INFO( - "Okay - 1.1" + " rList.get(0).getKey().mFluid.amount: " + rList.get(0).getKey().mFluid.amount - + " internalStorageTank:" + this.internalStorageTank.amount); + Utils.LOG_INFO("Okay - 1.1"+" rList.get(0).getKey().mFluid.amount: "+rList.get(0).getKey().mFluid.amount +" internalStorageTank:"+internalStorageTank.amount); return true; } Utils.LOG_INFO("No Fluid in hatch."); - return false; + return false; } - else if (this.internalStorageTank.isFluidEqual(rList.get(0).getKey().mFluid)) { - Utils.LOG_INFO("Storing " + rList.get(0).getKey().mFluid.amount + "L"); - Utils.LOG_INFO("Contains " + this.internalStorageTank.amount + "L"); - + else if (internalStorageTank.isFluidEqual(rList.get(0).getKey().mFluid)){ + Utils.LOG_INFO("Storing "+rList.get(0).getKey().mFluid.amount+"L"); + Utils.LOG_INFO("Contains "+internalStorageTank.amount+"L"); + int tempAdd = 0; tempAdd = rList.get(0).getKey().getFluidAmount(); - rList.get(0).getKey().mFluid = null; - Utils.LOG_INFO("adding " + tempAdd); - this.internalStorageTank.amount = this.internalStorageTank.amount + tempAdd; - Utils.LOG_INFO("Tank now Contains " + this.internalStorageTank.amount + "L of " - + this.internalStorageTank.getFluid().getName() + "."); - - if (this.mOutputHatches.get(0).mFluid == null || this.mOutputHatches.isEmpty()) { - Utils.LOG_INFO("Okay - 3"); - final int tempCurrentStored = this.internalStorageTank.amount; - int tempSubtract = 0; - int tempResult = 0; - final int tempHatchSize = this.mOutputHatches.get(0).getCapacity(); - final FluidStack tempOutputFluid = this.internalStorageTank; - if (tempHatchSize > tempCurrentStored) { - Utils.LOG_INFO("Okay - 3.1.1" + " hatchCapacity: " + tempHatchSize + " tempCurrentStored:" - + tempCurrentStored); - tempOutputFluid.amount = tempHatchSize; - tempSubtract = tempHatchSize; - tempResult = tempCurrentStored - tempSubtract; - Utils.LOG_INFO( - "Okay - 3.1.2" + " result: " + tempResult + " tempCurrentStored:" + tempCurrentStored); - this.mOutputHatches.get(0).mFluid = tempOutputFluid; - this.internalStorageTank.amount = tempResult; - } - else if (tempCurrentStored >= 5000) { - Utils.LOG_INFO("Okay - 3.2"); - tempOutputFluid.amount = tempCurrentStored; - tempSubtract = tempOutputFluid.amount; - tempResult = tempCurrentStored - tempSubtract; - this.mOutputHatches.get(0).mFluid = tempOutputFluid; - this.internalStorageTank.amount = tempResult; - } - Utils.LOG_INFO("Tank"); - return true; - } - else if (this.mOutputHatches.get(0).mFluid.isFluidEqual(this.internalStorageTank)) { - Utils.LOG_INFO("Okay - 4"); - final int tempCurrentStored = this.internalStorageTank.amount; - int tempSubtract = 0; - int tempResult = 0; - final int tempHatchSize = this.mOutputHatches.get(0).getCapacity(); - final FluidStack tempOutputFluid = this.internalStorageTank; - if (tempHatchSize > tempCurrentStored) { - tempOutputFluid.amount = tempHatchSize; - tempSubtract = tempOutputFluid.amount; - tempResult = tempCurrentStored - tempSubtract; - this.mOutputHatches.get(0).mFluid = tempOutputFluid; - this.internalStorageTank.amount = tempResult; - } - else if (tempCurrentStored >= 5000) { - tempOutputFluid.amount = tempCurrentStored; - tempSubtract = tempOutputFluid.amount; - tempResult = tempCurrentStored - tempSubtract; - this.mOutputHatches.get(0).mFluid = tempOutputFluid; - this.internalStorageTank.amount = tempResult; + rList.get(0).getKey().mFluid = null; + Utils.LOG_INFO("adding "+tempAdd); + internalStorageTank.amount = internalStorageTank.amount + tempAdd; + Utils.LOG_INFO("Tank now Contains "+internalStorageTank.amount+"L of "+internalStorageTank.getFluid().getName()+"."); + + if (mOutputHatches.get(0).mFluid == null || mOutputHatches.isEmpty()){ + Utils.LOG_INFO("Okay - 3"); + int tempCurrentStored = internalStorageTank.amount; + int tempSubtract = 0; + int tempResult = 0; + int tempHatchSize = mOutputHatches.get(0).getCapacity(); + FluidStack tempOutputFluid = internalStorageTank; + if (tempHatchSize > tempCurrentStored){ + Utils.LOG_INFO("Okay - 3.1.1"+" hatchCapacity: "+tempHatchSize +" tempCurrentStored:"+tempCurrentStored); + tempOutputFluid.amount = tempHatchSize; + tempSubtract = tempHatchSize; + tempResult = tempCurrentStored - tempSubtract; + Utils.LOG_INFO("Okay - 3.1.2"+" result: "+tempResult +" tempCurrentStored:"+tempCurrentStored); + mOutputHatches.get(0).mFluid = tempOutputFluid; + internalStorageTank.amount = tempResult; + } + else if (tempCurrentStored >= 5000){ + Utils.LOG_INFO("Okay - 3.2"); + tempOutputFluid.amount = tempCurrentStored; + tempSubtract = tempOutputFluid.amount; + tempResult = tempCurrentStored - tempSubtract; + mOutputHatches.get(0).mFluid = tempOutputFluid; + internalStorageTank.amount = tempResult; + } + Utils.LOG_INFO("Tank"); + return true; } + else if (mOutputHatches.get(0).mFluid.isFluidEqual(internalStorageTank)){ + Utils.LOG_INFO("Okay - 4"); + int tempCurrentStored = internalStorageTank.amount; + int tempSubtract = 0; + int tempResult = 0; + int tempHatchSize = mOutputHatches.get(0).getCapacity(); + FluidStack tempOutputFluid = internalStorageTank; + if (tempHatchSize > tempCurrentStored){ + tempOutputFluid.amount = tempHatchSize; + tempSubtract = tempOutputFluid.amount; + tempResult = tempCurrentStored - tempSubtract; + mOutputHatches.get(0).mFluid = tempOutputFluid; + internalStorageTank.amount = tempResult; + } + else if (tempCurrentStored >= 5000){ + tempOutputFluid.amount = tempCurrentStored; + tempSubtract = tempOutputFluid.amount; + tempResult = tempCurrentStored - tempSubtract; + mOutputHatches.get(0).mFluid = tempOutputFluid; + internalStorageTank.amount = tempResult; + } + Utils.LOG_INFO("Tank"); + return true; + } Utils.LOG_INFO("Tank"); - return true; - } - Utils.LOG_INFO("Tank"); return true; } else { - Utils.LOG_INFO("Tank Contains " + this.internalStorageTank.amount + "L of " - + this.internalStorageTank.getFluid().getName() + "."); + Utils.LOG_INFO("Tank Contains "+internalStorageTank.amount+"L of "+internalStorageTank.getFluid().getName()+"."); } - // this.getBaseMetaTileEntity().(tFluids[0].amount, true); + //this.getBaseMetaTileEntity().(tFluids[0].amount, true); Utils.LOG_INFO("Tank"); return false; } @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), - "VacuumFreezer.png"); - } - - @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Multitank", "Size: 3xHx3 (Block behind controller must be air)", - "Structure must be at least 4 blocks tall, maximum 20.", - "Each casing within the structure adds 96000L storage.", "Controller (front centered)", - "1x Input hatch (anywhere)", "1x Output hatch (anywhere)", "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", "Multitank Exterior Casings for the rest (16 at least!)", - "Stored Fluid: " + this.fluidStored - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - private long getMaximumTankStorage() { - final int multiplier = this.getStorageMultiplier(); - Utils.LOG_WARNING("x = " + multiplier + " * 96000"); - final long tempTankStorageMax = 96000 * multiplier; - Utils.LOG_WARNING("x = " + tempTankStorageMax); - if (tempTankStorageMax <= 0) { - return 96000; - } - return tempTankStorageMax; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { - return 0; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - private short getStorageMultiplier() { - final int tempstorageMultiplier = 1 * this.multiblockCasingCount; - if (tempstorageMultiplier <= 0) { - return 1; + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + Utils.LOG_INFO("Must be hollow."); + return false; } - return (short) tempstorageMultiplier; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[68], new GT_RenderedTexture(aActive - ? TexturesGtBlock.Overlay_Machine_Screen_Logo : TexturesGtBlock.Overlay_Machine_Screen_Logo) - }; + int tAmount = 0; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 19; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if ((!addMaintenanceToMachineList(tTileEntity, 68)) && (!addInputToMachineList(tTileEntity, 68)) && (!addOutputToMachineList(tTileEntity, 68)) && (!addEnergyInputToMachineList(tTileEntity, 68))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + if (h < 3){ + Utils.LOG_INFO("Casing Expected."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 11) { + if (h < 3){ + Utils.LOG_INFO("Wrong Meta."); + return false; + } + else if (h >= 3){ + //Utils.LOG_WARNING("Your Multitank can be 20 blocks tall."); + } + } + if (h < 3){ + tAmount++; + } + else if (h >= 3){ + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) == Blocks.air || aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName().contains("residual")){ + Utils.LOG_INFO("Found air"); + } + else { + Utils.LOG_INFO("Layer "+(h+2)+" is complete. Adding "+(64000*9)+"L storage to the tank."); + tAmount++; + } + } + } + } + } + } } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[68] - }; + multiblockCasingCount = (short) tAmount; + Utils.LOG_INFO("Your Multitank can be 20 blocks tall."); + Utils.LOG_INFO("Casings Count: "+tAmount+" Valid Multiblock: "+(tAmount >= 16)+" Tank Storage Capacity:"+getMaximumTankStorage()+"L"); + return tAmount >= 16; } @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mEUt = aNBT.getInteger("mEUt"); - this.mProgresstime = aNBT.getInteger("mProgresstime"); - this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - if (this.mMaxProgresstime > 0) { - this.mRunningOnLoad = true; - } - this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - this.mEfficiency = aNBT.getInteger("mEfficiency"); - this.mPollution = aNBT.getInteger("mPollution"); - this.mRuntime = aNBT.getInteger("mRuntime"); - this.fluidStored = aNBT.getLong("mFluidStored"); - this.storageMultiplier = aNBT.getShort("mStorageMultiplier"); - this.maximumFluidStorage = aNBT.getLong("mMaxFluidStored"); - this.multiblockCasingCount = aNBT.getShort("mCasingCount"); - this.mOutputItems = new ItemStack[this.getAmountOfOutputs()]; - for (int i = 0; i < this.mOutputItems.length; i++) { - this.mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - } - this.mOutputFluids = new FluidStack[this.getAmountOfOutputs()]; - for (int i = 0; i < this.mOutputFluids.length; i++) { - this.mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); - } - this.mWrench = aNBT.getBoolean("mWrench"); - this.mScrewdriver = aNBT.getBoolean("mScrewdriver"); - this.mSoftHammer = aNBT.getBoolean("mSoftHammer"); - this.mHardHammer = aNBT.getBoolean("mHardHammer"); - this.mSolderingTool = aNBT.getBoolean("mSolderingTool"); - this.mCrowbar = aNBT.getBoolean("mCrowbar"); + public int getPollutionPerTick(ItemStack aStack) { + return 0; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_MultiTank(this.mName); + public int getAmountOfOutputs() { + return 1; } @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mEUt", this.mEUt); - aNBT.setInteger("mProgresstime", this.mProgresstime); - aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); - aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); - aNBT.setInteger("mEfficiency", this.mEfficiency); - aNBT.setInteger("mPollution", this.mPollution); - aNBT.setInteger("mRuntime", this.mRuntime); - aNBT.setLong("mFluidStored", this.fluidStored); - aNBT.setShort("mStorageMultiplier", this.storageMultiplier); - aNBT.setLong("mMaxFluidStored", this.maximumFluidStorage); - aNBT.setShort("mCasingCount", this.multiblockCasingCount); - - if (this.mOutputItems != null) { - for (int i = 0; i < this.mOutputItems.length; i++) { - if (this.mOutputItems[i] != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItems[i].writeToNBT(tNBT); - aNBT.setTag("mOutputItem" + i, tNBT); - } - } - } - if (this.mOutputFluids != null) { - for (int i = 0; i < this.mOutputFluids.length; i++) { - if (this.mOutputFluids[i] != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputFluids[i].writeToNBT(tNBT); - aNBT.setTag("mOutputFluids" + i, tNBT); - } - } - } - - aNBT.setBoolean("mWrench", this.mWrench); - aNBT.setBoolean("mScrewdriver", this.mScrewdriver); - aNBT.setBoolean("mSoftHammer", this.mSoftHammer); - aNBT.setBoolean("mHardHammer", this.mHardHammer); - aNBT.setBoolean("mSolderingTool", this.mSolderingTool); - aNBT.setBoolean("mCrowbar", this.mCrowbar); + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java index 1006f68da7..45635ea74d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_PowerSubStationController.java @@ -17,144 +17,131 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTileEntity_MultiBlockBase { - private final int recipeCounter = 0; + private int recipeCounter = 0; - public GregtechMetaTileEntity_PowerSubStationController(final int aID, final String aName, - final String aNameRegional) { + public GregtechMetaTileEntity_PowerSubStationController(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_PowerSubStationController(final String aName) { + public GregtechMetaTileEntity_PowerSubStationController(String aName) { super(aName); } @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + public String[] getDescription() { + return new String[]{ + "Controller Block for the Power Sub-Station", + "Stores quite a lot of power.", + "Size(WxHxD): 1x5x1, Controller (One above the Bottom)", + CORE.GT_Tooltip}; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[67], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[67]}; + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); + } + + @Override + public void onConfigLoad(GT_Config aConfig) { + super.onConfigLoad(aConfig); + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { for (int h = 0; h < 4; h++) { - // Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" - // zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); - - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - h, zDir + j); - /* - * if (tTileEntity != - * Block.getBlockFromItem(UtilsItems.getItem( - * "IC2:blockAlloyGlass"))) { Utils.LOG_INFO("h:"+h+" i:"+i+ - * " j:"+j); double tX = tTileEntity.getXCoord(); double tY - * = tTileEntity.getYCoord(); double tZ = - * tTileEntity.getZCoord(); Utils.LOG_INFO( - * "Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); //return - * false; } - */ - if (i != -2 && i != 2 && j != -2 && j != 2) {// innerer 3x3 - // ohne h�he - if (h == 0 && i != 0 && j != 0) {// innen boden (kantal - // coils) - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO( - "Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Block"); - Utils.LOG_INFO("Found: " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName() - + " at x:" + (xDir + i) + " y:" + h + " z:" + (zDir + j)); - // tTileEntity.getWorld().setBlock(xDir+i, h, - // zDir+j, Blocks.diamond_block); - // Utils.LOG_INFO("Changed into : - // "+aBaseMetaTileEntity.getBlockOffset(xDir + - // i, h, zDir + j).getUnlocalizedName()); + //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); + + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { + Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); + double tX = tTileEntity.getXCoord(); + double tY = tTileEntity.getYCoord(); + double tZ = tTileEntity.getZCoord(); + Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); + //return false; + }*/ + if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he + if (h == 0 && i != 0 && j != 0) {// innen boden (kantal coils) + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Block"); + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); + //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO( - "Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Meta"); + Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Meta"); return false; } - } - else if (h == 3 && i != 0 && j != 0) {// innen decke - // (ulv casings - // + input + - // muffler) - // if(j == 0 && i == 0) { - - if (!this.addMufflerToMachineList(tTileEntity, 66)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Found: " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getUnlocalizedName() - + " at x:" + (xDir + i) + " y:" + h + " z:" + (zDir + j)); - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO("Found: " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getUnlocalizedName() - + " at x:" + (xDir + i) + " y:" + h + " z:" + (zDir + j)); - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } + } + else if (h == 3 && i != 0 && j != 0) {// innen decke (ulv casings + input + muffler) + //if(j == 0 && i == 0) { + + if ((!addMufflerToMachineList(tTileEntity, 66))) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); + return false; + } + } + //} + + } /*else {// top air + if ((i != -2 && i != 2) && (j != -2 && j != 2) && h == 3) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Block"); + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); + //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); + return false; } - // } - - } /* - * else {// top air if ((i != -2 && i != 2) && (j != - * -2 && j != 2) && h == 3) { if - * (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - * zDir + j) != ModBlocks.blockCasingsMisc) { - * Utils.LOG_INFO( - * "Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Block" - * ); Utils.LOG_INFO("Found: " - * +aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - * zDir + j).getUnlocalizedName()+" at x:"+(xDir + - * i)+" y:" +h+" z:"+(zDir + j)); - * //tTileEntity.getWorld().setBlock(xDir+i, h, - * zDir+j, Blocks.diamond_block); //Utils.LOG_INFO( - * "Changed into : " - * +aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - * zDir + j).getUnlocalizedName()); return false; } - * if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, - * h, zDir + j) != 4) { Utils.LOG_INFO( - * "Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Meta" - * ); return false; } } } - */ - } - else {// Outer 5x5 - if (h == 0) {// au�en boden (controller, output, energy, - // maintainance, rest ulv casings) - if (!this.addEnergyInputToMachineList(tTileEntity, 66) - && !this.addDynamoToMachineList(tTileEntity, 66)) { - if (xDir + i != 0 || zDir + j != 0) {// no - // controller - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, - zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Found: " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getUnlocalizedName() - + " at x:" + (xDir + i) + " y:" + h + " z:" + (zDir + j)); - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges of the bottom layer. " - + aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) - .getLocalizedName()); + if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { + Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Meta"); + return false; + } + } + }*/ + } else {// Outer 5x5 + if (h == 0) {// au�en boden (controller, output, energy, maintainance, rest ulv casings) + if ((!addEnergyInputToMachineList(tTileEntity, 66) && (!addDynamoToMachineList(tTileEntity, 66)))) { + if ((xDir + i != 0) || (zDir + j != 0)) {//no controller + if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { + Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer. "+(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName())); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO( - "Matter Fabricator Casings Missing from one of the edges of the bottom layer. 2"); + Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the edges of the bottom layer. 2"); return false; } } } - } - else { - + } else { + } } } @@ -165,77 +152,38 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil } @Override - public boolean checkRecipe(final ItemStack aStack) { - return false; - } - - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; } @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, - final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); + public int getMaxEfficiency(ItemStack aStack) { + return 10000; } @Override - public int getDamageToComponent(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack aStack) { return 0; } @Override - public String[] getDescription() { - return new String[] { - "Controller Block for the Power Sub-Station", "Stores quite a lot of power.", - "Size(WxHxD): 1x5x1, Controller (One above the Bottom)", CORE.GT_Tooltip - }; - } - - @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getDamageToComponent(ItemStack aStack) { return 0; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[67], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE - : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER) - }; - } - return new ITexture[] { - Textures.BlockIcons.CASING_BLOCKS[67] - }; + public int getAmountOfOutputs() { + return 1; } @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; + public boolean explodesOnComponentBreak(ItemStack aStack) { + return false; } @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GregtechMetaTileEntity_PowerSubStationController(this.mName); } - @Override - public void onConfigLoad(final GT_Config aConfig) { - super.onConfigLoad(aConfig); - } - }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java index eede58d65b..7508391f93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java @@ -12,108 +12,130 @@ import gtPlusPlus.core.util.fluid.FluidUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -public class GT_MetaTileEntity_TieredTank extends GT_MetaTileEntity_BasicTank { +public class GT_MetaTileEntity_TieredTank +extends GT_MetaTileEntity_BasicTank { - private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - private String mFluidName; - private int mFluidAmount; + private NBTTagCompound mRecipeStuff = new NBTTagCompound(); + private String mFluidName; + private int mFluidAmount; - public GT_MetaTileEntity_TieredTank(final int aID, final String aName, final String aNameRegional, - final int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Stores " + (int) (Math.pow(2, aTier) * 32000) + "L of fluid"); + public GT_MetaTileEntity_TieredTank(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); } - public GT_MetaTileEntity_TieredTank(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures) { + public GT_MetaTileEntity_TieredTank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 3, aDescription, aTextures); } @Override - public boolean canTankBeEmptied() { - return true; + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; } @Override - public boolean canTankBeFilled() { - return true; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER)}; } - @Override - public boolean displaysItemStack() { + + private boolean setVars(){ + //Utils.LOG_INFO("setting Vars."); + if (mFluidName.equals("") || !mFluidName.equals(null)){ + if (mFluid != null) mFluidName = mFluid.getFluid().getName(); + } + else{ + if (mFluid != null){ + if (!mFluidName.equalsIgnoreCase(mFluid.getFluid().getName())){ + mFluidName = mFluid.getFluid().getName(); + } + } + else { + // Leave Values Blank. + return false; + } + } + + if (mFluidAmount <= 0){ + if (mFluid != null) mFluidAmount = mFluid.amount; + } + else { + if (mFluid != null){ + if (mFluidAmount != mFluid.amount){ + mFluidAmount = mFluid.amount; + } + } + else { + // Leave Values Blank. + return false; + } + } return true; } + @Override - public boolean displaysStackSize() { - return false; - } + public String[] getDescription() { + + setVars(); - @Override - public boolean doesEmptyContainers() { - return true; + + if ((mFluidName.equals("Empty")||mFluidName.equals("")) || mFluidAmount <= 0){ + return new String[] {mDescription, CORE.GT_Tooltip}; + } + return new String[] {mDescription, "Stored Fluid: "+mFluidName, "Stored Amount: "+mFluidAmount+"l", CORE.GT_Tooltip}; } + @Override - public boolean doesFillContainers() { - return true; + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + setVars(); + mRecipeStuff.setString("mFluidName", mFluidName); + mRecipeStuff.setInteger("mFluidAmount", mFluidAmount); + aNBT.setTag("GT.CraftingComponents", mRecipeStuff); } @Override - public int getCapacity() { - return (int) (Math.pow(2, this.mTier) * 32000); + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); + mFluidName = mRecipeStuff.getString("mFluidName"); + mFluidAmount = mRecipeStuff.getInteger("mFluidAmount"); + mFluid = FluidUtils.getFluidStack(mFluidName, mFluidAmount); + setItemNBT(aNBT); } @Override - public String[] getDescription() { - - this.setVars(); - - if (this.mFluidName.equals("Empty") || this.mFluidName.equals("") || this.mFluidAmount <= 0) { - return new String[] { - this.mDescription, CORE.GT_Tooltip - }; - } - return new String[] { - this.mDescription, "Stored Fluid: " + this.mFluidName, "Stored Amount: " + this.mFluidAmount + "l", - CORE.GT_Tooltip - }; + public void setItemNBT(NBTTagCompound aNBT) { + super.setItemNBT(aNBT); + mRecipeStuff.setString("mFluidName", mFluidName); + mRecipeStuff.setInteger("mFluidAmount", mFluidAmount); + aNBT.setTag("GT.CraftingComponents", mRecipeStuff); } - @Override - public String[] getInfoData() { - if (this.mFluid == null) { - return new String[] { - GT_Values.VOLTAGE_NAMES[this.mTier] + " Fluid Tank", "Stored Fluid:", "No Fluid", - Integer.toString(0) + "L", Integer.toString(this.getCapacity()) + "L" - }; + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + return true; } - return new String[] { - GT_Values.VOLTAGE_NAMES[this.mTier] + " Fluid Tank", "Stored Fluid:", this.mFluid.getLocalizedName(), - Integer.toString(this.mFluid.amount) + "L", Integer.toString(this.getCapacity()) + "L" - }; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; } @Override - public int getTankPressure() { - return 100; + public boolean isSimpleMachine() { + return true; } @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - return aSide == 1 ? new ITexture[] { - Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE) - } : new ITexture[] { - Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], - new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER) - }; + public boolean isFacingValid(byte aFacing) { + return true; } @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - return new ITexture[0][0][0]; + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; } @Override @@ -122,114 +144,84 @@ public class GT_MetaTileEntity_TieredTank extends GT_MetaTileEntity_BasicTank { } @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { + public boolean doesFillContainers() { return true; } @Override - public boolean isFacingValid(final byte aFacing) { + public boolean doesEmptyContainers() { return true; } @Override - public boolean isGivingInformation() { + public boolean canTankBeFilled() { return true; } @Override - public boolean isSimpleMachine() { + public boolean canTankBeEmptied() { return true; } @Override - public void loadNBTData(final NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - this.mFluidName = this.mRecipeStuff.getString("mFluidName"); - this.mFluidAmount = this.mRecipeStuff.getInteger("mFluidAmount"); - this.mFluid = FluidUtils.getFluidStack(this.mFluidName, this.mFluidAmount); - this.setItemNBT(aNBT); + public boolean displaysItemStack() { + return true; } @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TieredTank(this.mName, this.mTier, this.mDescription, this.mTextures); + public boolean displaysStackSize() { + return false; } @Override - public void onMachineBlockUpdate() { - this.getBaseMetaTileEntity().markDirty(); - super.onMachineBlockUpdate(); + public String[] getInfoData() { + + if (mFluid == null) { + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", + "Stored Fluid:", + "No Fluid", + Integer.toString(0) + "L", + Integer.toString(getCapacity()) + "L"}; + } + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", + "Stored Fluid:", + mFluid.getLocalizedName(), + Integer.toString(mFluid.amount) + "L", + Integer.toString(getCapacity()) + "L"}; } @Override - public void onRemoval() { - this.getBaseMetaTileEntity().markDirty(); - super.onRemoval(); + public boolean isGivingInformation() { + return true; } @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TieredTank(mName, mTier, mDescription, mTextures); } @Override - public void saveNBTData(final NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - this.setVars(); - this.mRecipeStuff.setString("mFluidName", this.mFluidName); - this.mRecipeStuff.setInteger("mFluidAmount", this.mFluidAmount); - aNBT.setTag("GT.CraftingComponents", this.mRecipeStuff); + public int getCapacity() { + return (int) (Math.pow(2, mTier) * 32000); } @Override - public void setItemNBT(final NBTTagCompound aNBT) { - super.setItemNBT(aNBT); - this.mRecipeStuff.setString("mFluidName", this.mFluidName); - this.mRecipeStuff.setInteger("mFluidAmount", this.mFluidAmount); - aNBT.setTag("GT.CraftingComponents", this.mRecipeStuff); + public int getTankPressure() { + return 100; } - private boolean setVars() { - // Utils.LOG_INFO("setting Vars."); - if (this.mFluidName.equals("") || !this.mFluidName.equals(null)) { - if (this.mFluid != null) { - this.mFluidName = this.mFluid.getFluid().getName(); - } - } - else { - if (this.mFluid != null) { - if (!this.mFluidName.equalsIgnoreCase(this.mFluid.getFluid().getName())) { - this.mFluidName = this.mFluid.getFluid().getName(); - } - } - else { - // Leave Values Blank. - return false; - } - } + @Override + public void onMachineBlockUpdate() { + this.getBaseMetaTileEntity().markDirty(); + super.onMachineBlockUpdate(); + } - if (this.mFluidAmount <= 0) { - if (this.mFluid != null) { - this.mFluidAmount = this.mFluid.amount; - } - } - else { - if (this.mFluid != null) { - if (this.mFluidAmount != this.mFluid.amount) { - this.mFluidAmount = this.mFluid.amount; - } - } - else { - // Leave Values Blank. - return false; - } - } - return true; + @Override + public void onRemoval() { + this.getBaseMetaTileEntity().markDirty(); + super.onRemoval(); } }
\ No newline at end of file |