Add SteerVehicleEvent
We have
RideEntityEvent. While this seems to be specific toVehicles, should this event really be a sub-event of that?
Quoting the Javadoc, RideEntityEvent is "an event that involves an entity riding another." While this is fine for mount & dismount, only a player can steer a vehicle.
Taking over this.
Changed the API to be more friendly to consume. This is at least somewhat how I would imagine the values would be exposed.
The input can be directly used to manipulate the entitys velocity.
Also to add; This event is completly based on input. It does not take into account the current velocity, movement or direction.
If the plugin developer wants to make the entity controllable by the rider, it should use the riders direction and then add velocity to the entity based on the input.
I really don't know what I think about this - other than it's become a victim of ideas rather than solving a specific problem.
What is the problem we want to solve? To be able to stop someone from steering clockwise/counter-clockwise? Or is there some more fine grained control we need? Once we know what we want to do, we can design the event around that.
We are trying to solve how can we allow plugin to take control of how vehicle is being moved based on controls given by the player. To better visualize this, lets take a look at a real world example; Hypixel Turbo Kart Racers.
The "vehicle" the player is inside is actually a armor stand with item on its head. The item has 3D model to make it look like you are sitting inside actual race car. To be able to "control" this vehicle, the client sends the steering packet, which normally would do nothing. In this case however, the vanilla action is overridden by a plugin to give the armor stand velocity based where the player would like to move (wasd). When the player tries to jump (pressed space), a honk is used instead and when the player tries to sneak (pressed shift), the car starts to drift. To make the visuals look more pleasing, it also moves the armor stands head around to allow the car to tilt a bit when making a turn.
To solve that, we need a way for the plugin to interpret the steering packet and implement its own logic to override the vanilla behavior.
we need a way for the plugin to interpret the steering packet
To clear any confusion, an event should not be a façade for a packet itself, which is what this event tried to become. Instead, I see three significant events that should occur here:
- Steer - left and right
- Jump - this could be part of "steering", but I feel like it's a separate action
- Dismount - we already have this
In all cases you're riding an entity. Should we then be including this in RideEntityEvent as sub events? I'd propose we probably would have:
-
RideEntityEvent.Steer: with just a left and right (I know what I previously said, I am a victim of my own ideas too) - if we need to flesh it out later, so be it. -
RideEntityEvent.Jump: hopefully this one is obvious -
RideEntityEvent.Dismount: if we have to tell the server to remount if this is cancelled, so be it
Does that cover what you're interested in doing?
@gabizou @Zidane I suppose a good question here is if steer and jump should be sub-events or RideEntityEvent or not - any opinions?
I did consider to implement them all as sub events (as I did for dismount) but then got a bit worried about whatever that would be too impactful for performance reasons. It looks way cleaner in my opinion and would :+1: for it. However, what data type should we use when exposing the steering direction? Booleans? New enum? Existing enum? Vector like I used?
Also makes sense to move this all to RideEntityEvent, lets do that.
I suppose a good question here is if steer and jump should be sub-events or RideEntityEvent or not - any opinions?
I have no personal opinions here, sub events mean more to filter out. I don't know how spammy these events would be otherwise.
However, what data type should we use when exposing the steering direction? Booleans? New enum? Existing enum? Vector like I used?
Correct me if I'm wrong, but there's 8 possible directions, (forward, back, left, right, forward left, forward right, back right, back left) at which point I personally believe we should just expose the Vector3d direction aligned by the entity currently riding (maybe even expose the Vector3d of the direction from the entity riding vs the direction aligned to the world's coordinates).
Correct me if I'm wrong
Steering is clockwise or anti-clockwise - it's relative to the steering entity, not the world. Thus, that or left and right will suffice.
Hey! You seem to be running an unsupported version (API 8) of SpongeAPI. Support for API 8 ended in October 2023.
API-8 is now end-of-life. We will not be issuing any more API updates for version 8 of our API^1
As part of our legacy cleanup we are closing issues relating to API8/1.16
If you wish to move this forward, please rebase this PR on the current branch and reopen it.