add IHeatable interface for heating engines, close #1954
This commit is contained in:
parent
90a515c837
commit
a85f7fcade
1 changed files with 34 additions and 12 deletions
|
@ -9,6 +9,8 @@
|
|||
package buildcraft.energy;
|
||||
|
||||
import buildcraft.api.power.IEngine;
|
||||
import buildcraft.api.tiles.IHeatable;
|
||||
import buildcraft.core.utils.MathUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -25,7 +27,7 @@ import buildcraft.core.TileBuffer;
|
|||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.energy.gui.ContainerEngine;
|
||||
|
||||
public abstract class TileEngine extends TileBuildCraft implements IPipeConnection, IEnergyHandler, IEngine {
|
||||
public abstract class TileEngine extends TileBuildCraft implements IPipeConnection, IEnergyHandler, IEngine, IHeatable {
|
||||
// Index corresponds to metadata
|
||||
public static final ResourceLocation[] BASE_TEXTURES = new ResourceLocation[]{
|
||||
new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"),
|
||||
|
@ -55,7 +57,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
public static final ResourceLocation TRUNK_YELLOW_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_yellow.png");
|
||||
public static final ResourceLocation TRUNK_RED_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_red.png");
|
||||
|
||||
public enum EnergyStage {
|
||||
public enum EnergyStage {
|
||||
BLUE, GREEN, YELLOW, RED, OVERHEAT;
|
||||
public static final EnergyStage[] VALUES = values();
|
||||
}
|
||||
|
@ -150,7 +152,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
return energyStage;
|
||||
}
|
||||
|
||||
public void updateHeatLevel() {
|
||||
public void updateHeat() {
|
||||
heat = (float) ((MAX_HEAT - MIN_HEAT) * getEnergyLevel()) + MIN_HEAT;
|
||||
}
|
||||
|
||||
|
@ -158,14 +160,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
return (heat - MIN_HEAT) / (MAX_HEAT - MIN_HEAT);
|
||||
}
|
||||
|
||||
public float getIdealHeatLevel() {
|
||||
return heat / IDEAL_HEAT;
|
||||
}
|
||||
|
||||
public float getHeat() {
|
||||
return heat;
|
||||
}
|
||||
|
||||
public float getPistonSpeed() {
|
||||
if (!worldObj.isRemote) {
|
||||
return Math.max(0.16f * getHeatLevel(), 0.01f);
|
||||
|
@ -214,7 +208,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
}
|
||||
}
|
||||
|
||||
updateHeatLevel();
|
||||
updateHeat();
|
||||
getEnergyStage();
|
||||
engineUpdate();
|
||||
|
||||
|
@ -568,4 +562,32 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// IHeatable
|
||||
|
||||
@Override
|
||||
public double getMinHeatValue() {
|
||||
return MIN_HEAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getIdealHeatValue() {
|
||||
return IDEAL_HEAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHeatValue() {
|
||||
return MAX_HEAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCurrentHeatValue() {
|
||||
return heat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double setHeatValue(double value) {
|
||||
heat = (float) MathUtils.clamp(value, MIN_HEAT, MAX_HEAT);
|
||||
return heat;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue