Mekanism

Mekanism

111M Downloads

`teleporterDistance` cost is not properly substracted from `energyContainer`

YegorYellow opened this issue ยท 1 comments

commented

Issue description:

teleporterDistance cost is not properly substracted from energyContainer. Looks like it happens because energyContainer is updated when the entity is already teleported and the distance between entity and target teleport is about 1 block.

Steps to reproduce:

  1. Make sure usage.teleporter.teleporterDistance property in machine-usage.toml is more than one. Better to set big enough so you can notice it
  2. Link two teleports A and B with notable distance between them (let's say 1000 blocks).
  3. Charge teleport A with enough energy for teleportation.
  4. Cut of energy source from teleport A so you will be able to inspect exactly how much energy is spent for the teleportation
  5. Perform teleportation by entering to teleport A
  6. Check teleport A energy container

ER: the energy is substracted with taking in account teleporterDistance parameter and actual distance between teleports
AR: the energy is substracted with taking in account teleporterDistance but not multiplied by actual distance between teleports

Version (make sure you are on the latest version before reporting):

Forge:
Mekanism: 1.16.4-10.0.17.444
Other relevant version: 1.16.4-35.0.15

If a (crash)log is relevant for this issue, link it here:

no crashes

Additional info:

I think it can be fixed in TileEntityTeleporter.java to move
row 258 (energyContainer.extract(...)) to be before row 244 (teleportEntityTo(entity, closestCoords, teleporter);)

I've tested this fix on my local env with on 0287e5f revision.

commented

Ah ya looks like you are right that we should calculate the energy cost before teleporting the entity, even if we don't extract the energy until after teleporting.