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

API Request #16

Open
Speiger opened this issue Apr 6, 2021 · 11 comments
Open

API Request #16

Speiger opened this issue Apr 6, 2021 · 11 comments

Comments

@Speiger
Copy link

Speiger commented Apr 6, 2021

o/

We want to add some compat from Unique Enchantments to Wards.
But there is no API for wards. Could you maybe add one? I can provide help as needed.

Greets,

Speiger

@Speiger
Copy link
Author

Speiger commented Apr 6, 2021

Also another request if you do a API.
Please performance optimize the mod too. (I can provide ways to do so if you don't know how)
Because right now this mod can be a quick server killer if enough of them are placed.

@democat3457
Copy link

what version

@Speiger
Copy link
Author

Speiger commented Apr 6, 2021

1.16 in this case.

@OrderedChaos-Dev
Copy link
Owner

Hi,

I'm pretty busy at the moment, so I won't be able to do this until later in the month, but I've come up with a few ideas on how to get started:

I'll rewrite the class that handles the functions so others can extend it and register it to the ward, which is this class:
https://github.com/OrderedChaos-Dev/Wards/blob/1.16/src/main/java/wards/function/WardEnchantmentType.java
with the main two functions being:
expelMagic(WardTileEntity ward, LivingEntity entity, int level)
empowerPlayer(WardTileEntity ward, PlayerEntity entity, int level)

How would you want to associate enchantments with a ward enchantment type? Currently the mod takes the config strings for this, but I'm probably going to store it all in a Map when the mod loads and have some publicly accessible method to add to the set.

For optimizations, there are a few things I have in mind:
This does not need to be done every tick, only when the book is placed/removed.
This could probably actually be cached so it only needs to check its radius once per world load.
and this is redundant, and I also forgot to implement the target cap there.
If you find more possible optimizations, please let me know.

@Speiger
Copy link
Author

Speiger commented Apr 7, 2021

Yeah we don't expect to push out another update before the end of the month anyways.

1 question. Is a WardTileEntity really required? Isn't a normal TileEntity sufficient? That way the API can be used without the entire mod itself.

Just have a registry thats something like this: Map<Enchantment, WardEnchantment> where people can register their own types that you check first. If that isn't found you just default to your config. (You could use the same map for your config too)

Optimiztations:

  • 1: Yes agree.
  • 2: You don't need to search Blocks at all Have a Map<RegistryKey, List> and compare against all of those. Because i doubt people place more then a couple of these in their world. That way you could have thousands before you notice any lag.
  • 3: Yeah you could make that 1 entities & can be seen check in 1 go. On top of that for the raycasting you should look into the "Region" class which is a world wrapper that has a faster blockstate access speed then the world itself. (It loads all needed chunks into a cache thats faster to access, but it has a tiny overhead for loading the chunks at least once)
  • 4: Disable client tick directly after the book rotation was done since the server sends anyways packets to the client. That way the whole "test for server is not needed" and you can at least ensure a perfect framerate only the server has to suffer xD.
  • 5: And maybe do only 1 raycast per entity instead of 2. Yes it loses a tiny bit of accuracy but with the faster world access (Region Class) you would basically improve performance drastically. Also there is other rayTraceBlock methods that might suit your mod better.

I bet there is more but this is just what i had after a first look.

@OrderedChaos-Dev
Copy link
Owner

So I finally have time to work on this! I'm going to do some optimizations first and then get to work on the actual functions.
For the API, I could keep the objects in a separate package, but iirc it's just as easy to optionally load your mod's wards section if the wards mod is loaded. You would need to add this as a dependency.

@OrderedChaos-Dev
Copy link
Owner

Didn't mean to close this whoops :P

@Speiger
Copy link
Author

Speiger commented May 18, 2021

After you are done with 1.16 stuff.
I would like to ask you if you could also backport it since the 1.12 version of UE is like heavily used and we want to make it as possible a version parity between mc versions as possible

@OrderedChaos-Dev
Copy link
Owner

The 1.12 and 1.16 versions are very different and usually don't work on previous versions.

@Speiger
Copy link
Author

Speiger commented May 25, 2021

yeah thats fine. Might take longer that the compat will take effect though since multiversion features have priority over single version features

@OrderedChaos-Dev
Copy link
Owner

Hey sorry, haven't given an update in a while. I got distracted by other things and also put this on hold while I work on my main mod. Once I get everything sorted out I will finish work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants