aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities
diff options
context:
space:
mode:
authorPrometheus0000000 <prometheus0000000@gmail.com>2020-11-03 03:25:11 -0500
committerPrometheus0000000 <prometheus0000000@gmail.com>2020-11-03 03:25:11 -0500
commite13b3764e3e452ba14a96f49fdc32a520c7f2085 (patch)
treefc0eee7746102dd49bc8e30075c691405e4af3b1 /src/main/java/gregtech/common/tileentities
parent646beaf2a6bbddb1b03a0cc2c25711762aecf98e (diff)
downloadGT5-Unofficial-e13b3764e3e452ba14a96f49fdc32a520c7f2085.tar.gz
GT5-Unofficial-e13b3764e3e452ba14a96f49fdc32a520c7f2085.tar.bz2
GT5-Unofficial-e13b3764e3e452ba14a96f49fdc32a520c7f2085.zip
Added IV HOG only LCE
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java289
1 files changed, 289 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java
new file mode 100644
index 0000000000..f38f0a1de2
--- /dev/null
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ExtremeDieselEngine.java
@@ -0,0 +1,289 @@
+package gregtech.common.tileentities.machines.multi;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.Textures;
+import gregtech.api.gui.GT_GUIContainer_MultiMachine;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.FluidStack;
+
+public class GT_MetaTileEntity_ExtremeDieselEngine extends GT_MetaTileEntity_MultiBlockBase {
+ protected int fuelConsumption = 0;
+ protected int fuelValue = 0;
+ protected int fuelRemaining = 0;
+ protected boolean boostEu = false;
+
+ public GT_MetaTileEntity_ExtremeDieselEngine(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GT_MetaTileEntity_ExtremeDieselEngine(String aName) {
+ super(aName);
+ }
+
+ public String[] getDescription() {
+ return new String[]{
+ "Controller Block for the Extreme Combustion Engine",
+ "Size(WxHxD): 3x3x4, Controller (front centered)",
+ "3x3x4 of Robust Tungstensteel Machine Casing (hollow, Min 16!)",
+ "2x Titanium Gear Box Machine Casing inside the Hollow Casing",//todo
+ "8x Extreme Engine Intake Casing (around controller)",
+ "2x Input Hatch (HOG/Lubricant) (one of the Casings next to a Gear Box)",
+ "1x Input Hatch (Optional, for Liquid Oxygen) (one of the Casings next to a Gear Box)",
+ "1x Maintenance Hatch (one of the Casings next to a Gear Box)",
+ "1x Muffler Hatch (top middle back, above the rear Gear Box)",
+ "1x Dynamo Hatch (back centered)",
+ "Engine Intake Casings must not be obstructed in front (only air blocks)",
+ "Supply High Octane Gasoline and 8000L of Lubricant per hour to run.",
+ "Supply 320L of Liquid Oxygen per second to boost output (optional).",
+ "Default: Produces 8192EU/t at 100% efficiency",
+ "Boosted: Produces 32768EU/t at 400% efficiency",
+ "Causes " + 20 * getPollutionPerTick(null) + " Pollution per second"};
+ }
+
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if (aSide == aFacing) {
+ return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][60], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_EXTREME_DIESEL_ENGINE)};
+ }
+ return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][60]};//controller texture? where do I find this? Copied plasma turbine
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack aStack) {
+ return getMaxEfficiency(aStack) > 0;
+ }
+
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "LargeExtremeDieselEngine.png");//change
+ }
+
+ @Override
+ public boolean checkRecipe(ItemStack aStack) {
+ ArrayList<FluidStack> tFluids = getStoredFluids();
+ Collection<GT_Recipe> tRecipeList = GT_Recipe.GT_Recipe_Map.sDieselFuels.mRecipeList;
+
+ if(tFluids.contains(Materials.GasolinePremium.getFluid(4L))) { //Does input hatch contain HOG?
+ for (FluidStack hatchFluid1 : tFluids) { //Loops through hatches
+ for(GT_Recipe aFuel : tRecipeList) { //Loops through diesel fuel recipes dd. Can't remove because I suck at coding
+ FluidStack tLiquid;
+
+ if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != null) { //Create fluidstack from current recipe
+ if (hatchFluid1.isFluidEqual(tLiquid)) { //Has a diesel fluid
+ fuelConsumption = tLiquid.amount = boostEu ? (8192 / aFuel.mSpecialValue) : (2048 / aFuel.mSpecialValue); //Calc fuel consumption
+ if(depleteInput(tLiquid)) { //Deplete that amount ^Doesn't give bonus to fuel usage anymore
+ boostEu = depleteInput(Materials.LiquidOxygen.getGas(16L));//x8, and LOX instead
+
+ if(tFluids.contains(Materials.Lubricant.getFluid(8L))) { //Has lubricant?
+ //Deplete Lubricant. 8000L should = 1 hour of runtime (if baseEU = 8192)
+ if(mRuntime % 72 == 0 || mRuntime == 0) depleteInput(Materials.Lubricant.getFluid(boostEu ? 16 : 8));//x8
+ } else return false;
+
+ fuelValue = aFuel.mSpecialValue;
+ fuelRemaining = hatchFluid1.amount; //Record available fuel
+ this.mEUt = mEfficiency < 2000 ? 0 : 8192; //Output 0 if startup is less than 20%
+ this.mProgresstime = 1; //will output 8192 normally, 32768 boosted
+ this.mMaxProgresstime = 1;
+ this.mEfficiencyIncrease = 15;
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ this.mEUt = 0;
+ this.mEfficiency = 0;
+ return false;
+ }
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ byte tSide = getBaseMetaTileEntity().getBackFacing();
+ int tX = getBaseMetaTileEntity().getXCoord();
+ int tY = getBaseMetaTileEntity().getYCoord();
+ int tZ = getBaseMetaTileEntity().getZCoord();
+
+ if(getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 1) != getGearboxBlock() && getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, 2) != getGearboxBlock()) {
+ return false;
+ }
+ if(getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 1) != getGearboxMeta() && getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, 2) != getGearboxMeta()) {
+ return false;
+ }
+ for (byte i = -1; i < 2; i = (byte) (i + 1)) {
+ for (byte j = -1; j < 2; j = (byte) (j + 1)) {
+ if ((i != 0) || (j != 0)) {
+ for (byte k = 0; k < 4; k = (byte) (k + 1)) {
+
+ final int fX = tX - (tSide == 5 ? 1 : tSide == 4 ? -1 : i),
+ fZ = tZ - (tSide == 2 ? -1 : tSide == 3 ? 1 : i),
+ aY = tY + j,
+ aX = tX + (tSide == 5 ? k : tSide == 4 ? -k : i),
+ aZ = tZ + (tSide == 2 ? -k : tSide == 3 ? k : i);
+
+ final Block frontAir = getBaseMetaTileEntity().getBlock(fX, aY, fZ);
+ final String frontAirName = frontAir.getUnlocalizedName();
+ if(!(getBaseMetaTileEntity().getAir(fX, aY, fZ) || frontAirName.equalsIgnoreCase("tile.air") || frontAirName.equalsIgnoreCase("tile.railcraft.residual.heat"))) {
+ return false; //Fail if vent blocks are obstructed
+ }
+
+ if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2))) {
+ if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) {
+ // Do nothing
+ } else if (!addMufflerToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? 2 : tSide == 4 ? -2 : 0), tY + 1, tZ + (tSide == 3 ? 2 : tSide == 2 ? -2 : 0)), getCasingTextureIndex())) {
+ return false; //Fail if no muffler top middle back
+ } else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(aX, aY, aZ))) {
+ return false;
+ }
+ } else if (k == 0) {
+ if(!(getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getIntakeBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getIntakeMeta())) {
+ return false;
+ }
+ } else if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) {
+ // Do nothing
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ this.mDynamoHatches.clear();
+ IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3);
+ if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) {
+ if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Dynamo)) {
+ this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) tTileEntity.getMetaTileEntity());
+ ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).updateTexture(getCasingTextureIndex());
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public Block getCasingBlock() {//changed to RTSMC
+ return GregTech_API.sBlockCasings4;
+ }
+
+ public byte getCasingMeta() {//same
+ return 0;
+ }
+
+ public Block getIntakeBlock() {
+ return GregTech_API.sBlockCasings8;//added new
+ }
+
+ public byte getIntakeMeta() {//same
+ return 4;
+ }
+
+ public Block getGearboxBlock() {
+ return GregTech_API.sBlockCasings2;
+ }
+
+ public byte getGearboxMeta() {
+ return 4;
+ }
+
+ public byte getCasingTextureIndex() {//should be what hatches/busses change to?
+ return 60;
+ }
+
+ private boolean addToMachineList(IGregTechTileEntity tTileEntity) {
+ return ((addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex())) || (addInputToMachineList(tTileEntity, getCasingTextureIndex())) || (addOutputToMachineList(tTileEntity, getCasingTextureIndex())) || (addMufflerToMachineList(tTileEntity, getCasingTextureIndex())));
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_ExtremeDieselEngine(this.mName);
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack aStack) {
+ return 1;
+ }
+
+ public int getMaxEfficiency(ItemStack aStack) {
+ return boostEu ? 40000 : 10000;//4x output if boosted instead of x3
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack aStack) {
+ return 192;//x8
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public String[] getInfoData() {
+ int mPollutionReduction=0;
+ for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) {
+ if (isValidMetaTileEntity(tHatch)) {
+ mPollutionReduction=Math.max(tHatch.calculatePollutionReduction(100),mPollutionReduction);
+ }
+ }
+
+ long storedEnergy=0;
+ long maxEnergy=0;
+ for(GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) {
+ if (isValidMetaTileEntity(tHatch)) {
+ storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU();
+ maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity();
+ }
+ }
+
+
+ return new String[]{
+ EnumChatFormatting.BLUE+"Extreme Diesel Engine"+EnumChatFormatting.RESET,
+ StatCollector.translateToLocal("GT5U.multiblock.energy")+": " +
+ EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+
+ EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU",
+ getIdealStatus() == getRepairStatus() ?
+ EnumChatFormatting.GREEN+StatCollector.translateToLocal("GT5U.turbine.maintenance.false")+EnumChatFormatting.RESET :
+ EnumChatFormatting.RED+StatCollector.translateToLocal("GT5U.turbine.maintenance.true")+EnumChatFormatting.RESET,
+ StatCollector.translateToLocal("GT5U.engine.output")+": " +EnumChatFormatting.RED+(-mEUt*mEfficiency/10000)+EnumChatFormatting.RESET+" EU/t",
+ StatCollector.translateToLocal("GT5U.engine.consumption")+": " +EnumChatFormatting.YELLOW+fuelConsumption+EnumChatFormatting.RESET+" L/t",
+ StatCollector.translateToLocal("GT5U.engine.value")+": " +EnumChatFormatting.YELLOW+fuelValue+EnumChatFormatting.RESET+" EU/L",
+ StatCollector.translateToLocal("GT5U.turbine.fuel")+": " +EnumChatFormatting.GOLD+fuelRemaining+EnumChatFormatting.RESET+" L",
+ StatCollector.translateToLocal("GT5U.engine.efficiency")+": " +EnumChatFormatting.YELLOW+(mEfficiency/100F)+EnumChatFormatting.YELLOW+" %",
+ StatCollector.translateToLocal("GT5U.multiblock.pollution")+": " + EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %"
+
+ };
+ }
+
+ @Override
+ public boolean isGivingInformation() {
+ return true;
+ }
+
+}