aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java
blob: 95e12a5ed91feba8065a0becdcca390ac8fa0b87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package miscutil.gregtech.metatileentity.implementations;

import gregtech.api.enums.Dyes;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_ModHandler;
import miscutil.core.util.Utils;
import miscutil.gregtech.gui.CONTAINER_SteamCondenser;
import miscutil.gregtech.gui.GUI_SteamCondenser;
import miscutil.gregtech.metatileentity.implementations.base.GregtechMetaBoilerBase;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;

public class GregtechMetaCondensor extends GregtechMetaBoilerBase{

	 public GregtechMetaCondensor(int aID, String aName, String aNameRegional)
	  {
	    super(aID, aName, aNameRegional, "A Steam condenser - [IC2->Steam]", new ITexture[0]);
	  }
	  
	  public GregtechMetaCondensor(String aName, int aTier, String aDescription, ITexture[][][] aTextures)
	  {
	    super(aName, aTier, aDescription, aTextures);
	  }
	  
	  @Override
		public String[] getDescription() {
			return new String[] {mDescription, "Added by: "	+ EnumChatFormatting.DARK_GREEN+"Alkalus"};
		}
	  
	  public ITexture[][][] getTextureSet(ITexture[] aTextures)
	  {
	    ITexture[][][] rTextures = new ITexture[5][17][];
	    for (byte i = -1; i < 16; i++){
	      rTextures[0][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa))};
	      rTextures[1][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) };
	      rTextures[2][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) };
	      rTextures[3][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER) };
	      rTextures[4][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_POTIONBREWER_ACTIVE) };
	    }
	    return rTextures;
	  }
	  
	  public int maxProgresstime()
	  {
	    return 1000;
	  }
	  
	  public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity)
	  {
	    return new CONTAINER_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, 32000);
	  }
	  
	  public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity)
	  {
	    return new GUI_SteamCondenser(aPlayerInventory, aBaseMetaTileEntity, "SteelBoiler.png", 32000);
	  }
	  
	  public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity)
	  {
	    return new GregtechMetaCondensor(this.mName, this.mTier, this.mDescription, this.mTextures);
	  }
	  
	  public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick)
	  {
		  this.RI = Utils.randLong(5L, 30L);
	    if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L))
	    {
	      if (this.mTemperature <= 5)
	      {
	        this.mTemperature = 5;
	        this.mLossTimer = 0;
	      }
	      if (++this.mLossTimer > 10)
	      {
	        this.mTemperature -= 1;
	        this.mLossTimer = 0;
	      }
	      for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte)(i + 1)) {
	        if (i != aBaseMetaTileEntity.getFrontFacing())
	        {
	          IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i);
	          if (tTileEntity != null)
	          {
	            FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false);
	            if (tDrained != null)
	            {
	              int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false);
	              if (tFilledAmount > 0) {
	                tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true);
	              }
	            }
	          }
	        }
	      }
	      if (aTick % 10L == 0L) {
	        if (this.mTemperature > 5)
	        {
	          if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0))
	          {
	            this.mHadNoWater = true;
	          }
	          else
	          {
	            if (this.mHadNoWater)
	            {
	              aBaseMetaTileEntity.doExplosion(2048L);
	              return;
	            }
	            this.mFluid.amount -= 1;
	            if (this.mSteam == null) {
	              this.mSteam = GT_ModHandler.getSteam(30L);
	            } else if (GT_ModHandler.isSteam(this.mSteam)) {
	              this.mSteam.amount += 30;
	            } else {
	              this.mSteam = GT_ModHandler.getSteam(30L);
	            }
	          }
	        }
	        else {
	          this.mHadNoWater = false;
	        }
	      }
	      if ((this.mSteam != null) && 
	        (this.mSteam.amount > 32000))
	      {
	        sendSound((byte)1);
	        this.mSteam.amount = 24000;
	      }
	      /*if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && 
	        (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(IC2.getItemFromBlock(p_150898_0_)))))
	      {
	        this.mProcessingEnergy += 1000;
	        aBaseMetaTileEntity.decrStackSize(2, 1);
	        aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L));
	      }*/	      
	      if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % RI == 0L))
	      {
	        this.mProcessingEnergy -= 40;
	        this.mTemperature += 2;
	      }
	      aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0);
	    }
	  }
	  
	  public final int fill(FluidStack aFluid, boolean doFill)
	  {
	    if ((Utils.isIC2Steam(aFluid)) && (this.mProcessingEnergy < 50))
	    {
	      int tFilledAmount = Math.min(50, aFluid.amount);
	      if (doFill) {
	        this.mProcessingEnergy += tFilledAmount;
	      }
	      return tFilledAmount;
	    }
	    return super.fill(aFluid, doFill);
	  }
}