diff options
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Diesel.java | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Diesel.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Diesel.java new file mode 100644 index 0000000000..ddd11bb338 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Diesel.java @@ -0,0 +1,128 @@ +package gregtech.common.tileentities.machines.multi; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.Collection; + +public class GT_MetaTileEntity_LargeTurbine_Diesel extends GT_MetaTileEntity_LargeTurbine { + + public GT_MetaTileEntity_LargeTurbine_Diesel(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_LargeTurbine_Diesel(String aName) { + super(aName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE_ACTIVE5) : new GT_RenderedTexture(Textures.BlockIcons.LARGETURBINE5) : Textures.BlockIcons.CASING_BLOCKS[57]}; + } + + + public String[] getDescription() { + return new String[]{ + "Controller Block for the Large Diesel Generator", + "Size: 3x4x3 (Hollow)", "Controller (front centered)", + "1x Input Hatch (side centered)", + "1x Dynamo Hatch (back centered)", + "1x Maintenance Hatch (side centered)", + "Turbine Casings for the rest (24 at least!)", + "Needs a Turbine Item (inside controller GUI)"}; + } + + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null || GT_Recipe_Map.sTurbineFuels == null) return 0; + FluidStack tLiquid; + Collection<GT_Recipe> tRecipeList = GT_Recipe_Map.sDieselFuels.mRecipeList; + if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) + if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) + if (aLiquid.isFluidEqual(tLiquid)) return tFuel.mSpecialValue; + return 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_LargeTurbine_Plasma(mName); + } + + @Override + public Block getCasingBlock() { + return GregTech_API.sBlockCasings4; + } + + @Override + public byte getCasingMeta() { + return 9; + } + + @Override + public byte getCasingTextureIndex() { + return 46; + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return 0; + } + + @Override + int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) { + + aOptFlow *= 5; + int tEU = 0; + + int actualOptimalFlow = 0; + + if (aFluids.size() >= 1) { + FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest! + int fuelValue = getFuelValue(firstFuelType); + actualOptimalFlow = (int) ((aOptFlow + fuelValue - 1) / fuelValue); + + int remainingFlow = (int) (actualOptimalFlow * 1.25f); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios. + int flow = 0; + int totalFlow = 0; + + for (int i = 0; i < aFluids.size(); i++) { + if (aFluids.get(i).isFluidEqual(firstFuelType)) { + flow = aFluids.get(i).amount; // Get all (steam) in hatch + flow = Math.min(flow, Math.min(remainingFlow, (int) (actualOptimalFlow * 1.25f))); // try to use up to 125% of optimal flow w/o exceeding remainingFlow + depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount + remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches + totalFlow += flow; // track total input used + } + } + + tEU = (int) (Math.min((float) actualOptimalFlow, totalFlow) * fuelValue); + + if (totalFlow != actualOptimalFlow) { + float efficiency = 1.0f - Math.abs(((totalFlow - (float) actualOptimalFlow) / actualOptimalFlow)); + if(totalFlow>aOptFlow){efficiency = 1.0f;} + if (efficiency < 0) + efficiency = 0; // Can happen with really ludicrously poor inefficiency. + tEU *= efficiency; + tEU = Math.max(1, tEU * aBaseEff / 10000); + } else { + tEU = tEU * aBaseEff / 10000; + } + + return tEU; + + } + return 0; + } + + +} |