mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-28 07:56:01 +00:00
Make Smelteries use the fuel API. Should work, but somebody properly test this with servers.
This commit is contained in:
1 parent
02c4b119a3
commit
c09de4b135
2 files changed
+70
-25
No files matched your search
@@ -179,7 +179,7 @@ public class SmelteryGui extends NewContainerGui
|
||||
this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
if (logic.fuelGague > 0)
|
||||
{
|
||||
IIcon lavaIcon = Blocks.lava.getIcon(0, 0);
|
||||
IIcon lavaIcon = logic.getFuelIcon();
|
||||
int fuel = logic.getScaledFuelGague(52);
|
||||
int count = 0;
|
||||
while (fuel > 0)
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import mantle.blocks.abstracts.MultiServantLogic;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
@@ -31,6 +33,7 @@ import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -62,8 +65,8 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
CoordTuple activeLavaTank;
|
||||
public CoordTuple centerPos = new CoordTuple(0, 0, 0);
|
||||
|
||||
public int[] activeTemps;
|
||||
public int[] meltingTemps;
|
||||
public int[] activeTemps; // values are multiplied by 10
|
||||
public int[] meltingTemps; // values are multiplied by 10
|
||||
int tick;
|
||||
|
||||
public ArrayList<FluidStack> moltenMetal = new ArrayList<FluidStack>();
|
||||
@@ -111,8 +114,8 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
{
|
||||
for (int i = tempActive.length; i < activeTemps.length; i++)
|
||||
{
|
||||
activeTemps[i] = 20;
|
||||
meltingTemps[i] = 20;
|
||||
activeTemps[i] = 200;
|
||||
meltingTemps[i] = 200;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,17 +256,20 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
|
||||
public int getInternalTemperature ()
|
||||
{
|
||||
if(!validStructure)
|
||||
return 20;
|
||||
|
||||
return internalTemp;
|
||||
}
|
||||
|
||||
public int getTempForSlot (int slot)
|
||||
{
|
||||
return activeTemps[slot];
|
||||
return activeTemps[slot]/10;
|
||||
}
|
||||
|
||||
public int getMeltingPointForSlot (int slot)
|
||||
{
|
||||
return meltingTemps[slot];
|
||||
return meltingTemps[slot]/10;
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
@@ -273,7 +279,6 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
/*
|
||||
* if (worldObj.isRemote) return;
|
||||
*/
|
||||
|
||||
tick++;
|
||||
if (tick % 4 == 0)
|
||||
heatItems();
|
||||
@@ -426,19 +431,22 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
}
|
||||
}
|
||||
|
||||
void heatItems ()
|
||||
private void heatItems ()
|
||||
{
|
||||
if (useTime > 0)
|
||||
{
|
||||
boolean hasUse = false;
|
||||
int temperature = this.getInternalTemperature();
|
||||
int speed = temperature/100;
|
||||
int refTemp = temperature*10;
|
||||
for (int i = 0; i < 9 * layers; i++)
|
||||
{
|
||||
if (meltingTemps[i] > 20 && this.isStackInSlot(i))
|
||||
if (meltingTemps[i] > 200 && this.isStackInSlot(i))
|
||||
{
|
||||
hasUse = true;
|
||||
if (activeTemps[i] < internalTemp && activeTemps[i] < meltingTemps[i])
|
||||
if (activeTemps[i] < refTemp && activeTemps[i] < meltingTemps[i])
|
||||
{
|
||||
activeTemps[i] += 1;
|
||||
activeTemps[i] += speed; // lava has temp of 1000. we increase by 10 per application.
|
||||
}
|
||||
else if (activeTemps[i] >= meltingTemps[i])
|
||||
{
|
||||
@@ -450,7 +458,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
if (addMoltenMetal(result, false))
|
||||
{
|
||||
inventory[i] = null;
|
||||
activeTemps[i] = 20;
|
||||
activeTemps[i] = 200;
|
||||
ArrayList alloys = Smeltery.mixMetals(moltenMetal);
|
||||
for (int al = 0; al < alloys.size(); al++)
|
||||
{
|
||||
@@ -466,7 +474,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
}
|
||||
|
||||
else
|
||||
activeTemps[i] = 20;
|
||||
activeTemps[i] = 200;
|
||||
}
|
||||
inUse = hasUse;
|
||||
}
|
||||
@@ -516,12 +524,12 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
}
|
||||
}
|
||||
|
||||
void updateTemperatures ()
|
||||
private void updateTemperatures ()
|
||||
{
|
||||
inUse = true;
|
||||
for (int i = 0; i < 9 * layers; i++)
|
||||
{
|
||||
meltingTemps[i] = Smeltery.instance.getLiquifyTemperature(inventory[i]);
|
||||
meltingTemps[i] = Smeltery.getLiquifyTemperature(inventory[i])*10; // temperatures are *10 for more progress control
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,7 +556,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
if (tankContainer instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 4000, false);
|
||||
if (liquid != null && liquid.getFluid().getBlock() == Blocks.lava)
|
||||
if (liquid != null && Smeltery.isSmelteryFuel(liquid.getFluid()))
|
||||
{
|
||||
FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN);
|
||||
if (info.length > 0)
|
||||
@@ -589,11 +597,12 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
if (tankContainer instanceof IFluidHandler)
|
||||
{
|
||||
needsUpdate = true;
|
||||
FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 150, false);
|
||||
if (liquid != null && liquid.getFluid().getBlock() == Blocks.lava)
|
||||
FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 15, false);
|
||||
if (liquid != null && Smeltery.isSmelteryFuel(liquid.getFluid()))
|
||||
{
|
||||
liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 150, true);
|
||||
useTime += liquid.amount;
|
||||
liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, 15, true);
|
||||
useTime += Smeltery.getFuelDuration(liquid.getFluid());
|
||||
internalTemp = Smeltery.getFuelPower(liquid.getFluid());
|
||||
|
||||
FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN);
|
||||
liquid = info[0].fluid;
|
||||
@@ -621,7 +630,7 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
{
|
||||
// TConstruct.logger.info("Tank: "+possibleTank.toString());
|
||||
FluidStack newliquid = ((IFluidHandler) newTankContainer).drain(ForgeDirection.UNKNOWN, 150, false);
|
||||
if (newliquid != null && newliquid.getFluid().getBlock() == Blocks.lava && newliquid.amount > 0)
|
||||
if (newliquid != null && Smeltery.isSmelteryFuel(newliquid.getFluid()) && newliquid.amount > 0)
|
||||
{
|
||||
// TConstruct.logger.info("Tank: "+possibleTank.toString());
|
||||
foundTank = true;
|
||||
@@ -658,9 +667,23 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getFuelIcon()
|
||||
{
|
||||
IIcon defaultLava = Blocks.lava.getIcon(0,0);
|
||||
if(activeLavaTank == null)
|
||||
return defaultLava;
|
||||
|
||||
TileEntity tankContainer = worldObj.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z);
|
||||
if (tankContainer instanceof IFluidHandler)
|
||||
return ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN)[0].fluid.getFluid().getStillIcon();
|
||||
|
||||
return defaultLava;
|
||||
}
|
||||
|
||||
public FluidStack getResultFor (ItemStack stack)
|
||||
{
|
||||
return Smeltery.instance.getSmelteryResult(stack);
|
||||
return Smeltery.getSmelteryResult(stack);
|
||||
}
|
||||
|
||||
/* Inventory */
|
||||
@@ -777,8 +800,30 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
|
||||
{
|
||||
if (tempValidStructure)
|
||||
{
|
||||
internalTemp = 1000;
|
||||
activeLavaTank = lavaTanks.get(0);
|
||||
// try to derive temperature from fueltank
|
||||
activeLavaTank = null;
|
||||
for(CoordTuple tank : lavaTanks)
|
||||
{
|
||||
TileEntity tankContainer = worldObj.getTileEntity(tank.x, tank.y, tank.z);
|
||||
if(!(tankContainer instanceof IFluidHandler))
|
||||
continue;
|
||||
|
||||
FluidStack liquid = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN)[0].fluid;
|
||||
if(liquid == null)
|
||||
return;
|
||||
if(!Smeltery.isSmelteryFuel(liquid.getFluid()))
|
||||
continue;
|
||||
|
||||
internalTemp = Smeltery.getFuelPower(liquid.getFluid());
|
||||
activeLavaTank = tank;
|
||||
break;
|
||||
}
|
||||
|
||||
// no tank with fuel. we reserve the first found one
|
||||
if(activeLavaTank == null)
|
||||
activeLavaTank = lavaTanks.get(0);
|
||||
|
||||
// update other stuff
|
||||
adjustLayers(checkLayers, false);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
validStructure = true;
|
||||
|
||||
Reference in new issue
Block a user