Aversion Obelisk backport to 1.20.1 #777
No reviewers
Labels
No labels
Area-Assets
Area-Backend
Area-Conduits
Area-Datapacks
Area-Lang
Area-Mod Compat
Area-Parity
Area-Rendering
Good first issue
MC-1.19.2
MC-1.20.1
MC-1.20.4
MC-1.20.6
MC-1.21
MC-1.21.1
Modtoberfest
P-0-High
P-1-Medium
P-2-Low
Status-Awaiting Response
Status-Behind-Flag
Status-Blocked
Status-Cannot Reproduce
Status-Duplicate
Status-Help Wanted
Status-Incomplete Report
Status-Invalid
Status-Needs LTS Backport
Status-Needs Updating
Status-Stale
Status-To Implement
Status-Triage
Status-Wontfix
Status-Wontmerge
Type-Backport
Type-Bug
Type-Documentation
Type-Enhancement
Type-Question
Type-RFC
Type-Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Team-EnderIO/EnderIO#777
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "lts/1.20.1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Obelisk Manager system (required for any obelisk) is backported in accordance with 1.21. ChunkBoundLookup (required for the manager system) was backported/imported as is since it did not include anything conflicted between 1.20.1 and 1.21. Aversion Obelisk backported
, without Entity Filter support since it isn't present in Ender IO in 1.20.1. Everything was implemented in harmony with the whole structure of Ender IO's implementation. The backport required many things to be changed to their 1.20.1 counterparts, such as: Data Attachment -> Capability, and Generic Network Slot Usage -> (whatever required) Network Slot Usage.Additional Note: I implemented a new GUI Widget called MessageWidget, to render a custom tooltip/message on any desired area of a GUI without needing a placeholder element rendered.
This was implemented to render "This part is a work in progress." message on the Entity Filter slot.EDIT: Entity Filters were not implemented when I first opened this pull request because I wasn't sure if it was bound to changes even in 1.21 but I have decided to backport it also because it is really useful for Aversion Obelisk and it felt like an unfinished business. If it ever recieves any change, assuming I see it, I can just open another pull request to adjust it to match 1.21 behaviour.
TODO (Maybe)
Breaking Changes
I have decided to also backport Entity Filters even though I was unsure if they were bound to changes in 1.21. So, the whole Aversion Obelisk backport is done. I believe it should be ready for a review :)
Thank you for the PR, I'll try to look into it soon!
Cool, let me know if you need any changes!
Hey, I have realized that Rover656 has some updates for 1.20.1 which involved an update on FilterCapability which I was deriving from for the EntityFilterCapability class. So I pushed a small update to conform to the new changes made :) There should be no merging conflict now and I also once again tested everything just in case too. Just wanted to let you guys know so you won't have to review everything once again.
I have seen that ferriarnus also has updates for 1.20.1 today which involved updates on the base machine block entirely for performance optimizations. I will also make updates once again to conform with these changes but I will be doing it tomorrow. I will once again comment what updates I've made to conform with the changes tomorrow :)
@ferriarnus Just to check, do you have a review of this PR in progress or would you like me to take a look, I'm keen to get this into the next 1.20.1 release :)
@krxdev-kaan thanks for all of your hard work on this!
Some small remarks. I'll try to test it in game soon as well.
Is this used? I personally wouldn't want to add new classes that aren't in 1.21. That being said, if something has an advantage, feel free to leave it and PR it to 1.21.
@ -0,0 +1,114 @@package com.enderio.machines.common.blockentity;Here the Reasoning is mobs in the filter are the ones that are blocked. So Whitelisted filtered mobs should be blocked.
@ -0,0 +56,4 @@return stack;}if (stack.getCapability(EIOCapabilities.ENTITY_STORAGE).isPresent()) {I think if you do isPresent, you shouldn't use ifPresent but just use get() on it. It's a small thing but it's very slightly better for performance iirc.
Hey, I was just making some commits to conform with the changes you made yesterday. I just changed the getInventoryLayout method to createInventoryLayout method in that commit. Wanted to note it here just in case :) I will now reply to your remarks in a sec.
@ -0,0 +1,114 @@package com.enderio.machines.common.blockentity;Oh okay then I must've got it the wrong way in my head. Will be fixed in a minute.
@ -0,0 +56,4 @@return stack;}if (stack.getCapability(EIOCapabilities.ENTITY_STORAGE).isPresent()) {Well yeah that definitely looks unoptimized right away. Was I drunk or smth hahah. Fixing it in a minute also!
I once used it but then removed the use. I will explain and send you some screenshot in a bit, if you like it then I will PR it to 1.21 also and if you don't I will go ahead and remove it.
@ -0,0 +1,114 @@package com.enderio.machines.common.blockentity;I have pushed the fix for this. You can check it out if you want.
@ -0,0 +56,4 @@return stack;}if (stack.getCapability(EIOCapabilities.ENTITY_STORAGE).isPresent()) {Okay I can now remember why I did that. This is due to the fact that the get() method is private within LazyOptional on 1.20.1 forge so I have to use orElseGet() or orElse() method which are both doing checkups once again, in the end making the optimization level exactly the same as this (if not slightly worse). However, if you'd like, I can make a version with orElse() for readability reasons with a warning added due to usage of null on a @NotNull annotated object.
So in the first stages of this PR I did not implement Entity Filter Item but the Aversion Obelisk had the slot for it. So I wanted to be able to add a pop-up message anywhere in the GUI with a reusable approach. So I implemented this for that reason. The pop-up can be put anywhere like on a slot, on a button and/or on thin air. You just give the position and size constraints and the area is now a hoverable pop-up message. Here is a screenshot:

If you like it, I can PR it to 1.21 and leave it here also. However, please feel free to not like it hahah
@ -0,0 +56,4 @@return stack;}if (stack.getCapability(EIOCapabilities.ENTITY_STORAGE).isPresent()) {Yes I have thought about this for half an hour straight and every approach would be the same (if the others are not slightly worse) because of the LazyOptional's implementation on 1.20.1. Both orElse(), orElseGet() and resolve() are alternatives to get(). However, all of these make a couple of null and validity checks before returning the value. Therefore, making them almost on par with my isPresent()+ifPresent() approach. However, if you have any other idea, I am all ears.
It is my pleasure!
I just saw your latest commits, which were made an hour ago. I will also merge them in a couple hours. Though there seems to be no merge conflicts so I probably will just merge it and leave it.
I have merged the latest changes once again, no merge conflicts or any issues arose so I am leaving everything as is. Waiting on the review approvals from now on :)
I think it'd be fine to remove this widget for now personally :)
Alright, I will be removing it in a couple hours :)
@ -0,0 +56,4 @@return stack;}if (stack.getCapability(EIOCapabilities.ENTITY_STORAGE).isPresent()) {Tl;dr Found a better solution then isPresent+ifPresent but it will add 2 warnings, would that be a problem for you guys?
Well I have decided to make an accurate calculation by time analysis and here are the results:
Definitions:
n -> Time taken for a single comparison
m -> Time taken for any minor action on objects (the easy part)
k -> Time taken for getValue() inside an optional (the worst part)
Approaches:
Times taken:
Conclusion:
Second option and current approach is very close to each other with the current one being somewhat better. However, the third approach seems to be a much better option with a minor drawback. The third option will give out 2 warnings because of the usage of null in a Non-Null context, however it won't be a problem otherwise.
Side note: I know that this was an overkill analysis for, at most, a very slight performance optimization but I had nothing else to do hahah
Done! I have removed the widget and pushed the commits, you can check it out if you'd like. Once ferriarnus or you answer my last comment on the other task, I will do that right away also :)
I have pushed a fix for a very extreme case to crash the game with Aversion Obelisk. If a server closes at a tick where the next tick would have been a spawn event in the range of an obelisk, the next launch of the server would instantly crash it in the first tick for one time (next launch is successful). I was playing with my build for a month now and I have just came across this. This is also possible in 1.21 even though it is REALLY unlikely to happen. I have pushed a fix and I will most likely PR it to 1.21 also.
Explanation:
Aversion Obelisk handles spawn event only if the spawn event is occuring in the range of the obelisk so we call getAABB() while processing and check if AABB contains the event position. However, if this event is occuring in the very first tick of the server, then the obelisk is not loaded yet. Therefore making it's aabb null at the time. This really is a very extreme case but it happened.
Solution:
I simply added a null check for the getAABB() before using it.
I will PR this also to 1.21 because, even though it is for a single time and very unlikely, it can happen.
I've seen that ferriarnus marked everything as resolved. So I am assuming you guys didn't want me to make a change about the last comment. If there is any changes left you would like me to do, please do tell :)
Edit: I have clicked re-review by mistake while I was checking out the changes I've made to make sure I haven't skipped anything. Sorry!
This looks good to me, don't worry about the EntityFilterSlot - I think it'll be fine (and when I come to backporting some JEI stuff from 1.21 I can always touch it up.
Thanks a lot for backporting these features!
Cool! I have joined the discord with my main account also just now. I am really glad that I could be of help! Hoping to port the other obelisks in a couple weeks as soon as my workload gets a bit better :)