SlimeVoid / DynamicTransport

7 stars 7 forks source link

Consider a way to create blocks that will move riders instead of the entity(Up only) #10

Closed Tarig0 closed 10 years ago

Tarig0 commented 10 years ago

It seems impossible to use an entity to push a player up with any kind of lag, due to mojangs attempts to keep lag issues down.

Thuamcraft and Thumanic Tinkers use blocks to move entities, we could create ghost blocks that "follow" the elevator up and down transferring the current motion from the elevator block to an entitys within the blocks bounds, (which could be changed depending on the location of the elevator.)

ex. single elevator entity is moving up at motion y = 2 the curent center of the entity is at y = 60 or the top,bottom 60.5 - 59.5.

This will set two motion blocks at y 60 and 59.

These blocks on collision will first ignore the elevator, and then detect if there is any other entities within it's full block bounds.

if entity detected

  1. quickly scan for the elevator entity (we do this here since we can't guarantee the elevator will be the first entity colliding with this block)
  2. extract the current position of the elevator and motion Y
  3. check if the entity is withing .5 meters of the topY of the elevator
  4. if so add the current elevator motion y to the entity

Blocks should self check if they contain an elevator on random tick/ collision and kill themselves if no elevator is found.

Tarig0 commented 10 years ago

Considering a tick handler.

if (loaded entity list contains Dynamic Transport entities) check if those elevator blocks have any entities colliding or just above them and add the appropriate motion to them.

Eurymachus commented 10 years ago

Ew no! Not on tick, no need.

We can just store static HashMap <EntityPlayer, Integer> playersOnElevators

When an Elevator spawns it does if isplayer then playersOnElevators.put(player, elevatorId)

in Player tick handler if playerIsOnElevator then set motionY = getElevator(elevatorId).motionY

All server side of course.

Winning!

Eurymachus commented 10 years ago

We may still run into the same problem, but its a start.

Tarig0 commented 10 years ago

The issue is that motion Y for player needs to be calculated on the client side.

I think the client tick event is what we are going to need

this is the one case where all server side is losing

Tarig0 commented 10 years ago

We have two options on Player Client Tick, or simply Client Tick.

I'm leaning towards Player client

Player Client Tick will allow us to have each player check if they are standing on an elevator, simple and works.

Then on elevator tick we ignore any player entities and do what we do with the other entities.

The only thing left after that is why does item entities fall through the elevator.

Eurymachus commented 10 years ago

Yep! For consistent updates.

Sent from Windows Mail

From: Allen Cook Sent: ‎Friday‎, ‎3‎ ‎January‎ ‎2014 ‎09‎:‎43 To: SlimeVoid/DynamicTransport Cc: Greg Jones

We have two options on Player Client Tick, or simply Client Tick.

I'm leaning towards Player client

Player Client Tick will allow us to have each player check if they are standing on an elevator, simple and works.

Then on elevator tick we ignore any player entities and do what we do with the other entities.

— Reply to this email directly or view it on GitHub.

Tarig0 commented 10 years ago

Almost, I've looked at the entity code and compared it to the EntityArrow and I think we have the entity only being updated on the server side is incorrect

Tarig0 commented 10 years ago

Made it so the entity updates client and server, and passes the destination to client so the elevator gets updated with the correct logic.

Tarig0 commented 10 years ago

NO go at least with major lag, possibility of setting max speed by server config? Think the only thing left is to slow down the elevator, currently moves faster that creative flying

Tarig0 commented 10 years ago

Done