Cuberite Forum
How to override physics? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: How to override physics? (/thread-3158.html)



How to override physics? - TC1061 - 01-13-2018

How to override physics in Cuberite? Is there any hook to do this? For example:
Code:
IsFallingEnabled=true
function OnBlockFalling(Block,x,y,z)
  if IsFallingEnabled then
    return false -- Allow block to fall
  else
    return true -- Prevent block from falling
  end
end

function EntityPhysicsTick(Entity,dx,dy,dz)
  -- Do something
  return true -- Do not call any other plugins
end



RE: How to override physics? - xoft - 01-14-2018

There's currently no direct way to override physics, sorry. WHat you could, theoretically, do, is the hard way - intercept the cFallingBlock entity creation, don't let Cuberite create the entity and possibly re-set the block back, if Cuberite / client doesn't do that on its own. As for entities / mobs, there's not much to intercept, really, because we still need proper code refactor for all entities before sticking things out through an API that could potentially become very obsolete soon(ish).