SwitchCraftCC / Plethora-Fabric

A peripheral provider for ComputerCraft, ported to Fabric
MIT License
16 stars 13 forks source link

fix: entity motion inconsistencies #55

Closed hugeblank closed 1 year ago

hugeblank commented 1 year ago

Fixes SwitchCraftCC/Plethora-Fabric#52.

Adds a pair of mixins that calculate velocity from the entity's current position and the position in the tick prior.

Test program:

local mods = peripheral.wrap("back")
mods.canvas().clear()
local text = mods.canvas().addText({0,0}, "")
while true do
    local meta = mods.getMetaOwner()
    text.setText(meta.motionX.." "..meta.motionY.." "..meta.motionZ)
end

Use on NI with introspection module, overlay glasses, and entity sensor. Move around, see velocity change.

hugeblank commented 1 year ago

When changing dimensions, for a single tick, the entity velocity spikes. Should this be intended behavior? Some alternatives:

  1. Providing the dimension the entity is in in the metadata so the player can account for this programmatically.
  2. Storing positions per dimension. This has the side effect that when entering the nether, heading to another portal and exiting the nether through it, the overworld velocity will spike.
  3. Assuming the entity's velocity is always 0 when entering any dimension. I think this might be the best bet, but I like the idea of exposing the dimension the entity is in too...
Lemmmy commented 1 year ago

LGTM, Huge thanks for this!