Mekanism Additions

Mekanism Additions

21M Downloads

1.15.2 Question about heat API

desht opened this issue ยท 3 comments

commented

Issue description:

(Note: I'm the maintainer of PneumaticCraft: Repressurized)

I thought it might be fun to experiment with some compatibility between Mekanism's and PNC's heat systems, and since both mods handle heat with capabilities, using AttachCapabilitiesEvent to attach adapter capabilities seems the logical way of doing it. And I have it sort-of-working, but I noticed one possible problem with the way Mekanism transfers its heat to neighbours (and this may of course be me not understanding how Mek's heat works).

Anyway, looking specifically at https://github.com/mekanism/Mekanism/blob/1.15x/src/main/java/mekanism/common/capabilities/heat/ITileHeatHandler.java#L56, you call sink.handleHeat(tempToTransfer * heatCapacity);. But isn't heatCapacity here the source's heat capacity? Shouldn't you be using the sink's heat capacity?

What I'm seeing is that when I put a Mekanism Fuelwood Heater (heat capacity: 100) next to a PneumaticCraft Compressed Iron Block (heat capacity: 10), is that the heater is transferring 10 times as much heat as I'd expect it to, because the value passed to sink.handleHeat() is being multiplied by 100 (the heater's capacity) instead of 10 (the compressed iron block's capacity).

I think it's safe to say both mods are treating heat capacity in the same way, i.e. heat_transferred / thermal_capacity = temperature_delta, right?

Thoughts?

commented

Our heat is measured in joules, not degrees; as such, when one block transfers heat to another, it loses exactly as much as the other block gains. Heat calculations involve a change in temperature from a source block, so in order to determine how much heat is transferred we multiply by the source's heat capacity. If we scaled the heat separately by source and destination heat capacity there would be many potential heat energy dupes on our hands.

I hope that makes sense!

commented

By the way, let me know if there's anything I can do to make it easier for you to integrate.

commented

That does make sense, thanks. PNC also distinguishes between heat and temperature, in much the same way Mekanism does.

Playing around with it, I think it's mostly matter of the two mods using significantly different scales for energy yielded, and thermal capacities (e.g. the Fuelwood Heater has a capacity of 100, which is huge by PneumaticCraft standards, and generates 400 heat per tick of fuel, also huge). Obviously fine within the Mekanism environment, but causes an instant huge spike in the Compressed Iron Block (which has a thermal capacity of only 10): https://streamable.com/usmiek

For inter-mod balance purposes, I guess there will simply need to be an efficiency multiplier when heat is transferred...