use of net.minecraft.util.EntityDamageSource in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class FuelHandler method manageSteam.
public void manageSteam(EntityTrainCore train) {
//manage solid fuel
if (isFuel(train.getStackInSlot(0), train) && fuel + TileEntityFurnace.getItemBurnTime(train.getStackInSlot(0)) < train.getMaxFuel()) {
fuel += TileEntityFurnace.getItemBurnTime(train.getStackInSlot(0));
lastFuelConsumed = train.getStackInSlot(0).getItem();
if (!train.getBoolean(GenericRailTransport.boolValues.CREATIVE)) {
train.decrStackSize(0, 1);
}
}
//if there's a fluid item in the slot and the train can consume the entire thing
if (train.getStackInSlot(1) != null && train.fill(null, isUseableFluid(train.getStackInSlot(1), train), false) >= FluidContainerRegistry.getFluidForFilledItem(train.getStackInSlot(1)).amount) {
train.fill(null, isUseableFluid(train.getStackInSlot(1), train), true);
if (!train.getBoolean(GenericRailTransport.boolValues.CREATIVE)) {
train.decrStackSize(1, 1);
train.addItem(new ItemStack(Items.bucket));
}
}
//be sure there is fuel before trying to consume it
if (fuel > 0) {
/*
* add steam from burning to the steam tank.
* steam is equal to water used, minus a small percentage to compensate for impurities in the water that don't transition to steam,
* the amount of water used is generated from heat which is one part fuel 2 parts air, with more fuel burning more heat is created, but this only works to a point.
* steam beyond the max point of storage is considered to be expelled through a failsafe.
* NOTE: in TiM we need to remember steam and fluid are housed in the same tank, and calculate based on that. should also throw in calcium buildup for non-distilled water. TC however isn't so advanced
*/
int steam = Math.round(//calculate heat from fuel
(fuel * 0.00075f) * //calculate surface area of water
(train.getTankAmount() * 0.005f));
if (train.drain(null, steam, true) != null) {
//a lava bucket lasts 1000 seconds, so burnables are processed at 20000*0.05 a second
fuel -= 10 * train.getEfficiency();
steamTank += steam;
if (steamTank > train.getTankCapacity()) {
//in TiM it needs to be > getTankCapacity-getTankAmount.
steamTank = train.getTankCapacity();
}
} else if (!train.getBoolean(GenericRailTransport.boolValues.CREATIVE)) {
train.worldObj.createExplosion(train, train.posX, train.posY, train.posZ, 5f, false);
train.dropItem(train.getItem(), 1);
train.attackEntityFromPart(null, new EntityDamageSource("overheat", train), 100);
}
} else if (fuel < 0) {
fuel = 0;
}
if (steamTank > 0) {
train.setBoolean(GenericRailTransport.boolValues.RUNNING, true);
//steam is expelled through the pistons to push them back and forth, but even when the accelerator is off, a degree of steam is still escaping.
steamTank -= (5 * train.getEfficiency()) * ((train.accelerator) * train.getEfficiency());
} else {
train.setBoolean(GenericRailTransport.boolValues.RUNNING, false);
}
}
Aggregations