diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities')
23 files changed, 4634 insertions, 3973 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 56f6a8d4f9..a1093d67d3 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,7 +1,5 @@ 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.*; @@ -10,6 +8,7 @@ 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; @@ -23,516 +22,484 @@ 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(int aID, String aName, String aNameRegional, int aTier) { +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) { super(aID, aName, aNameRegional, aTier, 3, ""); } - public GT_MetaTileEntity_TesseractGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_TesseractGenerator(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TesseractGenerator(mName, mTier, mDescription, mTextures); } - @Override - public boolean isTransformerUpgradable() - { + 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 boolean isOverclockerUpgradable() - { + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { return false; } @Override - public boolean isSimpleMachine() - { + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { return false; } @Override - public boolean isFacingValid(byte aFacing) - { - return true; + 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); } @Override - public boolean isEnetInput() - { + 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); + } return true; } @Override - public boolean isEnetOutput() - { - return false; + 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 isInputFacing(byte aSide) - { + 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); + } return true; } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getBackFacing(); + public boolean canTankBeEmptied() { + return false; } @Override - public boolean isValidSlot(int aIndex) - { + public boolean canTankBeFilled() { return false; } @Override - public long getMinimumStoredEU() - { - return getBaseMetaTileEntity().getEUCapacity() / 2; + 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); } @Override - public long maxEUInput() - { - return 2048; + public boolean displaysItemStack() { + return false; } @Override - public long maxEUOutput() - { - return 0; + public boolean displaysStackSize() { + return false; } @Override - public long maxEUStore() - { - return 100000; + public boolean doesEmptyContainers() { + return false; } + // To-Do? @Override - public long maxSteamStore() - { - return maxEUStore(); + public boolean doesFillContainers() { + return false; } @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) - { - return true; + 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); } @Override - public boolean ownerControl() - { - return true; + 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); } @Override - public int getProgresstime() - { - return (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) && (this.isWorking >= 20) ? 999 : 0; + 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); } @Override - public int maxProgresstime() - { - return 1000; + 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; } @Override - public void saveNBTData(NBTTagCompound aNBT) - { - aNBT.setInteger("mFrequency", this.mFrequency); + public String[] getDescription() { + return new String[] { + "Generates a Tesseract for the attached Inventory" + }; } @Override - public void loadNBTData(NBTTagCompound aNBT) - { - this.mFrequency = aNBT.getInteger("mFrequency"); + 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" + }; } @Override - public void onConfigLoad(GT_Config aConfig) - { - TESSERACT_ENERGY_COST = 1024; - TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; + public String getInventoryName() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + return ""; + } + return tTileEntity.getInventoryName(); } @Override - public void onServerStart() - { - sTesseractGenerators.clear(); + 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 onServerStop() - { - sTesseractGenerators.clear(); - } - @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, ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null) && (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this) ? EnumChatFormatting.RED + " (Occupied)" : "")); - } - return true; + 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; } @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 + ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != null) && (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) != this) ? EnumChatFormatting.RED + " (Occupied)" : "")); - } + public long getMinimumStoredEU() { + return this.getBaseMetaTileEntity().getEUCapacity() / 2; } - public boolean allowCoverOnSide(byte aSide, int aCoverID) - { - return aSide != getBaseMetaTileEntity().getFrontFacing(); + @Override + public int getProgresstime() { + return CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this && this.isWorking >= 20 ? 999 + : 0; } @Override - public String[] getInfoData() - { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IGregTechDeviceInformation)) && (((IGregTechDeviceInformation)tTileEntity).isGivingInformation())) { - return ((IGregTechDeviceInformation)tTileEntity).getInfoData(); + public int getSizeInventory() { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + return 0; } - return new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) && (this.isWorking >= 20) ? "Active" : "Inactive" }; + return tTileEntity.getSizeInventory(); } @Override - public boolean isGivingInformation() - { - return true; + public ItemStack getStackInSlot(final int aIndex) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + return null; + } + return tTileEntity.getStackInSlot(aIndex); } - public boolean isSendingInformation() - { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IGregTechDeviceInformation))) { - return ((IGregTechDeviceInformation)tTileEntity).isGivingInformation(); + @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 false; + return null; } @Override - public boolean isDigitalChest() - { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest)tTileEntity).isDigitalChest(); + 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]; } - return false; + return tTileEntity.getTankInfo(aSide); } @Override - public ItemStack[] getStoredItemData() - { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest)tTileEntity).getStoredItemData(); - } - return null; + 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) + }; } @Override - public void setItemCount(int aCount) - { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { - ((IDigitalChest)tTileEntity).setItemCount(aCount); - } + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; } @Override - public int getMaxItemCount() - { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && ((tTileEntity instanceof IDigitalChest))) { - return ((IDigitalChest)tTileEntity).getMaxItemCount(); - } - return 0; + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; } @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) - { - IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return false; + 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(); } - return tTileEntity.isItemValidForSlot(aIndex, aStack); + return false; } @Override - 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; + public boolean isEnetInput() { + return true; } @Override - 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); - } + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isFacingValid(final byte aFacing) { return true; } @Override - public boolean canExtractItem(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).canExtractItem(aIndex, aStack, aSide); - } + public boolean isGivingInformation() { return true; } @Override - public int getSizeInventory() - { - IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.getSizeInventory(); + public boolean isInputFacing(final byte aSide) { + return true; } @Override - public ItemStack getStackInSlot(int aIndex) - { - IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return null; + public boolean isItemValidForSlot(final int aIndex, final ItemStack aStack) { + final IInventory tTileEntity = this.getBaseMetaTileEntity() + .getIInventoryAtSide(this.getBaseMetaTileEntity().getBackFacing()); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + return false; } - return tTileEntity.getStackInSlot(aIndex); + return tTileEntity.isItemValidForSlot(aIndex, aStack); } @Override - public void setInventorySlotContents(int aIndex, ItemStack aStack) - { - IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return; - } - tTileEntity.setInventorySlotContents(aIndex, aStack); + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); } @Override - public ItemStack decrStackSize(int aIndex, int aAmount) - { - IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return null; + 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(); } - return tTileEntity.decrStackSize(aIndex, aAmount); + return false; } @Override - public String getInventoryName() - { - IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return ""; - } - return tTileEntity.getInventoryName(); + public boolean isSimpleMachine() { + return false; } @Override - public int getInventoryStackLimit() - { - IInventory tTileEntity = getBaseMetaTileEntity().getIInventoryAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.getInventoryStackLimit(); + public boolean isTransformerUpgradable() { + return true; } @Override - 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); + 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); } @Override - 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); + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFrequency = aNBT.getInteger("mFrequency"); } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) - { - IFluidHandler tTileEntity = getBaseMetaTileEntity().getITankContainerAtSide(getBaseMetaTileEntity().getBackFacing()); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return new FluidTankInfo[0]; - } - return tTileEntity.getTankInfo(aSide); + public long maxEUInput() { + return 2048; } @Override - 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); + public long maxEUOutput() { + return 0; } @Override - 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); + public long maxEUStore() { + return 100000; } @Override - 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); + public int maxProgresstime() { + return 1000; } - 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; + @Override + public long maxSteamStore() { + return this.maxEUStore(); } - public boolean isValidTesseractGenerator(String aOwnerName, boolean aWorkIrrelevant) - { - return (getBaseMetaTileEntity() != null) && (!getBaseMetaTileEntity().isInvalidTileEntity()) && (getBaseMetaTileEntity().isAllowedToWork()) && ((aOwnerName == null) || (getBaseMetaTileEntity().getOwnerName().equals(aOwnerName))) && ((aWorkIrrelevant) || (this.isWorking >= 20)); + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + @Override + public void onConfigLoad(final GT_Config aConfig) { + GT_MetaTileEntity_TesseractGenerator.TESSERACT_ENERGY_COST = 1024; + GT_MetaTileEntity_TesseractGenerator.TESSERACT_ENERGY_COST_DIMENSIONAL = 2048; } - public void onPostTick() - { - if (getBaseMetaTileEntity().isServerSide()){ - if (this.mFrequency != this.oFrequency){ - + public void onPostTick() { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mFrequency != this.oFrequency) { + Utils.LOG_INFO("mFreq != oFreq"); - - if (sTesseractGenerators.get(Integer.valueOf(this.oFrequency)) == this) - { - sTesseractGenerators.remove(Integer.valueOf(this.oFrequency)); - getBaseMetaTileEntity().issueBlockUpdate(); + + if (CORE.sTesseractGenerators.get(Integer.valueOf(this.oFrequency)) == this) { + CORE.sTesseractGenerators.remove(Integer.valueOf(this.oFrequency)); + this.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 ((getBaseMetaTileEntity().isAllowedToWork()) && (getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mNeededEnergy, false))) - { + if (this.getBaseMetaTileEntity().isAllowedToWork() + && this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(this.mNeededEnergy, false)) { Utils.LOG_INFO("Can Work & Has Energy"); - if ((sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == null) || (!((GT_MetaTileEntity_TesseractGenerator)sTesseractGenerators.get(Integer.valueOf(this.mFrequency))).isValidTesseractGenerator(null, true))) { + if (CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == null + || !CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) + .isValidTesseractGenerator(null, true)) { Utils.LOG_INFO("storing TE I think to mFreq map?"); - sTesseractGenerators.put(Integer.valueOf(this.mFrequency), this); + CORE.sTesseractGenerators.put(Integer.valueOf(this.mFrequency), this); } } - else - { - if (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) - { + else { + if (CORE.sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) { Utils.LOG_INFO("this gen == mFreq on map - do block update"); - sTesseractGenerators.remove(Integer.valueOf(this.mFrequency)); - getBaseMetaTileEntity().issueBlockUpdate(); + CORE.sTesseractGenerators.remove(Integer.valueOf(this.mFrequency)); + this.getBaseMetaTileEntity().issueBlockUpdate(); } this.isWorking = 0; } - if (sTesseractGenerators.get(Integer.valueOf(this.mFrequency)) == this) - { + if (CORE.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) - { - getBaseMetaTileEntity().issueBlockUpdate(); - this.isWorking = ((byte)(this.isWorking + 1)); + if (this.isWorking == 20) { + this.getBaseMetaTileEntity().issueBlockUpdate(); + this.isWorking = (byte) (this.isWorking + 1); } } - else - { + else { this.isWorking = 0; } this.mNeededEnergy = 0; @@ -540,60 +507,93 @@ extends GT_MetaTileEntity_BasicTank } @Override - public String[] getDescription() - { - return new String[] {"Generates a Tesseract for the attached Inventory"}; - } - - @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 new ITexture[0][0][0]; + 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; } @Override - 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)}; + 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)" : "")); + } } - - //To-Do? @Override - public boolean doesFillContainers() { - return false; + public void onServerStart() { + CORE.sTesseractGenerators.clear(); } - @Override - public boolean doesEmptyContainers() { - return false; + public void onServerStop() { + CORE.sTesseractGenerators.clear(); } @Override - public boolean canTankBeFilled() { - return false; + public boolean ownerControl() { + return true; } @Override - public boolean canTankBeEmptied() { - return false; + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mFrequency", this.mFrequency); } @Override - public boolean displaysItemStack() { - return false; + 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); } @Override - public boolean displaysStackSize() { - return false; + 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); + } } } 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 3544d2a124..9a1a89cf47 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 @@ -19,508 +19,476 @@ 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 int mFrequency = 0; - public boolean mDidWork = false; - public static boolean sInterDimensionalTesseractAllowed = true; - - public GT_MetaTileEntity_TesseractTerminal(int aID, String aName, String aNameRegional, int aTier) { +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) { super(aID, aName, aNameRegional, aTier, 3, ""); } - public GT_MetaTileEntity_TesseractTerminal(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_TesseractTerminal(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TesseractTerminal(mName, mTier, mDescription, mTextures); } - @Override - public boolean isTransformerUpgradable() - { - return false; + public boolean allowCoverOnSide(final byte aSide, final int aCoverID) { + return aSide != this.getBaseMetaTileEntity().getFrontFacing(); } @Override - public boolean isOverclockerUpgradable() - { + public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { return false; } @Override - public boolean isSimpleMachine() - { + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { return false; } @Override - public boolean isFacingValid(byte aFacing) - { - return true; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getBackFacing(); + 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); } @Override - public boolean isValidSlot(int aIndex) - { - return false; - } - - @Override - public long getMinimumStoredEU() - { - return getBaseMetaTileEntity().getEUCapacity() / 2; + 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); } @Override - public long maxEUInput() - { - return 2048; + 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); } @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) - { - return true; - } - - @Override - public long maxEUStore() - { - return 100000; + 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); } @Override - public long maxSteamStore() - { - return maxEUStore(); + public boolean canTankBeEmptied() { + return false; } @Override - public boolean ownerControl() - { - return true; + public boolean canTankBeFilled() { + return false; } @Override - public int getProgresstime() - { - return getTesseract(this.mFrequency, false) != null ? 999 : 0; + 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); } @Override - public int maxProgresstime() - { - return 1000; + public boolean displaysItemStack() { + return false; } @Override - public void saveNBTData(NBTTagCompound aNBT) - { - aNBT.setInteger("mFrequency", this.mFrequency); + public boolean displaysStackSize() { + return false; } @Override - public void loadNBTData(NBTTagCompound aNBT) - { - this.mFrequency = aNBT.getInteger("mFrequency"); + public boolean doesEmptyContainers() { + return false; } + // To-Do? @Override - 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; - }*/ - - @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())); - } - } - - public boolean allowCoverOnSide(byte aSide, int aCoverID) - { - return aSide != getBaseMetaTileEntity().getFrontFacing(); + public boolean doesFillContainers() { + return false; } - 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; - } - if (!rTesseract.isValidTesseractGenerator(getBaseMetaTileEntity().getOwnerName(), aWorkIrrelevant)) { - return null; - } - if ((!sInterDimensionalTesseractAllowed) && (rTesseract.getBaseMetaTileEntity().getWorld() != getBaseMetaTileEntity().getWorld())) { + @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 rTesseract; + return tTileEntity.drain(aSide, aFluid, doDrain); } @Override - public String[] getInfoData() - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity != null) && (getBaseMetaTileEntity().isAllowedToWork()) && (tTileEntity.isSendingInformation())) { - return tTileEntity.getInfoData(); + 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 new String[] { "Tesseract Generator", "Freqency:", "" + this.mFrequency, getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" }; + return tTileEntity.drain(aDirection, maxDrain, doDrain); } @Override - public boolean isGivingInformation() - { - return true; + 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); } @Override - public boolean isDigitalChest() - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return false; + 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.isDigitalChest(); + return tTileEntity.getAccessibleSlotsFromSide(aSide); } + /* + * 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 ItemStack[] getStoredItemData() - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return null; - } - return tTileEntity.getStoredItemData(); + public String[] getDescription() { + return new String[] { + "Accesses Tesseracts remotely" + }; } @Override - public void setItemCount(int aCount) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return; + public String[] getInfoData() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if (tTileEntity != null && this.getBaseMetaTileEntity().isAllowedToWork() + && tTileEntity.isSendingInformation()) { + return tTileEntity.getInfoData(); } - tTileEntity.setItemCount(aCount); + return new String[] { + "Tesseract Generator", "Freqency:", "" + this.mFrequency, + this.getTesseract(this.mFrequency, false) != null ? "Active" : "Inactive" + }; } @Override - public int getMaxItemCount() - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return 0; + public String getInventoryName() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + return ""; } - return tTileEntity.getMaxItemCount(); + return tTileEntity.getInventoryName(); } @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return false; + public int getInventoryStackLimit() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + return 0; } - return tTileEntity.isItemValidForSlot(aIndex, aStack); + return tTileEntity.getInventoryStackLimit(); } @Override - public int[] getAccessibleSlotsFromSide(int aSide) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return new int[0]; + public int getMaxItemCount() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + return 0; } - return tTileEntity.getAccessibleSlotsFromSide(aSide); + return tTileEntity.getMaxItemCount(); } @Override - 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.canInsertItem(aIndex, aStack, aSide); + public long getMinimumStoredEU() { + return this.getBaseMetaTileEntity().getEUCapacity() / 2; } @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 tTileEntity.canExtractItem(aIndex, aStack, aSide); + public int getProgresstime() { + return this.getTesseract(this.mFrequency, false) != null ? 999 : 0; } @Override - public int getSizeInventory() - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + public int getSizeInventory() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { return 0; } return tTileEntity.getSizeInventory(); } @Override - public ItemStack getStackInSlot(int aIndex) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + public ItemStack getStackInSlot(final int aIndex) { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { return null; } return tTileEntity.getStackInSlot(aIndex); } @Override - public void setInventorySlotContents(int aIndex, ItemStack aStack) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return; + public ItemStack[] getStoredItemData() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { + return null; } - tTileEntity.setInventorySlotContents(aIndex, aStack); + return tTileEntity.getStoredItemData(); } @Override - public ItemStack decrStackSize(int aIndex, int aAmount) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + 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]; + } + return tTileEntity.getTankInfo(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; } - return tTileEntity.decrStackSize(aIndex, aAmount); + 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; + } + return rTesseract; } @Override - public String getInventoryName() - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return ""; - } - return tTileEntity.getInventoryName(); + 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) + }; } @Override - public int getInventoryStackLimit() - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return 0; - } - return tTileEntity.getInventoryStackLimit(); + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; } @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return false; - } - return tTileEntity.canFill(aSide, aFluid); + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; } @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { + public boolean isDigitalChest() { + final GT_MetaTileEntity_TesseractGenerator tTileEntity = this.getTesseract(this.mFrequency, false); + if (tTileEntity == null || !this.getBaseMetaTileEntity().isAllowedToWork()) { return false; } - return tTileEntity.canDrain(aSide, aFluid); + return tTileEntity.isDigitalChest(); } @Override - 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); + public boolean isFacingValid(final byte aFacing) { + return true; } @Override - 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); + public boolean isGivingInformation() { + return true; } @Override - public FluidStack drain(ForgeDirection aDirection, int maxDrain, boolean doDrain) - { - GT_MetaTileEntity_TesseractGenerator tTileEntity = getTesseract(this.mFrequency, false); - if ((tTileEntity == null) || (!getBaseMetaTileEntity().isAllowedToWork())) { - return null; + 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()) { + return false; } - return tTileEntity.drain(aDirection, maxDrain, doDrain); + return tTileEntity.isItemValidForSlot(aIndex, aStack); } @Override - 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); + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); } - 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 boolean isOverclockerUpgradable() { + return false; } @Override - public String[] getDescription() - { - return new String[] {"Accesses Tesseracts remotely"}; + public boolean isSimpleMachine() { + return false; } @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean isTransformerUpgradable() { return false; } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public boolean isValidSlot(final int aIndex) { return false; } @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; + public void loadNBTData(final NBTTagCompound aNBT) { + this.mFrequency = aNBT.getInteger("mFrequency"); } @Override - 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)}; + public long maxEUInput() { + return 2048; } - //To-Do? @Override - public boolean doesFillContainers() { - return false; + public long maxEUStore() { + return 100000; } @Override - public boolean doesEmptyContainers() { - return false; + public int maxProgresstime() { + return 1000; } @Override - public boolean canTankBeFilled() { - return false; + public long maxSteamStore() { + return this.maxEUStore(); } @Override - public boolean canTankBeEmptied() { - return false; + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TesseractTerminal(this.mName, this.mTier, this.mDescription, this.mTextures); } @Override - public boolean displaysItemStack() { - return false; + 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(); + } + } } @Override - public boolean displaysStackSize() { - return false; + 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; + } + + @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())); + } + } + + @Override + public boolean ownerControl() { + return true; + } + + @Override + public void saveNBTData(final NBTTagCompound aNBT) { + aNBT.setInteger("mFrequency", this.mFrequency); + } + + @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); + } + + @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); } } 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 c2cadab478..fee44a962e 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,129 +16,164 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -public class GT_MetaTileEntity_Boiler_Solar - extends GT_MetaTileEntity_Boiler { - public GT_MetaTileEntity_Boiler_Solar(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, "Steam Power by the Sun", new ITexture[0]); - } +public class GT_MetaTileEntity_Boiler_Solar extends GT_MetaTileEntity_Boiler { + private int mRunTime = 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 int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, "Steam Power by the Sun", new ITexture[0]); + } - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[4][17][]; - for (byte i = -1; i < 16; i = (byte) (i + 1)) { - ITexture[] tmp0 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; - rTextures[0][(i + 1)] = tmp0; - ITexture[] tmp1 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.BOILER_SOLAR)}; - rTextures[1][(i + 1)] = tmp1; - ITexture[] tmp2 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa))}; - rTextures[2][(i + 1)] = tmp2; - ITexture[] tmp3 = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE, Dyes.getModulation(i, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE)}; - rTextures[3][(i + 1)] = tmp3; - } - return rTextures; - } + public GT_MetaTileEntity_Boiler_Solar(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } - 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 getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); + } - public int maxProgresstime() { - return 500; - } + @Override + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 16000); + } - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_Boiler(aPlayerInventory, aBaseMetaTileEntity, 16000); - } + @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 getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_Boiler(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 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 MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Boiler_Solar(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - private int mRunTime = 0; - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mRunTime", this.mRunTime); - } + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mRunTime = aNBT.getInteger("mRunTime"); + } - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - this.mRunTime = aNBT.getInteger("mRunTime"); - } + @Override + public int maxProgresstime() { + return 500; + } - 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); - } - } + @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); + } }
\ 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 668c8e4018..b05e1cb2a0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityDoubleFuelGeneratorBase.java @@ -13,122 +13,151 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generato import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntityDoubleFuelGeneratorBase - extends GregtechRocketFuelGeneratorBase { - - public int mEfficiency; - - 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(); - } - - public GregtechMetaTileEntityDoubleFuelGeneratorBase(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 GregtechMetaTileEntityDoubleFuelGeneratorBase(this.mName, this.mTier, this.mDescription, this.mTextures); - } +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; + } - @Override - public GT_Recipe.GT_Recipe_Map getRecipes() { - return GT_Recipe.GT_Recipe_Map.sDieselFuels; - } + private GT_RenderedTexture getCasingTexture() { + if (this.mTier <= 4) { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + else if (this.mTier == 5) { - @Override - public int getCapacity() { - return 32000; - } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + else if (this.mTier >= 6) { - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, (100 - this.mTier * 8)); - } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } - @Override + @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)}; - } + 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 + 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); + } } 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 83ce6576c9..6c0df9ea99 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityGeothermalGenerator.java @@ -14,130 +14,158 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntityGeothermalGenerator -extends GT_MetaTileEntity_BasicGenerator -{ +public class GregtechMetaTileEntityGeothermalGenerator extends GT_MetaTileEntity_BasicGenerator { public int mEfficiency; - public GregtechMetaTileEntityGeothermalGenerator(int aID, String aName, String aNameRegional, int aTier) { + public GregtechMetaTileEntityGeothermalGenerator(final int aID, final String aName, final String aNameRegional, + final int aTier) { super(aID, aName, aNameRegional, aTier, "Requires Pahoehoe Lava or Normal Lava as Fuel", new ITexture[0]); - onConfigLoad(); + this.onConfigLoad(); } - public GregtechMetaTileEntityGeothermalGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + public GregtechMetaTileEntityGeothermalGenerator(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } + this.onConfigLoad(); + } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()){ - return true; - } - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } + 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) + }; + } @Override - public int getCapacity() { - //return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); - return 5000*this.mTier; + 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 void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "ThermalGenerator.efficiency.tier." + this.mTier, (100 - this.mTier * 7)); + @Override + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM) + }; } @Override - public int getEfficiency() { - return this.mEfficiency; + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { + super.getBottomActive(aColor)[0], + new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE) + }; } @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; + public int getCapacity() { + // return MathUtils.roundToClosestMultiple(32000*(this.mTier/2), 25000); + return 5000 * this.mTier; } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public String[] getDescription() { + return new String[] { + "Generates power from Lava/Pahoehoe at " + this.getEfficiency() + "% Efficiency per tick" + }; } @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityGeothermalGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + public int getEfficiency() { + return this.mEfficiency; } @Override - 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]}; + 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] + }; } @Override - 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)}; + 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] + }; } @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM)}; + 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 - 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)}; + public int getPollution() { + return 100; } @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT)}; + public GT_Recipe_Map getRecipes() { + return GT_Recipe_Map.sHotFuels; } @Override - 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]}; + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT) + }; } @Override - 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)}; + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE) + }; } @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE)}; + 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) + }; } @Override - 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)}; + 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) + }; } @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE)}; + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); } - @Override - public String[] getDescription() - { - return new String[] {"Generates power from Lava/Pahoehoe at " + getEfficiency() + "% Efficiency per tick"}; + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntityGeothermalGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } - @Override - public GT_Recipe_Map getRecipes() - { - return GT_Recipe_Map.sHotFuels; + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, + "ThermalGenerator.efficiency.tier." + this.mTier, 100 - this.mTier * 7); } - - public int getPollution() { - return 100; + @Override + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; } }
\ 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 74bc6ef5e1..95194a5ecb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -13,122 +13,149 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generato import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntityRocketFuelGenerator - extends GregtechRocketFuelGeneratorBase { - - public int mEfficiency; - - public GregtechMetaTileEntityRocketFuelGenerator(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires liquid Fuels.", new ITexture[0]); - onConfigLoad(); - } - - public GregtechMetaTileEntityRocketFuelGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } - - @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); - } +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; + } - @Override - public GT_Recipe.GT_Recipe_Map getRecipes() { - return GT_Recipe.GT_Recipe_Map.sDieselFuels; - } + private GT_RenderedTexture getCasingTexture() { + if (this.mTier <= 4) { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } + else if (this.mTier == 5) { - @Override - public int getCapacity() { - return 32000; - } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + else if (this.mTier >= 6) { - public void onConfigLoad() { - this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "RocketEngine.efficiency.tier." + this.mTier, (100 - this.mTier * 8)); - } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Ultra); + } + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top); + } - @Override + @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)}; - } + 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 + 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); + } } 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 0bab0ab9d0..50303dbfcd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySolarGenerator.java @@ -1,10 +1,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; -import static gregtech.api.enums.GT_Values.V; - import gregtech.api.GregTech_API; -import gregtech.api.enums.ConfigCategories; -import gregtech.api.enums.Textures; +import gregtech.api.enums.*; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; @@ -17,159 +14,200 @@ import net.minecraft.entity.player.InventoryPlayer; public class GregtechMetaTileEntitySolarGenerator extends GregtechMetaSolarGenerator { - public GregtechMetaTileEntitySolarGenerator(int aID, String aName, String aNameRegional, int aTier) { + 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) { super(aID, aName, aNameRegional, aTier, "Feasts on the power of the Sun!", new ITexture[0]); - onConfigLoad(); + this.onConfigLoad(); } - public GregtechMetaTileEntitySolarGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + public GregtechMetaTileEntitySolarGenerator(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); - onConfigLoad(); + this.onConfigLoad(); } @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { + super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) + }; } @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, 16000); + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { + super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE) + }; } @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { + super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) + }; } @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntitySolarGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); + public ITexture[] getBottomActive(final 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 Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, "SolarBoiler.png", 16000); } @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() - && aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + aBaseMetaTileEntity.getEUCapacity()) { - - if (this.mSolarCharge <= 20) { - //Utils.LOG_WARNING("1."); - this.mSolarCharge = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 45) { - //Utils.LOG_WARNING("2."); - this.mSolarCharge -= 1; - this.mLossTimer = 0; - } - - if (aTick % 10L == 0L) { - - Utils.LOG_WARNING("getUniversalEnergyStored: "+aBaseMetaTileEntity.getUniversalEnergyStored() + " maxEUOutput * 20 + getMinimumStoredEU: " + (maxEUOutput() * 20 + getMinimumStoredEU())); - - if ((this.mSolarCharge > 100) && (aBaseMetaTileEntity.isAllowedToWork()) && - (!aBaseMetaTileEntity.getWorld().isThundering()) && - aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUStore() - getMinimumStoredEU())) { - getBaseMetaTileEntity().increaseStoredEnergyUnits(sEnergyPerTick * getEfficiency(), true); - } - } - - if ((this.mSolarCharge < 500) && (this.mProcessingEnergy != 0) && (aTick % 32L == 0L)) { - Utils.LOG_WARNING("Adding Solar Charge. Currently "+mSolarCharge); - this.mProcessingEnergy -= 1; - this.mSolarCharge += 1; - } - - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 64L == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { - Utils.LOG_WARNING("Adding Processing Energy. Currently "+mProcessingEnergy); - boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && aBaseMetaTileEntity.getBiome().rainfall > 0.0F; - mProcessingEnergy += bRain && aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4 || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 : 1; - } - - if (aBaseMetaTileEntity.isServerSide()){ - //Utils.LOG_WARNING("6."); - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); - } - } + public int getEfficiency() { + return this.mEfficiency; } @Override - public void inValidate() { - + 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] + }; } @Override - public int getEfficiency() { - return this.mEfficiency; + 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] + }; } @Override - public long maxEUStore() { - return Math.max(getEUVar(), V[mTier] * 16000 + getMinimumStoredEU()); + public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_SolarGenerator(aPlayerInventory, aBaseMetaTileEntity, 16000); } - - ITexture SolarArray[] = {new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_8V), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_MV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_HV), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_EV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_IV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_LuV), - new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_ZPM), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL_UV), new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { + super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC) + }; } @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { + super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE) + }; } @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { + super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL) + }; } @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { + super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL) + }; } @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC)}; + public void inValidate() { + } @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE), - Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier]}; + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); } @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + public long maxEUStore() { + return Math.max(this.getEUVar(), GT_Values.V[this.mTier] * 16000 + this.getMinimumStoredEU()); } @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntitySolarGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.SOLARPANEL)}; + public void onConfigLoad() { + this.mEfficiency = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, + "SunAbsorber.efficiency.tier." + this.mTier, 100 - this.mTier * 10); + } @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE)}; + 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()); + } + } } }
\ 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 5d1befbbad..be4a51a02f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntitySuperCondensor.java @@ -8,97 +8,129 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GregtechMetaSuperConductorNodeBase; -public class GregtechMetaTileEntitySuperCondensor - extends GregtechMetaSuperConductorNodeBase { - - public int mEfficiency; - - public GregtechMetaTileEntitySuperCondensor(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires liquid Nitrogen/Helium", new ITexture[0]); - onConfigLoad(); - } - - public GregtechMetaTileEntitySuperCondensor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } - - @Override - public boolean isOutputFacing(byte aSide) { - return aSide == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntitySuperCondensor(this.mName, this.mTier, this.mDescription, this.mTextures); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipes() { - return GT_Recipe.GT_Recipe_Map.sDieselFuels; - } - - @Override +public 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 int getCapacity() { - return 64000; - } + return 64000; + } - public void onConfigLoad() { - this.mEfficiency = 100; - } - - @Override + @Override public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[]{super.getFront(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[]{super.getBack(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[]{super.getBottom(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[]{super.getTop(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP)}; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[]{super.getSides(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[]{super.getFrontActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[]{super.getBackActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[]{super.getBottomActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[]{super.getTopActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE)}; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[]{super.getSidesActive(aColor)[0], new GT_RenderedTexture(Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR), Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]}; - } + 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; + } } 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 8dbdfce45b..9df0d03a1b 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,7 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; -import static gregtech.api.enums.GT_Values.V; - +import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -14,117 +13,141 @@ import net.minecraft.nbt.NBTTagCompound; public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredMachineBlock { - 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) { - } + 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) { + } } 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 898fab830f..f478be73d6 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 @@ -25,172 +25,97 @@ import net.minecraftforge.fluids.FluidStack; 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 int recipeCounter = 0; - private static Block IC2Glass = Block.getBlockFromItem(ItemUtils.getItem("IC2:blockAlloyGlass")); - //public FluidStack mFluidOut = Materials.UUMatter.getFluid(1L); + 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 GregtechMTE_NuclearReactor(int aID, String aName, String aNameRegional) { + public GregtechMTE_NuclearReactor(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMTE_NuclearReactor(String aName) { + public GregtechMTE_NuclearReactor(final String aName) { super(aName); } @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Nuclear Reactor", - "Produces heat from Radioactive beta decay.", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", - "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", - "1x Input Hatch (Any bottom layer casing)", - "1x Output Hatch (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", - "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", - "1x Energy Hatch (Any bottom layer casing)", - "24x IC2 Reinforced Glass for the walls", - "Matter Fabricator Casings for the edges & top (40 at least!)", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66], - new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[66]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MatterFabricator.png"); - } - - @Override - public void onConfigLoad(GT_Config aConfig) { - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList<FluidStack> tFluidList = getStoredFluids(); - for (int i = 0; i < tFluidList.size() - 1; i++) { - for (int j = i + 1; j < tFluidList.size(); j++) { - if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { - tFluidList.remove(j--); - } else { - tFluidList.remove(i--); - break; - } - } - } - } - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tFluidList.size()]), 0, tFluidList.size()); - if (tFluids.length > 0) { - for(int i = 0;i<tFluids.length;i++){ - GT_Recipe tRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tFluids[i]}, new ItemStack[]{}); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[]{})) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = ((tRecipe.mDuration/**sDurationMultiplier*/) / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = (tRecipe.mDuration/**sDurationMultiplier*/); - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - this.mOutputFluids = tRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(mOutputFluids); - recipeCounter++; - updateSlots(); - //Utils.LOG_INFO("Recipes Finished: "+recipeCounter); - return true; - } - } - else { - Utils.LOG_INFO("Invalid Recipe"); - } - } - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + 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 < 4; i++) { for (int j = -3; j < 4; j++) { for (int h = 0; h < 4; h++) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + final 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 ((!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."); + 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( + "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("Matter Fabricator 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("Matter Fabricator 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("Matter Fabricator 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) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second 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 second layer."); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 12) { - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the corners in the second layer."); + 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; } @@ -201,19 +126,23 @@ 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("Matter Fabricator 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("Matter Fabricator 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; } @@ -224,12 +153,15 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } } 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."); + 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("Matter Fabricator 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; } } @@ -244,38 +176,143 @@ public class GregtechMTE_NuclearReactor extends GT_MetaTileEntity_MultiBlockBase } @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; + 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 int getMaxEfficiency(ItemStack aStack) { - return 10000; + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } + + @Override + public int getAmountOfOutputs() { + return 1; } @Override - public int getPollutionPerTick(ItemStack aStack) { + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); + } + + @Override + public int getDamageToComponent(final ItemStack aStack) { return 0; } @Override - public int getDamageToComponent(ItemStack aStack) { + 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 int getMaxEfficiency(final ItemStack aStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(final ItemStack aStack) { return 0; } @Override - public int getAmountOfOutputs() { - return 1; + 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] + }; } @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + public IMetaTileEntity newMetaEntity(final 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 811e049a8b..2d9512ce2f 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 @@ -18,212 +18,234 @@ 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(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 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 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 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 + 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 public GT_Recipe.GT_Recipe_Map getRecipeMap() { - 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; - } + 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); + } } 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 db9eb17093..db857a782d 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 @@ -27,99 +27,131 @@ 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; +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(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - frontFaceActive = new GT_RenderedTexture(GT9_5_Active); - frontFace = new GT_RenderedTexture(GT9_5); - } + ArrayList<ItemStack> tInputList = this.getStoredInputs(); - public GregtechMetaTileEntity_IndustrialCentrifuge(String aName) { - super(aName); - } + GT_Recipe mLastRecipe; - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCentrifuge(this.mName); + public GregtechMetaTileEntity_IndustrialCentrifuge(final int aID, final String aName, final 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); } - @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}; + public GregtechMetaTileEntity_IndustrialCentrifuge(final String aName) { + super(aName); } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? frontFaceActive : frontFace : Textures.BlockIcons.CASING_BLOCKS[57]}; - } - - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialCentrifuge.png"); - } + 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"); + } + } - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; - } + 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 boolean isFacingValid(byte aFacing) { - return aFacing > 1; + } + } + } + } + } + return tAmount >= 16; } - ArrayList<ItemStack> tInputList = getStoredInputs(); - GT_Recipe mLastRecipe; - @Override - public boolean checkRecipe(ItemStack aStack) { - /*if (!isCorrectMachinePart(mInventory[1])) { - return false; - }*/ + public boolean checkRecipe(final ItemStack aStack) { + /* + * if (!isCorrectMachinePart(mInventory[1])) { return false; } + */ Utils.LOG_WARNING("Centrifuge Debug - 1"); - GT_Recipe.GT_Recipe_Map map = getRecipeMap(); + final GT_Recipe.GT_Recipe_Map map = this.getRecipeMap(); if (map == null) { Utils.LOG_WARNING("Centrifuge Debug - False - No recipe map"); return false; } Utils.LOG_WARNING("Centrifuge Debug - 2"); - ArrayList<ItemStack> tInputList = getStoredInputs(); - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - Utils.LOG_WARNING("Centrifuge Debug - Tier variable: "+tTier); - ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); - ArrayList<FluidStack> tFluidList = getStoredFluids(); - FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); + 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()]); if (tInputList.size() > 0 || tFluids.length > 0) { - GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + final GT_Recipe tRecipe = map.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); if (tRecipe != null) { Utils.LOG_WARNING("Recipe was not invalid"); - mLastRecipe = tRecipe; + this.mLastRecipe = tRecipe; this.mEUt = 0; this.mOutputItems = null; this.mOutputFluids = null; @@ -130,29 +162,34 @@ extends GregtechMeta_MultiBlockBase { } this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiency = 10000 - (this.getIdealStatus() - this.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++) { @@ -160,30 +197,34 @@ extends GregtechMeta_MultiBlockBase { 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 (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) { tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; + } } } } if (tFOut != null) { - int tSize = tFOut.amount; + final 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); - List<ItemStack> overStacks = new ArrayList<ItemStack>(); + Utils.LOG_WARNING( + "Centrifuge Debug - 6 - Max Progress Time: " + this.mMaxProgresstime + " EU/t" + this.mEUt); + final List<ItemStack> overStacks = new ArrayList<ItemStack>(); for (int f = 0; f < tOut.length; f++) { if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - ItemStack tmp = tOut[f].copy(); + final ItemStack tmp = tOut[f].copy(); tmp.stackSize = tmp.getMaxStackSize(); tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); overStacks.add(tmp); @@ -195,14 +236,18 @@ extends GregtechMeta_MultiBlockBase { tmp = overStacks.toArray(tmp); tOut = ArrayUtils.addAll(tOut, tmp); } - List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (ItemStack tS : tOut) { - if (tS.stackSize > 0) tSList.add(tS); + final List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (final ItemStack tS : tOut) { + if (tS.stackSize > 0) { + tSList.add(tS); + } } tOut = tSList.toArray(new ItemStack[tSList.size()]); this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[]{tFOut}; - updateSlots(); + this.mOutputFluids = new FluidStack[] { + tFOut + }; + this.updateSlots(); Utils.LOG_WARNING("Centrifuge: True"); return true; } @@ -211,11 +256,20 @@ extends GregtechMeta_MultiBlockBase { 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; @@ -227,89 +281,66 @@ extends GregtechMeta_MultiBlockBase { } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - /*if (configSwitches.disableCentrifugeFormation){ - EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(this.getBaseMetaTileEntity().getOwnerName()); - if (!player.getEntityWorld().isRemote && isDisabled == false) - 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; + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), + "IndustrialCentrifuge.png"); } - @SuppressWarnings("static-method") - public boolean ignoreController(Block tTileEntity) { - if (!controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; - } - return false; + @Override + public String[] getDescription() { + return new String[] { + "Controller Block for the Industrial Centrifuge", "Size: 3x3x3 (Hollow)", + "Controller (Front Center) [Orange]", "1x Maintenance Hatch (Rear Center) [Green]", + "The rest can be placed anywhere except the Front [Red]", "1x Input Hatch", "1x Output Hatch", + "1x Input Bus", "1x Output Bus", "1x [EV] Energy Hatch (Can be higher Tier) [Blue]", + "Centrifuge Casings for the rest (16 at least)", CORE.GT_Tooltip + }; } @Override - public int getMaxEfficiency(ItemStack aStack) { + public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(ItemStack aStack) { + public int getPollutionPerTick(final ItemStack aStack) { return 0; } @Override - public int getAmountOfOutputs() { - return 1; + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes; } @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { + 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; + } 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 0c579c6bf0..5d0ceb53e8 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,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; - import java.util.ArrayList; import java.util.Arrays; @@ -16,261 +14,271 @@ 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 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 class GregtechMetaTileEntity_IndustrialCokeOven extends GregtechMeta_MultiBlockBase { + private int mLevel = 0; - public GregtechMetaTileEntity_IndustrialCokeOven(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } + public GregtechMetaTileEntity_IndustrialCokeOven(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional); + } - public GregtechMetaTileEntity_IndustrialCokeOven(String aName) { - super(aName); - } + public GregtechMetaTileEntity_IndustrialCokeOven(final String aName) { + super(aName); + } - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); - } + @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); - @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 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 ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_MULTI_SMELTER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+1]}; - } + @Override + public 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 Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "CokeOven.png"); - } + 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 GT_Recipe.GT_Recipe_Map getRecipeMap() { - return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; - - } + 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 = 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 boolean isCorrectMachinePart(ItemStack aStack) { - return true; - }*/ + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } + @Override + public int getAmountOfOutputs() { + return 24; + } - @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 Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "CokeOven.png"); + } - 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 boolean isCorrectMachinePart(ItemStack aStack) { return + * true; } + */ - 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 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 + }; + } - 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 getMaxEfficiency(final ItemStack aStack) { + return 10000; + } - @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 int getPollutionPerTick(final ItemStack aStack) { + return 0; + } - 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 GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sCokeOvenRecipes; - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } + } - @Override - 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[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 getDamageToComponent(ItemStack aStack) { - return 0; - }*/ + /* + * @Override public int getDamageToComponent(ItemStack aStack) { return 0; } + */ - @Override - public int getAmountOfOutputs() { - return 24; - } + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialCokeOven(this.mName); + } } 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 07087123cf..16920395f7 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,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; - import java.util.*; import org.apache.commons.lang3.ArrayUtils; @@ -19,153 +17,154 @@ 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 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 { - public GregtechMetaTileEntity_IndustrialElectrolyzer(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } +public class GregtechMetaTileEntity_IndustrialElectrolyzer extends GregtechMeta_MultiBlockBase { + ArrayList<ItemStack> tInputList = this.getStoredInputs(); - public GregtechMetaTileEntity_IndustrialElectrolyzer(String aName) { - super(aName); - } + GT_Recipe mLastRecipe; - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialElectrolyzer(this.mName); + public GregtechMetaTileEntity_IndustrialElectrolyzer(final int aID, final String aName, + final String aNameRegional) { + super(aID, aName, aNameRegional); } - @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 GregtechMetaTileEntity_IndustrialElectrolyzer(final String aName) { + super(aName); } @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)}; + 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; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+5]}; + 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; } @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "IndustrialElectrolyzer.png"); - } + 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); - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; - } + 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 boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - ArrayList<ItemStack> tInputList = getStoredInputs(); - GT_Recipe mLastRecipe; + final int tValidOutputSlots = this.getValidOutputSlots(this.getRecipeMap(), tInputs); + Utils.LOG_WARNING("Valid Output Slots: " + tValidOutputSlots); - @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 + // 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]; + 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); + + 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 (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) { tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; + } } } } if (tFOut != null) { - int tSize = tFOut.amount; + final int tSize = tFOut.amount; tFOut.amount = tSize * 1; } - - List<ItemStack> overStacks = new ArrayList<ItemStack>(); + + final List<ItemStack> overStacks = new ArrayList<ItemStack>(); for (int f = 0; f < tOut.length; f++) { if (tOut[f].getMaxStackSize() < tOut[f].stackSize) { while (tOut[f].getMaxStackSize() < tOut[f].stackSize) { - ItemStack tmp = tOut[f].copy(); + final ItemStack tmp = tOut[f].copy(); tmp.stackSize = tmp.getMaxStackSize(); tOut[f].stackSize = tOut[f].stackSize - tOut[f].getMaxStackSize(); overStacks.add(tmp); @@ -177,76 +176,100 @@ extends GregtechMeta_MultiBlockBase { tmp = overStacks.toArray(tmp); tOut = ArrayUtils.addAll(tOut, tmp); } - List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (ItemStack tS : tOut) { - if (tS.stackSize > 0) tSList.add(tS); + final List<ItemStack> tSList = new ArrayList<ItemStack>(); + for (final ItemStack tS : tOut) { + if (tS.stackSize > 0) { + tSList.add(tS); + } } tOut = tSList.toArray(new ItemStack[tSList.size()]); this.mOutputItems = tOut; - this.mOutputFluids = new FluidStack[]{tFOut}; - updateSlots(); - - /* this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)}; - updateSlots();*/ - return true; - } - } - return false; - } + this.mOutputFluids = new FluidStack[] { + tFOut + }; + this.updateSlots(); + + /* + * this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), + * tRecipe.getOutput(1)}; updateSlots(); + */ + return true; + } + } + return false; + } @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } - } + public boolean explodesOnComponentBreak(final 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; - 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; - } + public int getAmountOfOutputs() { + return 1; + } @Override - public int getMaxEfficiency(ItemStack aStack) { + 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 + }; + } + + @Override + public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(ItemStack aStack) { + public int getPollutionPerTick(final ItemStack aStack) { return 0; } @Override - public int getAmountOfOutputs() { - return 1; + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes; } @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; + 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); + } + + @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); + } } } 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 0a50b94976..787aa61856 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 @@ -22,172 +22,47 @@ 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(int aID, String aName, String aNameRegional) { + public GregtechMetaTileEntity_IndustrialMacerator(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialMacerator(String aName) { + public GregtechMetaTileEntity_IndustrialMacerator(final String aName) { super(aName); } @Override - 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; + 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, 1, zDir)) { return false; } int tAmount = 0; - controller = false; + GregtechMetaTileEntity_IndustrialMacerator.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))) { - 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) { + 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) { Utils.LOG_INFO("Returned False 1"); return false; } @@ -205,17 +80,18 @@ extends GregtechMeta_MultiBlockBase { Utils.LOG_INFO("Returned False 3"); return false; } - int height = this.getBaseMetaTileEntity().getYCoord(); + final 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; } - GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; + final GT_MetaTileEntity_Hatch_OutputBus[] tmpHatches = new GT_MetaTileEntity_Hatch_OutputBus[5]; for (int i = 0; i < this.mOutputBusses.size(); i++) { - int hatchNumber = this.mOutputBusses.get(i).getBaseMetaTileEntity().getYCoord() - 1 - height; + final 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; } @@ -227,35 +103,181 @@ extends GregtechMeta_MultiBlockBase { return tAmount >= 26; } - public boolean ignoreController(Block tTileEntity) { - if (!controller && tTileEntity == GregTech_API.sBlockMachines) { - return true; + @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; + } + } + return false; + } + + @Override + public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @Override - public int getMaxEfficiency(ItemStack aStack) { + 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) { return 10000; } @Override - public int getPollutionPerTick(ItemStack aStack) { + public int getPollutionPerTick(final ItemStack aStack) { return 0; } @Override - public int getAmountOfOutputs() { - return 16; + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; } @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { + 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; + } 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 68254a880f..ee15dcd83c 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,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import static gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks.GTID; - import java.util.ArrayList; import java.util.Arrays; @@ -18,182 +16,200 @@ 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 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(int aID, String aName, String aNameRegional) { +public class GregtechMetaTileEntity_IndustrialPlatePress extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialPlatePress(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialPlatePress(String aName) { + public GregtechMetaTileEntity_IndustrialPlatePress(final String aName) { super(aName); } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); + 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; } @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 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; } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER)}; - } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GTID+4]}; + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; } @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MaterialPress.png"); + public int getAmountOfOutputs() { + return 1; } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sBenderRecipes; + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MaterialPress.png"); } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + 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 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 getMaxEfficiency(final ItemStack aStack) { + return 10000; + } @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(5)), 10, 1.0F, aX, aY, aZ); - } - } + 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; - 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; - } + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sBenderRecipes; + } @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; + 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] + }; } @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; } @Override - public int getAmountOfOutputs() { - return 1; + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialPlatePress(this.mName); } @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; + 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); + } } } 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 3e964bdb28..dadb82388d 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 @@ -19,159 +19,111 @@ 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(int aID, String aName, String aNameRegional) { + + public GregtechMetaTileEntity_IndustrialSinter(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialSinter(String aName) { + public GregtechMetaTileEntity_IndustrialSinter(final String aName) { super(aName); } - @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"); + private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { + return this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()); } - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sWiremillRecipes; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList<ItemStack> tInputList = getStoredInputs(); - for (ItemStack tInput : tInputList) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sWiremillRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], null, new ItemStack[]{tInput}); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, null, new ItemStack[]{tInput})) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1)); - } else { - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = (-this.mEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0)}; - updateSlots(); - return true; - } - } - } - return false; + 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 checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int controllerX = aBaseMetaTileEntity.getXCoord(); - int controllerY = aBaseMetaTileEntity.getYCoord(); - int controllerZ = aBaseMetaTileEntity.getZCoord(); + public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + final int controllerX = aBaseMetaTileEntity.getXCoord(); + final int controllerY = aBaseMetaTileEntity.getYCoord(); + final int controllerZ = aBaseMetaTileEntity.getZCoord(); - byte tSide = getBaseMetaTileEntity().getBackFacing(); - if ((getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1)) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2) && (getBaseMetaTileEntity().getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) { + 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)) { int tAirCount = 0; for (byte i = -1; i < 2; i = (byte) (i + 1)) { for (byte j = -1; j < 2; j = (byte) (j + 1)) { for (byte k = -1; k < 2; k = (byte) (k + 1)) { - if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { - Utils.LOG_INFO("Found Air at: "+(controllerX+i)+" "+(controllerY+k)+" "+(controllerZ+k)); - //if (aBaseMetaTileEntity.getWorld().isRemote){ - //asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, (controllerX+i), (controllerY+k), (controllerZ+k)); - //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.YELLOW_GREEN); - //} + 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); + // } 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 = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && - (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && - ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialSinter))) { - //Utils.LOG_INFO("False 1"); + 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"); return false; } } - int tX = getBaseMetaTileEntity().getXCoord(); - int tY = getBaseMetaTileEntity().getYCoord(); - int tZ = getBaseMetaTileEntity().getZCoord(); + final int tX = this.getBaseMetaTileEntity().getXCoord(); + final int tY = this.getBaseMetaTileEntity().getYCoord(); + final int tZ = this.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 (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))))) { + // 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)))) { Utils.LOG_INFO("False 2"); return false; } - } - else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { - } + } + else 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 { Utils.LOG_INFO("False 3"); return false; @@ -187,14 +139,17 @@ extends GT_MetaTileEntity_MultiBlockBase { if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { Utils.LOG_INFO("Incorrect amount of Input & Output busses."); return false; - } + } this.mMaintenanceHatches.clear(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if (tTileEntity != null && tTileEntity.getMetaTileEntity() != null) { + if (tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance) { this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - } else { + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this + .getCasingTextureIndex(); + } + else { Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); return false; } @@ -203,7 +158,8 @@ extends GT_MetaTileEntity_MultiBlockBase { Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); return false; } - } else { + } + else { Utils.LOG_INFO("False 5"); return false; } @@ -212,18 +168,52 @@ extends GT_MetaTileEntity_MultiBlockBase { } @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } + 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)); - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; + 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 getDamageToComponent(ItemStack aStack) { - return 0; + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; } @Override @@ -231,30 +221,81 @@ extends GT_MetaTileEntity_MultiBlockBase { return 1; } - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } - public byte getCasingMeta() { return 6; } - public byte getCasingTextureIndex() { return 63; } - private boolean addToMachineList(IGregTechTileEntity tTileEntity) { - return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + @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 addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { - return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); + @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; + } + + @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); } } 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 5ee5c0d787..f9a633bff5 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 @@ -20,110 +20,38 @@ 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(int aID, String aName, String aNameRegional) { +public class GregtechMetaTileEntity_IndustrialWireMill extends GregtechMeta_MultiBlockBase { + public GregtechMetaTileEntity_IndustrialWireMill(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_IndustrialWireMill(String aName) { + public GregtechMetaTileEntity_IndustrialWireMill(final String aName) { super(aName); } - @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 - }; + private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { + return this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()); } - @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"); + 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 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)))) { + 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)) { int tAirCount = 0; for (byte i = -1; i < 2; i = (byte) (i + 1)) { for (byte j = -1; j < 2; j = (byte) (j + 1)) { for (byte k = -1; k < 2; k = (byte) (k + 1)) { - if (getBaseMetaTileEntity().getAirOffset(i, j, k)) { + if (this.getBaseMetaTileEntity().getAirOffset(i, j, k)) { tAirCount++; } } @@ -135,30 +63,44 @@ extends GregtechMeta_MultiBlockBase { } for (byte i = 2; i < 6; i = (byte) (i + 1)) { IGregTechTileEntity tTileEntity; - if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && - (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && - ((tTileEntity.getMetaTileEntity() instanceof GregtechMetaTileEntity_IndustrialWireMill))) { - //Utils.LOG_INFO("False 1"); + 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"); return false; } } - int tX = getBaseMetaTileEntity().getXCoord(); - int tY = getBaseMetaTileEntity().getYCoord(); - int tZ = getBaseMetaTileEntity().getZCoord(); + final int tX = this.getBaseMetaTileEntity().getXCoord(); + final int tY = this.getBaseMetaTileEntity().getYCoord(); + final int tZ = this.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 (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))))) { + 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)))) { Utils.LOG_INFO("False 2"); return false; } - } - else if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { - } + } + else 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 { Utils.LOG_INFO("False 3"); return false; @@ -174,14 +116,17 @@ extends GregtechMeta_MultiBlockBase { if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) { Utils.LOG_INFO("Incorrect amount of Input & Output busses."); return false; - } + } this.mMaintenanceHatches.clear(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { + final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if (tTileEntity != null && tTileEntity.getMetaTileEntity() != null) { + if (tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance) { this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = getCasingTextureIndex(); - } else { + ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this + .getCasingTextureIndex(); + } + else { Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back."); return false; } @@ -190,7 +135,8 @@ extends GregtechMeta_MultiBlockBase { Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches."); return false; } - } else { + } + else { Utils.LOG_INFO("False 5"); return false; } @@ -199,13 +145,61 @@ extends GregtechMeta_MultiBlockBase { } @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; + 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; } @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; } @Override @@ -213,30 +207,71 @@ extends GregtechMeta_MultiBlockBase { return 1; } - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } - public byte getCasingMeta() { return 6; } - public byte getCasingTextureIndex() { return 63; } - private boolean addToMachineList(IGregTechTileEntity tTileEntity) { - return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex()))); + @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 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; } - - private boolean addEnergyInputToMachineList(IGregTechTileEntity tTileEntity) { - return ((addEnergyInputToMachineList(tTileEntity, getCasingTextureIndex()))); + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IndustrialWireMill(this.mName); } } 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 aa7aecc8c5..1ae8e60885 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,358 +23,460 @@ 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(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, 4); - } - - public GregtechMetaTileEntity_IronBlastFurnace(String aName) { - super(aName, 4); - } - - @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(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 String[] getDescription() { - return new String[]{"Sloooowly, Skip the Bronze age, Get some Steel!", - "Multiblock: 3x3x5 hollow with opening on top", - "40 Iron Plated Bricks required", - "----", - "Even though Iron melts hotter than bronze,", - "this machine is to help players skip looking", - "for tin and copper, which are not as common", - "as Iron is. This machine takes 5x longer than the bronze", - "blast furnace as a result.", - "----", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return aActive ? FACING_ACTIVE : FACING_FRONT; - } - return FACING_SIDE; - } - - @Override - public boolean isSteampowered() { - return false; - } + 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 boolean isElectric() { - return false; - } + @Override + public int increaseProgress(final int aProgress) { + this.mProgresstime += aProgress; + return this.mMaxProgresstime - this.mProgresstime; + } - @Override - public boolean isPneumatic() { - return false; - } + @Override + public boolean isAccessAllowed(final EntityPlayer aPlayer) { + return true; + } - @Override + @Override + public boolean isElectric() { + return false; + } + + @Override public boolean isEnetInput() { - return false; - } + return false; + } - @Override + @Override public boolean isEnetOutput() { - return false; - } + return false; + } - @Override - public boolean isInputFacing(byte aSide) { - return false; - } + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } - @Override - public boolean isOutputFacing(byte aSide) { - return false; - } + @Override + public boolean isGivingInformation() { + return false; + } - @Override - public boolean isTeleporterCompatible() { - return false; - } + @Override + public boolean isInputFacing(final byte aSide) { + return false; + } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } + @Override + public boolean isOutputFacing(final byte aSide) { + return false; + } - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } + @Override + public boolean isPneumatic() { + return false; + } - @Override - public int getProgresstime() { - return this.mProgresstime; - } + @Override + public boolean isSteampowered() { + return false; + } - @Override + @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 public int maxProgresstime() { - return this.mMaxProgresstime; - } - - @Override - public int increaseProgress(int aProgress) { - this.mProgresstime += aProgress; - return this.mMaxProgresstime - this.mProgresstime; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new 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 + return this.mMaxProgresstime; + } + + @Override + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); + } + + @Override public void onMachineBlockUpdate() { - this.mUpdate = 30; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if ((aBaseMetaTileEntity.isClientSide()) && - (aBaseMetaTileEntity.isActive())) { - aBaseMetaTileEntity.getWorld().spawnParticle("cloud", aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), 0.0D, 0.3D, 0.0D); - } - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate-- == 0) { - this.mMachine = checkMachine(); - } - if (this.mMachine) { - if (this.mMaxProgresstime > 0) { - if (++this.mProgresstime >= this.mMaxProgresstime) { - addOutputProducts(); - this.mOutputItem1 = null; - this.mOutputItem2 = null; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - try { - // GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "steel"); - } catch (Exception e) { - } - } - } else if (aBaseMetaTileEntity.isAllowedToWork()) { - checkRecipe(); - } - } - aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); - if (aBaseMetaTileEntity.isActive()) { - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getAir(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.lava, 1, 2); - this.mUpdate = 1; - } - } else { - if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), aBaseMetaTileEntity.getYCoord() + 1, aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), Blocks.air, 0, 2); - this.mUpdate = 1; - } - } - } - } - - private void addOutputProducts() { - if (this.mOutputItem1 != null) { - if (this.mInventory[2] == null) { - this.mInventory[2] = GT_Utility.copy(new Object[]{this.mOutputItem1}); - } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { - this.mInventory[2].stackSize = Math.min(this.mOutputItem1.getMaxStackSize(), this.mOutputItem1.stackSize + this.mInventory[2].stackSize); - } - } - if (this.mOutputItem2 != null) { - if (this.mInventory[3] == null) { - this.mInventory[3] = GT_Utility.copy(new Object[]{this.mOutputItem2}); - } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { - this.mInventory[3].stackSize = Math.min(this.mOutputItem2.getMaxStackSize(), this.mOutputItem2.stackSize + this.mInventory[3].stackSize); - } - } - } - - private boolean spaceForOutput(ItemStack aStack1, ItemStack aStack2) { - if (((this.mInventory[2] == null) || (aStack1 == null) || ((this.mInventory[2].stackSize + aStack1.stackSize <= this.mInventory[2].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) && ( - (this.mInventory[3] == null) || (aStack2 == null) || ((this.mInventory[3].stackSize + aStack2.stackSize <= this.mInventory[3].getMaxStackSize()) && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { - return true; - } - return false; - } - - private boolean checkRecipe() { - if (!this.mMachine) { - return false; - } - if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = 36000; - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = 4800*5; - return true; - } - if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 9); - getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = 64800*5; - return true; - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = 3600*5; - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 1) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 1*3); - this.mMaxProgresstime = 2400*5; - return true; - } - if ((this.mInventory[0].stackSize >= 9) && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 2) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { - getBaseMetaTileEntity().decrStackSize(0, 9); - getBaseMetaTileEntity().decrStackSize(1, 2*3); - this.mMaxProgresstime = 32400*5; - return true; - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 64); - this.mMaxProgresstime = 64800*9; - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) && (this.mInventory[1].stackSize >= 18) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 18*3); - this.mMaxProgresstime = 43200*5; - return true; - } - if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) && (this.mInventory[1].stackSize >= 4) && (spaceForOutput(this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - getBaseMetaTileEntity().decrStackSize(0, 1); - getBaseMetaTileEntity().decrStackSize(1, 4*3); - this.mMaxProgresstime = 64800*5; - return true; - } - } - } - this.mOutputItem1 = null; - this.mOutputItem2 = null; - return false; - } - - @Override - public boolean isGivingInformation() { - return false; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex > 1; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aIndex < 2) { - } - return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); - } - - @Override - public byte getTileEntityBaseType() { - return 0; - } + 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; + } } 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 b69fd8f8e1..42ded10622 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 @@ -28,110 +28,212 @@ import net.minecraftforge.fluids.FluidStack; 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 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; - } - - public int getMatterProduced(){ - return mMatterProduced; - } - - public GregtechMetaTileEntity_MassFabricator(int aID, String aName, String aNameRegional) { + 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")); + + ItemStack scrapBox = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + FluidStack tempFake = FluidUtils.getFluidStack("uuamplifier", 1); + GT_Recipe fakeRecipe; + + public GregtechMetaTileEntity_MassFabricator(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_MassFabricator(String aName) { + public GregtechMetaTileEntity_MassFabricator(final String aName) { super(aName); } @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Matter Fabricator", - "Produces UU-Matter from UU-Amplifier", - "Size(WxHxD): 5x4x5, Controller (Bottom center)", - "3x1x3 Matter Generation Coils (Inside bottom 5x1x5 layer)", - "9x Matter Generation Coils (Centered 3x1x3 area in Bottom layer)", - "1x Input Hatch (Any bottom layer casing)", - "1x Output Hatch (Any bottom layer casing)", - "1x Maintenance Hatch (Any bottom layer casing)", - "1x Muffler Hatch (Centered 3x1x3 area in Top layer)", - "1x Energy Hatch (Any bottom layer casing)", - "24x IC2 Reinforced Glass for the walls", - "Matter Fabricator Casings for the edges & top (40 at least!)", - CORE.GT_Tooltip}; - } + 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++) { - @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]}; - } + // 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) { - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, 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 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); + 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; + } + } + + 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 boolean checkRecipe(ItemStack aStack) { + public boolean checkRecipe(final ItemStack aStack) { Utils.LOG_INFO("Fabricating Matter."); - if (mInputHatches.size() != 1){ - Utils.LOG_INFO("Too many input hatches. Found: "+mInputHatches.size()+" | Expected: 1"); + if (this.mInputHatches.size() != 1) { + Utils.LOG_INFO("Too many input hatches. Found: " + this.mInputHatches.size() + " | Expected: 1"); return false; } - ArrayList<ItemStack> tInputList = getStoredInputs(); + 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((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { - if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { tInputList.remove(j--); - } else { + } + else { tInputList.remove(i--); break; } } } - } - - ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - + } + final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - ArrayList<FluidStack> tFluidList = getStoredFluids(); + 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((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { tFluidList.remove(j--); - } else { + } + else { tFluidList.remove(i--); break; } @@ -139,99 +241,109 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo } } - 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)) { + 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)) { 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++){ - 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[]{}); + 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 - (getIdealStatus() - getRepairStatus()) * 1000); + 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/**sDurationMultiplier*/) / (1 << tTier - 1)); - } else { + 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/**sDurationMultiplier*/); - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mMaxProgresstime = tRecipe.mDuration; + 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(mOutputFluids); - mMatterProduced++; - mAmplifierUsed++; - updateSlots(); - //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + ArrayUtils.reverse(this.mOutputFluids); + this.mMatterProduced++; + this.mAmplifierUsed++; + this.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"); - fakeRecipe = Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], new FluidStack[]{tempFake}, new ItemStack[]{}); + 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[] {}); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiency = 10000 - (this.getIdealStatus() - this.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 (fakeRecipe != null) { + if (this.fakeRecipe != null) { this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputItems = new ItemStack[]{fakeRecipe.getOutput(0)}; - this.mOutputFluids = fakeRecipe.mFluidOutputs.clone(); - ArrayUtils.reverse(mOutputFluids); - mMatterProduced++; - updateSlots(); - //Utils.LOG_INFO("Recipes Finished: "+mMatterProduced); + 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); return true; } } @@ -243,147 +355,85 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - for (int i = -2; i < 3; i++) { - for (int j = -2; j < 3; j++) { - for (int h = 0; h < 4; h++) { + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } - //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 int getAmountOfOutputs() { + return 10; + } - 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; - } - } + public int getAmplifierUsed() { + return this.mAmplifierUsed; + } - 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; - } - } + @Override + public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, + final IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_MatterFab(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); + } - 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 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 + }; + } + + public int getMatterProduced() { + return this.mMatterProduced; } @Override - public int getMaxEfficiency(ItemStack aStack) { + public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @Override - public int getPollutionPerTick(ItemStack aStack) { + public int getPollutionPerTick(final ItemStack aStack) { return 0; } @Override - public int getAmountOfOutputs() { - return 10; + 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] + }; } @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MassFabricator(this.mName); } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_MassFabricator(this.mName); + 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; } }
\ 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 1dea443d98..b4f272bdf3 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 @@ -24,365 +24,399 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class GregtechMetaTileEntity_MultiTank -extends GregtechMeta_MultiBlockBase { - public GregtechMetaTileEntity_MultiTank(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - 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; - } - +public class GregtechMetaTileEntity_MultiTank extends GregtechMeta_MultiBlockBase { + private long fluidStored = 0; - @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"); + 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) { + super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_MultiTank(String aName) { + public GregtechMetaTileEntity_MultiTank(final String aName) { super(aName); } @Override - 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)}; + 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; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[68]}; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "VacuumFreezer.png"); - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + 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++; + } + } + } + } + } + } + } + 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; } @Override - public boolean checkRecipe(ItemStack aStack) { + public boolean checkRecipe(final ItemStack aStack) { Utils.LOG_INFO("Okay"); - - - - ArrayList<ItemStack> tInputList = getStoredInputs(); + + 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((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { - if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { tInputList.remove(j--); - } else { + } + else { tInputList.remove(i--); break; } } } } - ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); + final ItemStack[] tInputs = Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2); - ArrayList<FluidStack> tFluidList = getStoredFluids(); + 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((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { - if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { tFluidList.remove(j--); - } else { + } + else { tFluidList.remove(i--); break; } } } } - FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); - - if (tFluids.length >= 2){ + final FluidStack[] tFluids = Arrays.copyOfRange(tFluidList.toArray(new FluidStack[1]), 0, 1); + + if (tFluids.length >= 2) { Utils.LOG_INFO("Bad"); return false; } - - ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>>(); + + final ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_Input, Boolean>>(); int slotInputCount = 0; - for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + for (final GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) { boolean containsFluid = false; - if (isValidMetaTileEntity(tHatch)) { + if (GregtechMeta_MultiBlockBase.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 (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; + + 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; 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:"+internalStorageTank.amount); + Utils.LOG_INFO( + "Okay - 1.1" + " rList.get(0).getKey().mFluid.amount: " + rList.get(0).getKey().mFluid.amount + + " internalStorageTank:" + this.internalStorageTank.amount); return true; } Utils.LOG_INFO("No Fluid in hatch."); - return false; + return false; } - 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"); - + 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"); + int tempAdd = 0; tempAdd = rList.get(0).getKey().getFluidAmount(); - 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; + 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; } - 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 "+internalStorageTank.amount+"L of "+internalStorageTank.getFluid().getName()+"."); + Utils.LOG_INFO("Tank Contains " + this.internalStorageTank.amount + "L of " + + this.internalStorageTank.getFluid().getName() + "."); } - //this.getBaseMetaTileEntity().(tFluids[0].amount, true); + // this.getBaseMetaTileEntity().(tFluids[0].amount, true); Utils.LOG_INFO("Tank"); 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, 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)))) { - 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++; - } - } - } - } - } - } - } - 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; + 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 int getMaxEfficiency(ItemStack aStack) { + 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(ItemStack aStack) { + public int getPollutionPerTick(final ItemStack aStack) { return 0; } @Override - public int getAmountOfOutputs() { - return 1; + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; + } + + private short getStorageMultiplier() { + final int tempstorageMultiplier = 1 * this.multiblockCasingCount; + if (tempstorageMultiplier <= 0) { + return 1; + } + return (short) tempstorageMultiplier; } @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; + 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) + }; + } + return new ITexture[] { + Textures.BlockIcons.CASING_BLOCKS[68] + }; + } + + @Override + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + @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"); + } + + @Override + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_MultiTank(this.mName); + } + + @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); } } 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 45635ea74d..1006f68da7 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,131 +17,144 @@ import net.minecraftforge.common.util.ForgeDirection; public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTileEntity_MultiBlockBase { - private int recipeCounter = 0; + private final int recipeCounter = 0; - public GregtechMetaTileEntity_PowerSubStationController(int aID, String aName, String aNameRegional) { + public GregtechMetaTileEntity_PowerSubStationController(final int aID, final String aName, + final String aNameRegional) { super(aID, aName, aNameRegional); } - public GregtechMetaTileEntity_PowerSubStationController(String aName) { + public GregtechMetaTileEntity_PowerSubStationController(final String aName) { super(aName); } @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Power Sub-Station", - "Stores quite a lot of power.", - "Size(WxHxD): 1x5x1, Controller (One above the Bottom)", - CORE.GT_Tooltip}; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[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; + 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; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { for (int h = 0; h < 4; h++) { - //Utils.LOG_INFO("Logging Variables - xDir:"+xDir+" zDir:"+zDir+" h:"+h+" i:"+i+" j:"+j); - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - /*if (tTileEntity != Block.getBlockFromItem(UtilsItems.getItem("IC2:blockAlloyGlass"))) { - Utils.LOG_INFO("h:"+h+" i:"+i+" j:"+j); - double tX = tTileEntity.getXCoord(); - double tY = tTileEntity.getYCoord(); - double tZ = tTileEntity.getZCoord(); - Utils.LOG_INFO("Found Glass at X:"+tX+" Y:"+tY+" Z:"+tZ); - //return false; - }*/ - if ((i != -2 && i != 2) && (j != -2 && j != 2)) {// innerer 3x3 ohne h�he - if (h == 0 && i != 0 && j != 0) {// innen boden (kantal coils) - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Block"); - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); - //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); + // 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()); return false; } if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO("Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Meta"); - return false; - } - } - else if (h == 3 && i != 0 && j != 0) {// innen decke (ulv casings + input + muffler) - //if(j == 0 && i == 0) { - - if ((!addMufflerToMachineList(tTileEntity, 66))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 4) { - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - Utils.LOG_INFO("Matter Fabricator Casings Missing from one of the top layers inner 3x3."); - return false; - } - } - //} - - } /*else {// top air - if ((i != -2 && i != 2) && (j != -2 && j != 2) && h == 3) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != ModBlocks.blockCasingsMisc) { - Utils.LOG_INFO("Matter Generation Coils missings from the top layer, inner 3x3. - Wrong Block"); - Utils.LOG_INFO("Found: "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()+" at x:"+(xDir + i)+" y:" +h+" z:"+(zDir + j)); - //tTileEntity.getWorld().setBlock(xDir+i, h, zDir+j, Blocks.diamond_block); - //Utils.LOG_INFO("Changed into : "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getUnlocalizedName()); + Utils.LOG_INFO( + "Matter Generation Coils missings from the bottom layer, inner 3x3. - Wrong Meta"); 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 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 {// 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())); + // } + + } /* + * 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()); 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 { + } } } @@ -152,38 +165,77 @@ public class GregtechMetaTileEntity_PowerSubStationController extends GT_MetaTil } @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; + public boolean checkRecipe(final ItemStack aStack) { + return false; } @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; + 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 GUI_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "MatterFabricator.png"); } @Override - public int getPollutionPerTick(ItemStack aStack) { + public int getDamageToComponent(final ItemStack aStack) { return 0; } @Override - public int getDamageToComponent(ItemStack aStack) { + 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) { return 0; } @Override - public int getAmountOfOutputs() { - return 1; + 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] + }; } @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; + public boolean isCorrectMachinePart(final ItemStack aStack) { + return true; } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + public IMetaTileEntity newMetaEntity(final 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 7508391f93..eede58d65b 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,130 +12,108 @@ 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(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 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(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_TieredTank(final String aName, final int aTier, final String aDescription, + final ITexture[][][] aTextures) { super(aName, aTier, 3, aDescription, aTextures); } @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; + public boolean canTankBeEmptied() { + return true; } @Override - 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)}; + public boolean canTankBeFilled() { + return true; } - - 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; - } - } + @Override + public boolean displaysItemStack() { return true; } - @Override - public String[] getDescription() { - - setVars(); - - - 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}; + public boolean displaysStackSize() { + return false; } - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - setVars(); - mRecipeStuff.setString("mFluidName", mFluidName); - mRecipeStuff.setInteger("mFluidAmount", mFluidAmount); - aNBT.setTag("GT.CraftingComponents", mRecipeStuff); + public boolean doesEmptyContainers() { + return true; } @Override - 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); + public boolean doesFillContainers() { + return true; } @Override - public void setItemNBT(NBTTagCompound aNBT) { - super.setItemNBT(aNBT); - mRecipeStuff.setString("mFluidName", mFluidName); - mRecipeStuff.setInteger("mFluidAmount", mFluidAmount); - aNBT.setTag("GT.CraftingComponents", mRecipeStuff); + public int getCapacity() { + return (int) (Math.pow(2, this.mTier) * 32000); } + @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 + }; + } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()){ - return true; + 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" + }; } - aBaseMetaTileEntity.openGUI(aPlayer); - 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" + }; } @Override - public boolean isSimpleMachine() { - return true; + public int getTankPressure() { + return 100; } @Override - public boolean isFacingValid(byte aFacing) { - return true; + 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) + }; } @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + return new ITexture[0][0][0]; } @Override @@ -144,84 +122,114 @@ extends GT_MetaTileEntity_BasicTank { } @Override - public boolean doesFillContainers() { + public boolean isAccessAllowed(final EntityPlayer aPlayer) { return true; } @Override - public boolean doesEmptyContainers() { + public boolean isFacingValid(final byte aFacing) { return true; } @Override - public boolean canTankBeFilled() { + public boolean isGivingInformation() { return true; } @Override - public boolean canTankBeEmptied() { + public boolean isSimpleMachine() { return true; } @Override - public boolean displaysItemStack() { - return true; + 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); } @Override - public boolean displaysStackSize() { - return false; + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_TieredTank(this.mName, this.mTier, this.mDescription, this.mTextures); } @Override - 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"}; + public void onMachineBlockUpdate() { + this.getBaseMetaTileEntity().markDirty(); + super.onMachineBlockUpdate(); } @Override - public boolean isGivingInformation() { - return true; + public void onRemoval() { + this.getBaseMetaTileEntity().markDirty(); + super.onRemoval(); } @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TieredTank(mName, mTier, mDescription, mTextures); + public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + aBaseMetaTileEntity.openGUI(aPlayer); + return true; } @Override - public int getCapacity() { - return (int) (Math.pow(2, mTier) * 32000); + 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); } @Override - public int getTankPressure() { - return 100; + 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); } - @Override - public void onMachineBlockUpdate() { - this.getBaseMetaTileEntity().markDirty(); - super.onMachineBlockUpdate(); - } + 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 onRemoval() { - this.getBaseMetaTileEntity().markDirty(); - super.onRemoval(); + 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; } }
\ No newline at end of file |