diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations')
9 files changed, 868 insertions, 1697 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java new file mode 100644 index 0000000000..2effc58f9a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeTank.java @@ -0,0 +1,327 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.enums.ItemList; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_DeluxeTank; +import gtPlusPlus.xmod.gregtech.api.gui.GUI_DeluxeTank; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +/** + * NEVER INCLUDE THIS FILE IN YOUR MOD!!! + * <p/> + * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually + */ +public abstract class GT_MetaTileEntity_DeluxeTank extends GT_MetaTileEntity_BasicTank { + + public FluidStack mFluid; + public FluidStack mFluid2; + + /** + * @param aInvSlotCount should be 3 + */ + public GT_MetaTileEntity_DeluxeTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); + } + + public GT_MetaTileEntity_DeluxeTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex != getStackDisplaySlot(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + if (mFluid2 != null) aNBT.setTag("mFluid2", mFluid2.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + mFluid2 = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid2")); + } + + @Override + public abstract boolean doesFillContainers(); + + @Override + public abstract boolean doesEmptyContainers(); + + @Override + public abstract boolean canTankBeFilled(); + + @Override + public abstract boolean canTankBeEmptied(); + + @Override + public abstract boolean displaysItemStack(); + + @Override + public abstract boolean displaysStackSize(); + + @Override + public int getInputSlot() { + return 0; + } + + @Override + public int getOutputSlot() { + return 1; + } + + @Override + public int getStackDisplaySlot() { + return 2; + } + + public int getStackDisplaySlot2() { + return 3; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return true; + } + + @Override + public boolean isFluidChangingAllowed() { + return true; + } + + @Override + public FluidStack getFillableStack() { + return getFillableStackEx(1); + } + + public FluidStack getFillableStackEx(int stackID) { + if (stackID <= 1){ + return mFluid; + } + return mFluid2; + } + + @Override + public FluidStack setFillableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; + } + + public FluidStack setFillableStack2(FluidStack aFluid) { + mFluid2 = aFluid; + return mFluid2; + } + + @Override + public FluidStack getDrainableStack() { + return getDrainableStackEx(1); + } + + public FluidStack getDrainableStackEx(int stackID) { + if (stackID <= 1){ + return mFluid; + } + return mFluid2; + } + + @Override + public FluidStack setDrainableStack(FluidStack aFluid) { + mFluid = aFluid; + return mFluid; + } + + @Override + public FluidStack getDisplayedFluid() { + return getDrainableStack(); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_DeluxeTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) + setFillableStack(null); + + if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { + if (getDisplayedFluid() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) + mInventory[getStackDisplaySlot()] = null; + } else { + mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); + } + } + + if (displaysItemStack() && getStackDisplaySlot2() >= 0 && getStackDisplaySlot2() < mInventory.length) { + if (getDrainableStackEx(2) == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot2()], true, true)) + mInventory[getStackDisplaySlot2()] = null; + } else { + mInventory[getStackDisplaySlot2()] = GT_Utility.getFluidDisplayStack(getDrainableStackEx(2), displaysStackSize()); + } + } + + if (doesEmptyContainers()) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); + if (tFluid != null && isFluidInputAllowed(tFluid)) { + + if (tFluid.isFluidEqual(getDrainableStackEx(1)) || getDrainableStackEx(1) == null){ + if (getFillableStackEx(1) == null) { + if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + setFillableStack(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + getFillableStack().amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + else if (tFluid.isFluidEqual(getDrainableStackEx(2)) || (getDrainableStackEx(2) == null)){ + if (getFillableStackEx(2) == null) { + if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + setFillableStack2(tFluid.copy()); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } else { + if (tFluid.isFluidEqual(getFillableStackEx(2)) && tFluid.amount + getFillableStackEx(2).amount <= getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { + getFillableStackEx(2).amount += tFluid.amount; + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + else { + Utils.LOG_INFO("Something broke when trying to empty cells between two fluid tank areas."); + } + } + } + + if (doesFillContainers()) { + ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); + if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { + FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + if (tFluid != null) getDrainableStack().amount -= tFluid.amount; + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); + } + } + } + } + + @Override + public FluidStack getFluid() { + return getDrainableStack(); + } + + @Override + public int getFluidAmount() { + return getDrainableStack() != null ? getDrainableStack().amount : 0; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) + return 0; + + if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { + if (aFluid.amount <= getCapacity()) { + if (doFill) { + setFillableStack(aFluid.copy()); + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + setFillableStack(aFluid.copy()); + getFillableStack().amount = getCapacity(); + getBaseMetaTileEntity().markDirty(); + } + return getCapacity(); + } + + if (!getFillableStack().isFluidEqual(aFluid)) + return 0; + + int space = getCapacity() - getFillableStack().amount; + if (aFluid.amount <= space) { + if (doFill) { + getFillableStack().amount += aFluid.amount; + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) + getFillableStack().amount = getCapacity(); + return space; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (getDrainableStack() == null || !canTankBeEmptied()) return null; + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { + setDrainableStack(null); + getBaseMetaTileEntity().markDirty(); + return null; + } + + int used = maxDrain; + if (getDrainableStack().amount < used) + used = getDrainableStack().amount; + + if (doDrain) { + getDrainableStack().amount -= used; + getBaseMetaTileEntity().markDirty(); + } + + FluidStack drained = getDrainableStack().copy(); + drained.amount = used; + + if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { + setDrainableStack(null); + getBaseMetaTileEntity().markDirty(); + } + + return drained; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getOutputSlot(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == getInputSlot(); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaBasicTank.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaBasicTank.java deleted file mode 100644 index c199114daa..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaBasicTank.java +++ /dev/null @@ -1,261 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.ItemList; -import gregtech.api.gui.GT_Container_BasicTank; -import gregtech.api.gui.GT_GUIContainer_BasicTank; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually - */ -public abstract class GregtechMetaBasicTank extends GregtechMetaTieredMachineBlock { - - public FluidStack mFluid; - public FluidStack mInternal; - /** - * @param aInvSlotCount should be 3 - */ - public GregtechMetaBasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GregtechMetaBasicTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex != getStackDisplaySlot(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - } - - public abstract boolean doesFillContainers(); - - public abstract boolean doesEmptyContainers(); - - public abstract boolean canTankBeFilled(); - - public abstract boolean canTankBeEmptied(); - - public abstract boolean displaysItemStack(); - - public abstract boolean displaysStackSize(); - - public int getInputSlot() { - return 0; - } - - public int getOutputSlot() { - return 1; - } - - public int getStackDisplaySlot() { - return 2; - } - - public boolean isFluidInputAllowed(FluidStack aFluid) { - return true; - } - - public boolean isFluidChangingAllowed() { - return true; - } - - public FluidStack getFillableStack() { - return mFluid; - } - - public FluidStack setFillableStack(FluidStack aFluid) { - mFluid = aFluid; - return mFluid; - } - - public FluidStack setInternalStack(FluidStack aFluid) { - mInternal = aFluid; - return mInternal; - } - - public FluidStack getInternalStack() { - return mInternal; - } - - public FluidStack getDrainableStack() { - return mFluid; - } - - public FluidStack setDrainableStack(FluidStack aFluid) { - mFluid = aFluid; - return mFluid; - } - - public FluidStack getDisplayedFluid() { - return getDrainableStack(); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) - setFillableStack(null); - if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount >= 1) - setInternalStack(getFillableStack()); - if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { - if (getDisplayedFluid() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) - mInventory[getStackDisplaySlot()] = null; - } else { - mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); - } - } - - if (doesEmptyContainers()) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); - if (tFluid != null && isFluidInputAllowed(tFluid)) { - if (getFillableStack() == null) { - if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - setFillableStack(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } else { - if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - getFillableStack().amount += tFluid.amount; - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } - } - } - - if (doesFillContainers()) { - ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); - if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - if (tFluid != null) getDrainableStack().amount -= tFluid.amount; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); - } - } - } - } - - @Override - public FluidStack getFluid() { - return getDrainableStack(); - } - - @Override - public int getFluidAmount() { - return getDrainableStack() != null ? getDrainableStack().amount : 0; - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) - return 0; - - if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { - if (aFluid.amount <= getCapacity()) { - if (doFill) { - setFillableStack(aFluid.copy()); - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - setFillableStack(aFluid.copy()); - getFillableStack().amount = getCapacity(); - getBaseMetaTileEntity().markDirty(); - } - return getCapacity(); - } - - if (!getFillableStack().isFluidEqual(aFluid)) - return 0; - - int space = getCapacity() - getFillableStack().amount; - if (aFluid.amount <= space) { - if (doFill) { - getFillableStack().amount += aFluid.amount; - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) - getFillableStack().amount = getCapacity(); - return space; - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - if (getDrainableStack() == null || !canTankBeEmptied()) return null; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - return null; - } - - int used = maxDrain; - if (getDrainableStack().amount < used) - used = getDrainableStack().amount; - - if (doDrain) { - getDrainableStack().amount -= used; - getBaseMetaTileEntity().markDirty(); - } - - FluidStack drained = getDrainableStack().copy(); - drained.amount = used; - - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - } - - return drained; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == getOutputSlot(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == getInputSlot(); - } -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java index 45f05f4495..4f4f3f931f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaEnergyBuffer.java @@ -13,7 +13,9 @@ import gregtech.api.util.GT_ModHandler; 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.api.metatileentity.implementations.base.GregtechMetaTileEntity; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import ic2.api.item.IElectricItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -47,7 +49,81 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { /* * MACHINE_STEEL_SIDE */ - @Override + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = getFront(i); + rTextures[1][i + 1] = getBack(i); + rTextures[2][i + 1] = getBottom(i); + rTextures[3][i + 1] = getTop(i); + rTextures[4][i + 1] = getSides(i); + rTextures[5][i + 1] = getFrontActive(i); + rTextures[6][i + 1] = getBackActive(i); + rTextures[7][i + 1] = getBottomActive(i); + rTextures[8][i + 1] = getTopActive(i); + rTextures[9][i + 1] = getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + public ITexture[] getFront(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + + public ITexture[] getBack(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getTop(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; + } + + + public ITexture[] getSides(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mTier]}; + } + + + public ITexture[] getBackActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + + public ITexture[] getTopActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Screen_Logo)}; + } + + + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange)}; + } + + /*@Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[2][17][]; for (byte i = -1; i < 16; i++) { @@ -60,7 +136,7 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] }; } return rTextures; - } + }*/ /* * @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { @@ -84,10 +160,10 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { * } return rTextures; } */ - @Override + /*@Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; - } + }*/ @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -158,7 +234,7 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { long tempStorage = getStoredEnergy()[0]; final double c = ((double) tempStorage / maxEUStore()) * 100; final double roundOff = Math.round(c * 100.00) / 100.00; - Utils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff+"%)"); + PlayerUtils.messagePlayer(playerIn, "Energy: " + tempStorage + " EU at "+V[mTier]+"v ("+roundOff+"%)"); } //Utils.LOG_WARNING("Begin Show Energy"); @@ -314,10 +390,6 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { } @Override - public void markDirty() { - } - - @Override public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_BasicMachine_Custom_Recipe.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_BasicMachine_Custom_Recipe.java deleted file mode 100644 index c7f84f1095..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_BasicMachine_Custom_Recipe.java +++ /dev/null @@ -1,623 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; - -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.W; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; -import gregtech.api.enums.Tier; -import gregtech.api.gui.GT_Container_BasicMachine; -import gregtech.api.gui.GT_GUIContainer_BasicMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_ModHandler.RecipeBits; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.api.util.GregtechRecipe_OLD.Gregtech_Recipe_Map; - -import java.util.Random; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public class GT_MTE_BasicMachine_Custom_Recipe extends GT_MTE_CustomRecipe_BasicMachine { - private final Gregtech_Recipe_Map mRecipes; - private final int mTankCapacity, mSpecialEffect; - private final String mSound; - private final boolean mSharedTank, mRequiresFluidForFiltering; - private final byte mGUIParameterA, mGUIParameterB; - public GT_MTE_BasicMachine_Custom_Recipe(int aID, String aName, String aNameRegional, int aTier, String aDescription, Gregtech_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) { - super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new ITexture[]{new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_BOTTOM"))}); - mSharedTank = aSharedTank; - mTankCapacity = aTankCapacity; - mSpecialEffect = aSpecialEffect; - mRequiresFluidForFiltering = aRequiresFluidForFiltering; - mRecipes = aRecipes; - mSound = aSound; - mGUIParameterA = (byte) aGUIParameterA; - mGUIParameterB = (byte) aGUIParameterB; - - if (aRecipe != null) { - for (int i = 3; i < aRecipe.length; i++) { - if (aRecipe[i] == X.CIRCUIT) { - aRecipe[i] = Tier.ELECTRIC[mTier].mManagingObject; - continue; - } - if (aRecipe[i] == X.BETTER_CIRCUIT) { - aRecipe[i] = Tier.ELECTRIC[mTier].mBetterManagingObject; - continue; - } - if (aRecipe[i] == X.HULL) { - aRecipe[i] = Tier.ELECTRIC[mTier].mHullObject; - continue; - } - if (aRecipe[i] == X.WIRE) { - aRecipe[i] = Tier.ELECTRIC[mTier].mConductingObject; - continue; - } - if (aRecipe[i] == X.WIRE4) { - aRecipe[i] = Tier.ELECTRIC[mTier].mLargerConductingObject; - continue; - } - - if (aRecipe[i] == X.GLASS) { - switch (mTier) { - default: - aRecipe[i] = new ItemStack(Blocks.glass, 1, W); - break; - } - continue; - } - - if (aRecipe[i] == X.PLATE) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.plate.get(Materials.Steel); - break; - case 2: - aRecipe[i] = OrePrefixes.plate.get(Materials.Aluminium); - break; - case 3: - aRecipe[i] = OrePrefixes.plate.get(Materials.StainlessSteel); - break; - case 4: - aRecipe[i] = OrePrefixes.plate.get(Materials.Titanium); - break; - default: - aRecipe[i] = OrePrefixes.plate.get(Materials.TungstenSteel); - break; - } - continue; - } - - if (aRecipe[i] == X.PIPE) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Bronze); - break; - case 2: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Steel); - break; - case 3: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.StainlessSteel); - break; - case 4: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Titanium); - break; - default: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.TungstenSteel); - break; - } - continue; - } - - if (aRecipe[i] == X.COIL_HEATING) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Cupronickel); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Kanthal); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Nichrome); - break; - default: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.Nichrome); - break; - } - continue; - } - - if (aRecipe[i] == X.COIL_HEATING_DOUBLE) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Cupronickel); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Kanthal); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Nichrome); - break; - default: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.Nichrome); - break; - } - continue; - } - - if (aRecipe[i] == X.STICK_DISTILLATION) { - switch (mTier) { - default: - aRecipe[i] = OrePrefixes.stick.get(Materials.Blaze); - break; - } - continue; - } - - if (aRecipe[i] == X.STICK_MAGNETIC) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.stick.get(Materials.IronMagnetic); - break; - case 2: - case 3: - aRecipe[i] = OrePrefixes.stick.get(Materials.SteelMagnetic); - break; - default: - aRecipe[i] = OrePrefixes.stick.get(Materials.NeodymiumMagnetic); - break; - } - continue; - } - - if (aRecipe[i] == X.STICK_ELECTROMAGNETIC) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.stick.get(Materials.AnyIron); - break; - case 2: - case 3: - aRecipe[i] = OrePrefixes.stick.get(Materials.Steel); - break; - case 4: - aRecipe[i] = OrePrefixes.stick.get(Materials.Neodymium); - break; - default: - aRecipe[i] = OrePrefixes.stick.get(Materials.VanadiumGallium); - break; - } - continue; - } - - if (aRecipe[i] == X.COIL_ELECTRIC) { - switch (mTier) { - case 0: - aRecipe[i] = OrePrefixes.wireGt01.get(Materials.Tin); - break; - case 1: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Tin); - break; - case 2: - aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); - break; - case 3: - aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); - break; - case 4: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.AnnealedCopper); - break; - default: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.AnnealedCopper); - break; - } - continue; - } - - if (aRecipe[i] == X.ROBOT_ARM) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Robot_Arm_LV; - break; - case 2: - aRecipe[i] = ItemList.Robot_Arm_MV; - break; - case 3: - aRecipe[i] = ItemList.Robot_Arm_HV; - break; - case 4: - aRecipe[i] = ItemList.Robot_Arm_EV; - break; - case 5: - aRecipe[i] = ItemList.Robot_Arm_IV; - break; - case 6: - aRecipe[i] = ItemList.Robot_Arm_LuV; - break; - case 7: - aRecipe[i] = ItemList.Robot_Arm_ZPM; - break; - default: - aRecipe[i] = ItemList.Robot_Arm_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.PUMP) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Pump_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Pump_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Pump_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Pump_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Pump_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Pump_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Pump_ZPM; - break; - default: - aRecipe[i] = ItemList.Electric_Pump_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.ROTOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Tin); - break; - case 2: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Bronze); - break; - case 3: - aRecipe[i] = OrePrefixes.rotor.get(Materials.Steel); - break; - case 4: - aRecipe[i] = OrePrefixes.rotor.get(Materials.StainlessSteel); - break; - case 5: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - case 6: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - case 7: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - default: - aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); - break; - } - continue; - } - - if (aRecipe[i] == X.MOTOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Motor_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Motor_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Motor_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Motor_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Motor_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Motor_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Motor_ZPM; - break; - default: - aRecipe[i] = ItemList.Electric_Motor_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.PISTON) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Electric_Piston_LV; - break; - case 2: - aRecipe[i] = ItemList.Electric_Piston_MV; - break; - case 3: - aRecipe[i] = ItemList.Electric_Piston_HV; - break; - case 4: - aRecipe[i] = ItemList.Electric_Piston_EV; - break; - case 5: - aRecipe[i] = ItemList.Electric_Piston_IV; - break; - case 6: - aRecipe[i] = ItemList.Electric_Piston_LuV; - break; - case 7: - aRecipe[i] = ItemList.Electric_Piston_ZPM; - break; - default: - aRecipe[i] = ItemList.Electric_Piston_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.CONVEYOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Conveyor_Module_LV; - break; - case 2: - aRecipe[i] = ItemList.Conveyor_Module_MV; - break; - case 3: - aRecipe[i] = ItemList.Conveyor_Module_HV; - break; - case 4: - aRecipe[i] = ItemList.Conveyor_Module_EV; - break; - case 5: - aRecipe[i] = ItemList.Conveyor_Module_IV; - break; - case 6: - aRecipe[i] = ItemList.Conveyor_Module_LuV; - break; - case 7: - aRecipe[i] = ItemList.Conveyor_Module_ZPM; - break; - default: - aRecipe[i] = ItemList.Conveyor_Module_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.EMITTER) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Emitter_LV; - break; - case 2: - aRecipe[i] = ItemList.Emitter_MV; - break; - case 3: - aRecipe[i] = ItemList.Emitter_HV; - break; - case 4: - aRecipe[i] = ItemList.Emitter_EV; - break; - case 5: - aRecipe[i] = ItemList.Emitter_IV; - break; - case 6: - aRecipe[i] = ItemList.Emitter_LuV; - break; - case 7: - aRecipe[i] = ItemList.Emitter_ZPM; - break; - default: - aRecipe[i] = ItemList.Emitter_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.SENSOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Sensor_LV; - break; - case 2: - aRecipe[i] = ItemList.Sensor_MV; - break; - case 3: - aRecipe[i] = ItemList.Sensor_HV; - break; - case 4: - aRecipe[i] = ItemList.Sensor_EV; - break; - case 5: - aRecipe[i] = ItemList.Sensor_IV; - break; - case 6: - aRecipe[i] = ItemList.Sensor_LuV; - break; - case 7: - aRecipe[i] = ItemList.Sensor_ZPM; - break; - default: - aRecipe[i] = ItemList.Sensor_UV; - break; - } - continue; - } - - if (aRecipe[i] == X.FIELD_GENERATOR) { - switch (mTier) { - case 0: - case 1: - aRecipe[i] = ItemList.Field_Generator_LV; - break; - case 2: - aRecipe[i] = ItemList.Field_Generator_MV; - break; - case 3: - aRecipe[i] = ItemList.Field_Generator_HV; - break; - case 4: - aRecipe[i] = ItemList.Field_Generator_EV; - break; - case 5: - aRecipe[i] = ItemList.Field_Generator_IV; - break; - case 6: - aRecipe[i] = ItemList.Field_Generator_LuV; - break; - case 7: - aRecipe[i] = ItemList.Field_Generator_ZPM; - break; - default: - aRecipe[i] = ItemList.Field_Generator_UV; - break; - } - continue; - } - - if (aRecipe[i] instanceof X) - throw new IllegalArgumentException("MISSING TIER MAPPING FOR: " + aRecipe[i] + " AT TIER " + mTier); - } - - if (!GT_ModHandler.addCraftingRecipe(getStackForm(1), RecipeBits.DISMANTLEABLE | RecipeBits.BUFFERED | RecipeBits.NOT_REMOVABLE | RecipeBits.REVERSIBLE, aRecipe)) { - throw new IllegalArgumentException("INVALID CRAFTING RECIPE FOR: " + getStackForm(1).getDisplayName()); - } - } - } - - public GT_MTE_BasicMachine_Custom_Recipe(String aName, int aTier, String aDescription, Gregtech_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { - super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName); - mSharedTank = aSharedTank; - mTankCapacity = aTankCapacity; - mSpecialEffect = aSpecialEffect; - mRequiresFluidForFiltering = aRequiresFluidForFiltering; - mRecipes = aRecipes; - mSound = aSound; - mGUIParameterA = (byte) aGUIParameterA; - mGUIParameterB = (byte) aGUIParameterB; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MTE_BasicMachine_Custom_Recipe(mName, mTier, mDescription, mRecipes, mInputSlotCount, mOutputItems == null ? 0 : mOutputItems.length, mTankCapacity, mAmperage, mGUIParameterA, mGUIParameterB, mTextures, mGUIName, mNEIName, mSound, mSharedTank, mRequiresFluidForFiltering, mSpecialEffect); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : "", mGUIParameterA, mGUIParameterB); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; - if (mInventory[aIndex] != null) return true; - switch (mInputSlotCount) { - case 0: return false; - case 1: return getFillableStack() == null ? !mRequiresFluidForFiltering && getRecipeList().containsInput(aStack) : null!=getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), new ItemStack[] {aStack}); - case 2: return (!mRequiresFluidForFiltering || getFillableStack() != null) && (((getInputAt(0)!=null&&getInputAt(1)!=null) || (getInputAt(0)==null&&getInputAt(1)==null?getRecipeList().containsInput(aStack):(getRecipeList().containsInput(aStack)&&null!=getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), aIndex == getInputSlot() ? new ItemStack[] {aStack, getInputAt(1)} : new ItemStack[] {getInputAt(0), aStack}))))); - default: return getRecipeList().containsInput(aStack); - } - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { - switch (mSpecialEffect) { - case 0: - break; - case 1: - if (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.9F + tRandom.nextFloat() * 0.2F, aBaseMetaTileEntity.getZCoord() + 0.8F - tRandom.nextFloat() * 0.6F, 0.0D, 0.0D, 0.0D); - } - break; - } - } - } - - - public Gregtech_Recipe_Map getRecipeList() { - return mRecipes; - } - - @Override - public int getCapacity() { - return mTankCapacity; - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1 && GT_Utility.isStringValid(mSound)) GT_Utility.doSoundAtClient(mSound, 100, 1.0F, aX, aY, aZ); - } - - @Override - public void startProcess() { - if (GT_Utility.isStringValid(mSound)) sendLoopStart((byte) 1); - } - - @Override - public FluidStack getFillableStack() { - return mSharedTank ? getDrainableStack() : super.getFillableStack(); - } - - @Override - public FluidStack setFillableStack(FluidStack aFluid) { - return mSharedTank ? setDrainableStack(aFluid) : super.setFillableStack(aFluid); - } - - @Override - protected boolean displaysOutputFluid() { - return !mSharedTank; - } - - public static enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC;} -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_CustomRecipe_BasicMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_CustomRecipe_BasicMachine.java deleted file mode 100644 index 521b23a42e..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GT_MTE_CustomRecipe_BasicMachine.java +++ /dev/null @@ -1,799 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_Container_BasicMachine; -import gregtech.api.gui.GT_GUIContainer_BasicMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.xmod.gregtech.api.util.GregtechRecipe_OLD; -import gtPlusPlus.xmod.gregtech.api.util.GregtechRecipe_OLD.Gregtech_Recipe_Map; - -import java.util.Arrays; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public abstract class GT_MTE_CustomRecipe_BasicMachine extends GT_MetaTileEntity_BasicTank { - /** - * return values for checkRecipe() - */ - protected static final int - DID_NOT_FIND_RECIPE = 0, - FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, - FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; - private static final int OTHER_SLOT_COUNT = 4; - public final ItemStack[] mOutputItems; - public final int mInputSlotCount, mAmperage; - public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; - public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; - public FluidStack mOutputFluid; - public String mGUIName = "", mNEIName = ""; - private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - /** - * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered - */ - protected GregtechRecipe_OLD mLastRecipe = null; - private FluidStack mFluidOut; - - /** - * @param aOverlays 0 = SideFacingActive - * 1 = SideFacingInactive - * 2 = FrontFacingActive - * 3 = FrontFacingInactive - * 4 = TopFacingActive - * 5 = TopFacingInactive - * 6 = BottomFacingActive - * 7 = BottomFacingInactive - * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- - * 8 = BottomFacingPipeActive - * 9 = BottomFacingPipeInactive - * 10 = TopFacingPipeActive - * 11 = TopFacingPipeInactive - * 12 = SideFacingPipeActive - * 13 = SideFacingPipeInactive - */ - public GT_MTE_CustomRecipe_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); - mInputSlotCount = Math.max(0, aInputSlotCount); - mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; - mAmperage = aAmperage; - mGUIName = aGUIName; - mNEIName = aNEIName; - } - - public GT_MTE_CustomRecipe_BasicMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { - super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); - mInputSlotCount = Math.max(0, aInputSlotCount); - mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; - mAmperage = aAmperage; - mGUIName = aGUIName; - mNEIName = aNEIName; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[14][17][]; - aTextures = Arrays.copyOf(aTextures, 14); - - for (int i = 0; i < aTextures.length; i++) - if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { - if (rTextures[i][c + 1] == null) - rTextures[i][c + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; - } - - for (byte c = -1; c < 16; c++) { - if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); - if (rTextures[1][c + 1] == null) rTextures[1][c + 1] = getSideFacingInactive(c); - if (rTextures[2][c + 1] == null) rTextures[2][c + 1] = getFrontFacingActive(c); - if (rTextures[3][c + 1] == null) rTextures[3][c + 1] = getFrontFacingInactive(c); - if (rTextures[4][c + 1] == null) rTextures[4][c + 1] = getTopFacingActive(c); - if (rTextures[5][c + 1] == null) rTextures[5][c + 1] = getTopFacingInactive(c); - if (rTextures[6][c + 1] == null) rTextures[6][c + 1] = getBottomFacingActive(c); - if (rTextures[7][c + 1] == null) rTextures[7][c + 1] = getBottomFacingInactive(c); - if (rTextures[8][c + 1] == null) rTextures[8][c + 1] = getBottomFacingPipeActive(c); - if (rTextures[9][c + 1] == null) rTextures[9][c + 1] = getBottomFacingPipeInactive(c); - if (rTextures[10][c + 1] == null) rTextures[10][c + 1] = getTopFacingPipeActive(c); - if (rTextures[11][c + 1] == null) rTextures[11][c + 1] = getTopFacingPipeInactive(c); - if (rTextures[12][c + 1] == null) rTextures[12][c + 1] = getSideFacingPipeActive(c); - if (rTextures[13][c + 1] == null) rTextures[13][c + 1] = getSideFacingPipeInactive(c); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public boolean isElectric() { - return true; - } - - @Override - public boolean isValidSlot(int aIndex) { - return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return mMainFacing > 1 || aFacing > 1; - } - - @Override - public boolean isEnetInput() { - return true; - } - - @Override - public boolean isInputFacing(byte aSide) { - return aSide != mMainFacing; - } - - @Override - public boolean isOutputFacing(byte aSide) { - return false; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); - } - - @Override - public boolean isLiquidOutput(byte aSide) { - return aSide != mMainFacing; - } - - @Override - public long getMinimumStoredEU() { - return V[mTier] * 16; - } - - @Override - public long maxEUStore() { - return V[mTier] * 64; - } - - @Override - public long maxEUInput() { - return V[mTier]; - } - - @Override - public long maxSteamStore() { - return maxEUStore(); - } - - @Override - public long maxAmperesIn() { - return (mEUt * 2) / V[mTier] + 1; - } - - @Override - public int getInputSlot() { - return OTHER_SLOT_COUNT; - } - - @Override - public int getOutputSlot() { - return OTHER_SLOT_COUNT + mInputSlotCount; - } - - @Override - public int getStackDisplaySlot() { - return 2; - } - - @Override - public int rechargerSlotStartIndex() { - return 1; - } - - @Override - public int dechargerSlotStartIndex() { - return 1; - } - - @Override - public int rechargerSlotCount() { - return mCharge ? 1 : 0; - } - - @Override - public int dechargerSlotCount() { - return mDecharge ? 1 : 0; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; - } - - @Override - public int getProgresstime() { - return mProgresstime; - } - - @Override - public int maxProgresstime() { - return mMaxProgresstime; - } - - @Override - public int increaseProgress(int aProgress) { - mProgresstime += aProgress; - return mMaxProgresstime - mProgresstime; - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); - } - - @Override - public boolean isFluidChangingAllowed() { - return true; - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return true; - } - - @Override - public boolean displaysStackSize() { - return true; - } - - @Override - public FluidStack getDisplayedFluid() { - return displaysOutputFluid() ? getDrainableStack() : null; - } - - @Override - public FluidStack getDrainableStack() { - return mFluidOut; - } - - @Override - public FluidStack setDrainableStack(FluidStack aFluid) { - mFluidOut = aFluid; - return mFluidOut; - } - - @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 GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); - } - - @Override - public void initDefaultModes(NBTTagCompound aNBT) { - mMainFacing = -1; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mFluidTransfer", mFluidTransfer); - aNBT.setBoolean("mItemTransfer", mItemTransfer); - aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); - aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); - aNBT.setInteger("mEUt", mEUt); - aNBT.setInteger("mMainFacing", mMainFacing); - aNBT.setInteger("mProgresstime", mProgresstime); - aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); - aNBT.setTag("GT.CraftingComponents", mRecipeStuff); - if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); - if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); - - for (int i = 0; i < mOutputItems.length; i++) - if (mOutputItems[i] != null) - aNBT.setTag("mOutputItem" + i, mOutputItems[i].writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); - mItemTransfer = aNBT.getBoolean("mItemTransfer"); - mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); - mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); - mEUt = aNBT.getInteger("mEUt"); - mMainFacing = aNBT.getInteger("mMainFacing"); - mProgresstime = aNBT.getInteger("mProgresstime"); - mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); - mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); - - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (aBaseMetaTileEntity.isServerSide()) { - mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; - mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; - - doDisplayThings(); - - boolean tSucceeded = false; - - if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { - aBaseMetaTileEntity.setActive(true); - if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { - if (++mProgresstime >= mMaxProgresstime) { - for (int i = 0; i < mOutputItems.length; i++) - for (int j = 0; j < mOutputItems.length; j++) - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) - break; - if (mOutputFluid != null) - if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); - else if (mOutputFluid.isFluidEqual(getDrainableStack())) - getDrainableStack().amount += mOutputFluid.amount; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; - mOutputFluid = null; - mEUt = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mStuttering = false; - tSucceeded = true; - endProcess(); - } - if (mProgresstime > 5) mStuttering = false; - } else { - if (!mStuttering) { - stutterProcess(); - if (canHaveInsufficientEnergy()) mProgresstime = -100; - mStuttering = true; - } - } - } else { - aBaseMetaTileEntity.setActive(false); - } - - boolean tRemovedOutputFluid = false; - - if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { - IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); - if (tTank != null) { - FluidStack tDrained = drain(1000, false); - if (tDrained != null) { - int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); - if (tFilledAmount > 0) - tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); - } - } - if (getDrainableStack() == null) tRemovedOutputFluid = true; - } - - if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { - TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); - } - } - - if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; - else mOutputBlocked++; - - if (allowToCheckRecipe()) { - if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { - if (checkRecipe() == 2) { - if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; - for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; - for (int i = 0; i < mOutputItems.length; i++) { - mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); - if (mOutputItems[i] != null && mOutputItems[i].stackSize > 64) - mOutputItems[i].stackSize = 64; - mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); - } - if (mFluid != null && mFluid.amount <= 0) mFluid = null; - mMaxProgresstime = Math.max(1, mMaxProgresstime); - if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { - mEUt = mMaxProgresstime = 1; - } - startProcess(); - } else { - mMaxProgresstime = 0; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; - mOutputFluid = null; - } - } - } else { - if (!mStuttering) { - stutterProcess(); - mStuttering = true; - } - } - } - } - - protected void doDisplayThings() { - if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { - mMainFacing = getBaseMetaTileEntity().getFrontFacing(); - } - if (mMainFacing >= 2 && !mHasBeenUpdated) { - mHasBeenUpdated = true; - getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); - } - - if (displaysInputFluid()) { - int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; - if (getFillableStack() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) - mInventory[tDisplayStackSlot] = null; - } else { - mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); - } - } - } - - protected boolean hasEnoughEnergyToCheckRecipe() { - return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); - } - - protected boolean drainEnergyForProcess(long aEUt) { - return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); - } - - protected void calculateOverclockedNess(GregtechRecipe_OLD tRecipe) { - calculateOverclockedNess(tRecipe.mEUt, tRecipe.mDuration); - } - - protected void calculateOverclockedNess(int aEUt, int aDuration) { - if (aEUt <= 16) { - mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); - mMaxProgresstime = aDuration / (1 << (mTier - 1)); - } else { - mEUt = aEUt; - mMaxProgresstime = aDuration; - while (mEUt <= V[mTier - 1] * mAmperage) { - mEUt *= 4; - mMaxProgresstime /= 2; - } - } - } - - protected ItemStack getSpecialSlot() { - return mInventory[3]; - } - - protected ItemStack getOutputAt(int aIndex) { - return mInventory[getOutputSlot() + aIndex]; - } - - protected ItemStack[] getAllOutputs() { - ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; - for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); - return rOutputs; - } - - protected boolean canOutput(GregtechRecipe_OLD tRecipe) { - return tRecipe != null && (tRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(tRecipe.getFluidOutput(0)) && canOutput(tRecipe.mOutputs)); - } - - protected boolean canOutput(ItemStack... aOutputs) { - if (aOutputs == null) return true; - ItemStack[] tOutputSlots = getAllOutputs(); - for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) - if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { - mOutputBlocked++; - return false; - } - return true; - } - - protected boolean canOutput(FluidStack aOutput) { - return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); - } - - protected ItemStack getInputAt(int aIndex) { - return mInventory[getInputSlot() + aIndex]; - } - - protected ItemStack[] getAllInputs() { - ItemStack[] rInputs = new ItemStack[mInputSlotCount]; - for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); - return rInputs; - } - - protected boolean isOutputEmpty() { - boolean rIsEmpty = true; - for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; - return rIsEmpty; - } - - protected boolean displaysInputFluid() { - return true; - } - - protected boolean displaysOutputFluid() { - return true; - } - - @Override - public void onValueUpdate(byte aValue) { - mMainFacing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte) mMainFacing; - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - super.doSound(aIndex, aX, aY, aZ); - if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); - } - - public boolean doesAutoOutput() { - return mItemTransfer; - } - - public boolean doesAutoOutputFluids() { - return mFluidTransfer; - } - - public boolean allowToCheckRecipe() { - return true; - } - - public boolean showPipeFacing() { - return true; - } - - /** - * Called whenever the Machine successfully started a Process, useful for Sound Effects - */ - public void startProcess() { - // - } - - /** - * Called whenever the Machine successfully finished a Process, useful for Sound Effects - */ - public void endProcess() { - // - } - - /** - * Called whenever the Machine aborted a Process, useful for Sound Effects - */ - public void abortProcess() { - // - } - - /** - * Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects - */ - public void stutterProcess() { - if (useStandardStutterSound()) sendSound((byte) 8); - } - - /** - * If this Machine can have the Insufficient Energy Line Problem - */ - public boolean canHaveInsufficientEnergy() { - return true; - } - - public boolean useStandardStutterSound() { - return true; - } - - @Override - public String[] getInfoData() { - return new String[]{ - mRecipeStuff.toString(), - mNEIName, - "Progress:", (mProgresstime / 20) + " secs", - (mMaxProgresstime / 20) + " secs", - "Stored Energy:", - getBaseMetaTileEntity().getStoredEU() + "EU", - getBaseMetaTileEntity().getEUCapacity() + "EU"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { - mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); - } - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (aSide != mMainFacing || GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide != mMainFacing && aIndex >= getOutputSlot() && aIndex < getOutputSlot() + mOutputItems.length; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) - return false; - for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) - if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; - return true; - } - - /** - * @return the Recipe List which is used for this Machine, this is a useful Default Handler - */ - public Gregtech_Recipe_Map getRecipeList() { - return null; - } - - /** - * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case - * <p/> - * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. - * <p/> - * Funny how Eclipse marks the word Enum as not correctly spelled. - * - * @return see constants above - */ - public int checkRecipe() { - Gregtech_Recipe_Map tMap = getRecipeList(); - if (tMap == null) return DID_NOT_FIND_RECIPE; - GregtechRecipe_OLD tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); - if (tRecipe == null) return DID_NOT_FIND_RECIPE; - if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; - if (!canOutput(tRecipe)) { - mOutputBlocked++; - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - } - if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - - for (int i = 0; i < mOutputItems.length; i++) - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) - mOutputItems[i] = tRecipe.getOutput(i); - mOutputFluid = tRecipe.getFluidOutput(0); - calculateOverclockedNess(tRecipe); - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; - } - - public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; - } - - public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java index 585987797c..e9947464be 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMetaPipeEntityBase_Cable.java @@ -16,6 +16,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Proxy; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; @@ -71,13 +72,14 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements } private int getGT5Var(){ - Class clazz = GT_Mod.gregtechproxy.getClass(); + Class<? extends GT_Proxy> clazz = GT_Mod.gregtechproxy.getClass(); String lookingForValue = "mWireHeatingTicks"; int temp = 4; Field field; + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ try { field = clazz.getClass().getField(lookingForValue); - Class clazzType = field.getType(); + Class<?> clazzType = field.getType(); if (clazzType.toString().equals("int")){ temp = (field.getInt(clazz)); } @@ -85,10 +87,12 @@ public class GregtechMetaPipeEntityBase_Cable extends MetaPipeEntity implements temp = 4; } } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { - Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + //Utils.LOG_INFO("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); Utils.LOG_WARNING("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); Utils.LOG_ERROR("FATAL ERROR - REFLECTION FAILED FOR GT CABLES - PLEASE REPORT THIS."); + temp = 4; } + } return temp; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 59f98b8767..a6121f783d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -22,9 +22,11 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_MultiMachine; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; @@ -824,5 +826,46 @@ public abstract class GregtechMeta_MultiBlockBase extends MetaTileEntity { // } + public int getValidOutputSlots(GT_Recipe.GT_Recipe_Map sRecipeMap, ItemStack[] sInputs){ + ArrayList<ItemStack> tInputList = getStoredInputs(); + GT_Recipe tRecipe = sRecipeMap.findRecipe(getBaseMetaTileEntity(), false, 9223372036854775807L, null, sInputs); + ArrayList<Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer>> rList = new ArrayList<Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer>>(); + int tTotalHatches=0; + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { + int hatchUsedSlotCount = 0; + if (isValidMetaTileEntity(tHatch)) { + tTotalHatches++; + for (int i=0; i<tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null){hatchUsedSlotCount++;} + } + rList.add(new Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer>(tHatch, hatchUsedSlotCount)); + } + } + boolean[] mValidOutputSlots = new boolean[tTotalHatches]; + int arrayPos=0; + for (Pair<GT_MetaTileEntity_Hatch_OutputBus, Integer> IE : rList) { + GT_MetaTileEntity_Hatch_OutputBus vTE = IE.getKey(); + int vUsedSlots = IE.getValue(); + if (vUsedSlots == 0){mValidOutputSlots[arrayPos] = true;} + else if (vUsedSlots < vTE.getSizeInventory()){ + int outputItemCount = tRecipe.mOutputs.length; + if (vUsedSlots < vTE.getSizeInventory()-outputItemCount){mValidOutputSlots[arrayPos] = true;} + else if (vUsedSlots >= vTE.getSizeInventory()-outputItemCount){ + if (vUsedSlots > vTE.getSizeInventory()-outputItemCount){if (arrayPos == tTotalHatches){return 0;} /*Change to Hatch total*/ } + } + } + //Hatch is full + if (vUsedSlots == vTE.getSizeInventory()){ + mValidOutputSlots[arrayPos] = false; + if (arrayPos == tTotalHatches){return 0;} // Change to Hatch Total + } + arrayPos++; + } + int tValidOutputSlots = 0; + for (int cr=0;cr<mValidOutputSlots.length;cr++){if (mValidOutputSlots[cr]){tValidOutputSlots++;}} + if (tValidOutputSlots >= 1) {return tValidOutputSlots;} + return 0; + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java new file mode 100644 index 0000000000..49f9fb1344 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechDoubleFuelGeneratorBase.java @@ -0,0 +1,407 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators; + +import static gregtech.api.enums.GT_Values.V; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeTank; + +import java.util.Collection; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public abstract class GregtechDoubleFuelGeneratorBase extends GT_MetaTileEntity_DeluxeTank { + + private boolean useFuel = false; + + public GregtechDoubleFuelGeneratorBase(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, 4, aDescription, aTextures); + } + + public GregtechDoubleFuelGeneratorBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = getFront(i); + rTextures[1][i + 1] = getBack(i); + rTextures[2][i + 1] = getBottom(i); + rTextures[3][i + 1] = getTop(i); + rTextures[4][i + 1] = getSides(i); + rTextures[5][i + 1] = getFrontActive(i); + rTextures[6][i + 1] = getBackActive(i); + rTextures[7][i + 1] = getBottomActive(i); + rTextures[8][i + 1] = getTopActive(i); + rTextures[9][i + 1] = getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + } + + + @Override + public String[] getDescription() { + return new String[]{mDescription, "Fuel Efficiency: " + getEfficiency() + "%", CORE.GT_Tooltip}; + } + + + /* @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + }*/ + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()){ + Utils.LOG_WARNING("Entity is Client side, simply returning true"); + return true; + } + Utils.LOG_WARNING("Entity is not Client side, opening entity Container and by extension, it's GUI, then returning true"); + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + public ITexture[] getFront(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBack(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getBottom(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getTop(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getSides(byte aColor) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + } + + public ITexture[] getFrontActive(byte aColor) { + return getFront(aColor); + } + + public ITexture[] getBackActive(byte aColor) { + return getBack(aColor); + } + + public ITexture[] getBottomActive(byte aColor) { + return getBottom(aColor); + } + + public ITexture[] getTopActive(byte aColor) { + return getTop(aColor); + } + + public ITexture[] getSidesActive(byte aColor) { + return getSides(aColor); + } + + @Override + public boolean isFacingValid(byte aSide) { + return aSide > 1; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return aIndex < 2; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(byte aSide) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public long maxEUOutput() { + return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0; + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[mTier] * 115 + getMinimumStoredEU()); + } + + @Override + public boolean doesFillContainers() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean doesEmptyContainers() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeFilled() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean canTankBeEmptied() { + return getBaseMetaTileEntity().isAllowedToWork(); + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return getFuelValue(aFluid) > 0; + } + + @Override + public long getMinimumStoredEU() { + return 512; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10 == 0) { + if (mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { + mInventory[getStackDisplaySlot()] = null; + } else { + if (mInventory[getStackDisplaySlot()] == null) + mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + } + } else { + if (mFluid != null && mFluid2 != null){ + int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); + int tFuelValue2 = getFuelValue(mFluid2), tConsumed2 = consumedFluidPerOperation(mFluid2); + if ((tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed)/* && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)*/) { + + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName()); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName()); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); + long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + long tFluidAmountToUse2 = Math.min(mFluid2.amount / tConsumed2, (maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2); + + if (tFluidAmountToUse <= 0){ + /*if ((mFluid.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse = 1; + }*/ + + if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ + tFluidAmountToUse = 1; + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse - Updated: "+tFluidAmountToUse); + Utils.LOG_WARNING("========================================================="); + } + } + + if (tFluidAmountToUse2 <= 0){ + /*if ((mFluid2.amount / tConsumed) == getCapacity()){ + tFluidAmountToUse2 = 1; + }*/ + if (aBaseMetaTileEntity.getUniversalEnergyStored() <= (aBaseMetaTileEntity.getEUCapacity()-aBaseMetaTileEntity.getUniversalEnergyStored())){ + tFluidAmountToUse2 = 1; + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse2 - Updated: "+tFluidAmountToUse2); + Utils.LOG_WARNING("========================================================="); + } + } + + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse: "+tFluidAmountToUse); + Utils.LOG_WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid.amount / tConsumed: "+("fluidAmount:"+mFluid.amount)+(" tConsumed:"+tConsumed)+" | "+(mFluid.amount / tConsumed)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue: "+(tFuelValue)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue)); + */ + + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); + Utils.LOG_WARNING("========================================================="); + + /*Utils.LOG_WARNING("mFluid2.amount / tConsumed2: "+("fluidAmount2:"+mFluid2.amount)+(" tConsumed2:"+tConsumed2)+" | "+(mFluid2.amount / tConsumed2)); + Utils.LOG_WARNING("maxEUOutput() * 20 + getMinimumStoredEU(): "+(maxEUOutput() * 30 + getMinimumStoredEU())); + Utils.LOG_WARNING("maxEUOutput(): "+maxEUOutput()); + Utils.LOG_WARNING("maxEUOutput() * 20: "+(maxEUOutput() * 30)); + Utils.LOG_WARNING("getMinimumStoredEU(): "+(getMinimumStoredEU())); + Utils.LOG_WARNING("aBaseMetaTileEntity.getUniversalEnergyStored(): "+(aBaseMetaTileEntity.getUniversalEnergyStored())); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()))); + Utils.LOG_WARNING("tFuelValue2: "+(tFuelValue2)); + Utils.LOG_WARNING("(maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2): "+((maxEUOutput() * 30 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue2)); + */ + if ((tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) && (tFluidAmountToUse2 > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse2 * tFuelValue2, true))){ + + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.name: "+mFluid.getFluid().getName()); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.name: "+mFluid2.getFluid().getName()); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); + + if (useFuel){ + mFluid.amount -= tFluidAmountToUse * tConsumed; + mFluid2.amount -= tFluidAmountToUse2 * tConsumed2; + useFuel = false; + } + else { + useFuel = true; + } + + } + else { + Utils.LOG_WARNING("========================================================="); + Utils.LOG_WARNING("Either tFluidAmountToUse1 <= 0, power cannot be increased of tFluidAmountToUse2 <= 0"); + Utils.LOG_WARNING("tFluidAmountToUse1: "+tFluidAmountToUse); + Utils.LOG_WARNING("tFluidAmountToUse2: "+tFluidAmountToUse2); + } + } + else { + /*Utils.LOG_WARNING("(tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) && (tFuelValue2 > 0 && tConsumed2 > 0 && mFluid2.amount > tConsumed2)"); + Utils.LOG_WARNING("tFuelValue: "+tFuelValue); + Utils.LOG_WARNING("tConsumed: "+tConsumed); + Utils.LOG_WARNING("mFluid.amount: "+mFluid.amount); + Utils.LOG_WARNING("mFluid.amount > tConsumed: "+(mFluid.amount > tConsumed)); + + Utils.LOG_WARNING("========================================================="); + + Utils.LOG_WARNING("tFuelValue2: "+tFuelValue2); + Utils.LOG_WARNING("tConsumed2: "+tConsumed2); + Utils.LOG_WARNING("mFluid2.amount: "+mFluid2.amount); + Utils.LOG_WARNING("mFluid2.amount > tConsumed2: "+(mFluid2.amount > tConsumed2)); */ + } + } + else { + Utils.LOG_WARNING("One mFluid is null"); + if (mFluid != null) + Utils.LOG_WARNING("mFluid1 is not null"); + if (mFluid2 != null) + Utils.LOG_WARNING("mFluid2 is not null"); + } + } + if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { + int tFuelValue = getFuelValue(mInventory[getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); + } + + public abstract GT_Recipe_Map getRecipes(); + + public abstract int getEfficiency(); + + public int consumedFluidPerOperation(FluidStack aLiquid) { + return 1; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null || getRecipes() == null) return 0; + FluidStack tLiquid; + Collection<GT_Recipe> tRecipeList = getRecipes().mRecipeList; + if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) + if (aLiquid.isFluidEqual(tLiquid)) + return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); + return 0; + } + + public int getFuelValue(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); + return 0; + } + + public ItemStack getEmptyContainer(ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; + GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); + if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); + return GT_Utility.getContainerItem(aStack, true); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public int getTankPressure() { + return -100; + } +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java index ddbc5aab96..2c43293e87 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java @@ -10,6 +10,7 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.core.handler.events.UnbreakableBlockManager; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerCache; +import gtPlusPlus.core.util.player.PlayerUtils; import java.util.UUID; @@ -222,8 +223,8 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered //Utils.LOG_WARNING("GUI should now be open for you sir."); } else { - Utils.messagePlayer(aPlayer, "Access Denied, This does not belong to you."); - Utils.messagePlayer(aPlayer, "it is owned by: "+PlayerCache.lookupPlayerByUUID(ownerUUID)); + PlayerUtils.messagePlayer(aPlayer, "Access Denied, This does not belong to you."); + PlayerUtils.messagePlayer(aPlayer, "it is owned by: "+PlayerCache.lookupPlayerByUUID(ownerUUID)); Utils.LOG_WARNING("Expecting Player : "+PlayerCache.lookupPlayerByUUID(ownerUUID)); Utils.LOG_ERROR("Access Denied."); return true; |