SpongePowered / SpongeAPI

A Minecraft plugin API
http://www.spongepowered.org/
MIT License
1.14k stars 342 forks source link

Add the ability to prevent a player from picking up experience. #598

Closed kashike closed 1 year ago

kashike commented 9 years ago

There is currently no event to prevent a player from picking up experience.

Deamon5550 commented 9 years ago

PlayerExpChangeEvent should cover this.

kashike commented 9 years ago

@Deamon5550 As far as I can see, that's an event called when a player's experience changes. This issue is for a 'PlayerPickupExperience' event, to prevent a player from picking up experience orbs.

ryantheleach commented 9 years ago

Like a player/entity event between the xp orb and player. There should also be a way to avoid the targetting of xp orbs (or other entities) for spectating / vanished players.

Deamon5550 commented 9 years ago

Well by checking if the difference in the player's experience is positive and cancelling you are preventing them from gaining experience, since the only source of a player gaining experience is via picking up experience orbs this is effectively the same thing. Perhaps an argument can be made for requiring finer contols over the player's interaction with experience orbs but I'm not really seeing a use case.

Other than hiding players that is, however, by what means are the player's hidden? if there was (is there?) some way to set a player as hidden from other players via api this would be better handled by that rather than with a seperate switch for whether a player interacts with experience orbs.

Perhaps you could explain better what it is you want this for.

AlphaModder commented 9 years ago

@Deamon5550 Even if you negate the experience change, the orb would still disappear. I think this is a need to stop the entity from going into the player in the first place, not just the experience change. If experience orbs were used as FX or there was a game where they were only supposed to be picked up by one team (power ups maybe) you would want to stop the entity from disappearing or even navigating to the player.

Zidane commented 9 years ago

@AlphaModder

That is a good point. We should probably add an event for that.

ST-DDT commented 9 years ago

Something like EntityPickupEntityEvent Or EntityAttractedByEntityEvent Or more specific events for xp orbs only.

gabizou commented 9 years ago

That is a good point. We should probably add an event for that.

Possibly, we could hook into the EntityXPOrb to use a TargetLivingData manipulator.....

Zidane commented 9 years ago

@bloodmc

Can you add in the ability to keep an exp orb from being attracted to you? Does it actually move towards you or is that an effect? Do our current events support this?

gabizou commented 9 years ago

@Zidane It's totally possible to dictate to the xp orb where to go actually.

simon816 commented 8 years ago

In order to prevent players picking up orbs you can listen to CollideEntityEvent and cancel the collision if it involves a Player and ExperienceOrb. As for the orbs attraction to the player, maybe that could be represented in ExpOrbData as Value<Player> targetPlayer()

gabizou commented 8 years ago

This is perfectly handled with TargetLivingData and contextualized data. Also, a few events that need to be verified for checking:

CollideEntityEvent, DataHolderChangeEvent, etc.

gabizou commented 6 years ago

Not sure what happened with this issue, but I'm of the opponent that the data management for this would be either using a combination of a List<UUID> of entities to avoid drawing towards, or add something similar to the target event where the experience orb is moving towards the player. Or can make it a value on the Player to avoid picking up experience orbs. Client would glitch out for sure, but that wouldn't be terrible if the experience is still sitting on the floor.