Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArmorStand water move enhancement #3

Open
kaxonomy opened this issue Mar 25, 2022 · 5 comments
Open

ArmorStand water move enhancement #3

kaxonomy opened this issue Mar 25, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@kaxonomy
Copy link

kaxonomy commented Mar 25, 2022

If you're using papermc, you can accomplish preventing armorstands from moving in water quite easily without disabling gravity:

    @EventHandler
    public void onEntityMove(EntityMoveEvent event) {
        if (event.getEntity() instanceof ArmorStand armorstand) {
            if (armorstand.isInWater()) {
                event.setCancelled(true);
            }
        }
    }

I don't have enough time to make a pull request, but since you're using spigot-api, I'd recommend using reflection to check if the papermc event exists.

@xSavior-of-God
Copy link
Owner

Hi @kaxon-dev,
thanks for the advice.
As soon as I have a moment I add it to the checks.

@xSavior-of-God xSavior-of-God added the enhancement New feature or request label Mar 25, 2022
@xSavior-of-God
Copy link
Owner

I found the method you mentioned above (armorstand.isInWater()) in the spigot API. I'm not sure if it is present in all versions, as soon as I have a moment I take a look.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Entity.html#isInWater()

for now the idea is to diversify these two checks for what they are, so
1 => to disable the gravity
2 => to disable movement in the water

but i'm sure that i don't need to add paper-api for now.

@xSavior-of-God
Copy link
Owner

Hi @kaxon-dev,
I analyzed the thing a bit, and in my opinion it could be heavy as a process for a spigot server.
For a papermc I don't know how such an event can be optimized, it always check the location of each entity every time, (Imagine the weight of this process if you have millions of entities in the world).

So, after a few attempts I believe that it is not the best way to block this type of event,
reasons:

  • It is compatible only for paper and for versions 1.17+ compiled in java 16-17.
  • Also, by doing this, I block the use of the resource to who uses previous versions (like 1.12-1.13).
  • In addition this event could also be heavy if you have a server with many entities.

Yes, you could do the listener by hand, i.e. check all the armorstand 1 to 1 for each x tick, but in my opinion it is bullshit:

  • You should make 1 thread to get every entity in the world (obviously in loaded chunks) and check if it is anarmorstand...
    to then manage and archive its location.

  • And then every tick (minimum 1, otherwise then you have the animation effect that goes back), you should check if the location is different and if it is in the water you should take the armorstand and move it back every time the location changes.

I don't know, but in my opinion it seems like bullshit, when you could just block gravity since the generation of the entity.

Ah yes, I assume that paper does this thing like that, for each entity, I don't know how it doesn't make it overlap, but in my opinion some slight delay is present with the increase of entities and players.

So in summary, I'm sorry but it's not possible at the moment.
If you have any better ideas to handle it, say it... for now, I don't see a better way than to turn off the gravity.

@kaxonomy
Copy link
Author

Thanks for the information. Since that solution isn't feasible, how about instead of disabling armor stand gravity altogether, you add a configuration setting for scanning the chunks every X amount of minutes and set their gravity depending on whether or not they're in water?

if (entity.getType() == EntityType.ARMOR_STAND) {
    entity.setGravity(!entity.isInWater());
}

@xSavior-of-God
Copy link
Owner

Hi,
Yes it is a good idea, but I do not do the method for everyone, I mean, I would do something that does not involve the change of the gravity of all the armorstands, in order to avoid delays, I'd rather do something like:

If condition: armorstand is in water and gravity is enabled
do: disable gravity
else: continue;

The only thing now is to figure out if I can add this check to the thread that checks the number of armorstand x chunk/xyz... or do a new thread...

Anyway, I'll try to optimize the controls, also if i can, i try to manage everything from 1 single common thread.

xSavior-of-God added a commit that referenced this issue Aug 15, 2024
- Solved #12
- Possible option for #3
- Added Folia Support
- Now the piston works if there are armorstands in the same chunk (see new config option)
- Limit Check optimization
- Added "/asl clear" command
- NOW ALL TIMERS ARE IN SECONDS, Min value is 10!
xSavior-of-God added a commit that referenced this issue Aug 15, 2024
* License Updated

* Bump json from 20220924 to 20230227 (#10)

* License Updated (#9)

* Bump json from 20220924 to 20230227

Bumps [json](https://github.com/douglascrockford/JSON-java) from 20220924 to 20230227.
- [Release notes](https://github.com/douglascrockford/JSON-java/releases)
- [Changelog](https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md)
- [Commits](https://github.com/douglascrockford/JSON-java/commits)

---
updated-dependencies:
- dependency-name: org.json:json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: xSavior_of_God <66216419+xSavior-of-God@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Started development to support Folia

WIP

* scheduler manager - part#1

* Update pom.xml

Fix for Denial of Service in JSON-Java (dependabot)

* 1.21.x and Folia Support

- Solved #12
- Possible option for #3
- Added Folia Support
- Now the piston works if there are armorstands in the same chunk (see new config option)
- Limit Check optimization
- Added "/asl clear" command
- NOW ALL TIMERS ARE IN SECONDS, Min value is 10!

* updated CI/CD java version to 22

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants