reworked blaze heater heating system (again)

This commit is contained in:
LordGrimmauld 2020-07-14 17:23:07 +02:00
parent 376b6cc851
commit ffb1b17626

View File

@ -18,7 +18,7 @@ import net.minecraftforge.common.ForgeHooks;
public class HeaterTileEntity extends SmartTileEntity {
private int fuelLevel;
private int burnTimeRemaining;
private static final int maxHeatCapacity = 5000;
private static final int maxHeatCapacity = 10000;
public HeaterTileEntity(TileEntityType<? extends HeaterTileEntity> tileEntityTypeIn) {
super(tileEntityTypeIn);
@ -32,11 +32,11 @@ public class HeaterTileEntity extends SmartTileEntity {
super.tick();
if (burnTimeRemaining > 0) {
burnTimeRemaining--;
if (burnTimeRemaining <= 0 && fuelLevel > 0) {
if (burnTimeRemaining <= 0 && fuelLevel > 1) {
fuelLevel--;
burnTimeRemaining = maxHeatCapacity / 2;
updateHeatLevel();
}
updateHeatLevel();
markDirty();
}
}
@ -71,7 +71,7 @@ public class HeaterTileEntity extends SmartTileEntity {
boolean specialFuelUsed = itemStack.getItem() == AllItems.FUEL_PELLET.get();
int burnTime =
itemStack.getItem() == Items.EGG ? 150 : (specialFuelUsed ? 1000 : ForgeHooks.getBurnTime(itemStack));
int newFuelLevel = (specialFuelUsed ? 3 : 2);
int newFuelLevel = (specialFuelUsed ? 2 : 1);
if (burnTime <= 0 || newFuelLevel < fuelLevel)
return false;
if (newFuelLevel > this.fuelLevel) {
@ -91,6 +91,12 @@ public class HeaterTileEntity extends SmartTileEntity {
}
private void updateHeatLevel() {
HeaterBlock.setBlazeLevel(world, pos, 1 + fuelLevel);
if (fuelLevel == 2)
HeaterBlock.setBlazeLevel(world, pos, 4);
else if (fuelLevel == 0 || burnTimeRemaining <= 0)
HeaterBlock.setBlazeLevel(world, pos, 1);
else {
HeaterBlock.setBlazeLevel(world, pos, (double) burnTimeRemaining / maxHeatCapacity > 0.1 ? 3 : 2);
}
}
}