-
Notifications
You must be signed in to change notification settings - Fork 97
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
Reorganize Inventory code and add Reward Chest #666
base: main
Are you sure you want to change the base?
Conversation
As dependency #630 is done, this should now be ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the need for this. Reward chest doesn't have any custom functionality other than a different menu title, and bounded and unlimited inventory can be implemented by just using a bool in the inventory class.
Seems like the new classes are created just to use the types, which isn't necessarily the best way to check variant. Like I said, boolean, but enums are also very helpful.
In terms of code structure design, having a completely unused field under certain configuration does not feel right. What |
I see no reason why reward chests have to be functionally different than regular chests.
I'm not sure I understand what you are trying to convey.
I'm generally against adding more classes if the required functionality is possible without them. Enums can be used in this specific case, as they are quite powerful in Java, but I'll take your response to the last question into account when you respond. |
When giving rewards, the chests used are supposed not be a part of the rewards, which would break the expectation and balancing instead. Therefore, the reward chests are supposed to be read-only, which would only allow players getting items from but not putting items into, instead of regular chests. For the part of the classes and enums part, here, there are 2 cases:
These two are entirely different cases and ideally should be separated for code design. You can see that there are different numbers of methods implemented in the 2 new subclasses. It is not barely just "adding new classes" but reorganizing the code structure and design. |
I know I'm a C brained programmer so this might not fit the codebase, but does a single 'maxItem' value, where 'maxItem == -1' or even just 'maxItem == Integer.MAX_VALUE' implies unlimited? Where you can create a constructor that defaults to maxValue == -1 or MAX_VALUE (or something else), and a constructor where maxValue is specified by a parameter? |
I think it is not a recommended or the best practice in Java (while there is |
What would you make BoundedInventory abstract for? imo maxSlots should just be a property, not the return of an abstract method |
The design of the codebase would going towards to way that allowing flexibility and feasibility of moddability. There can be cases that there are variable bounds in some designs, like there can be another case that the inventory is max for another condition. Perhaps |
I disagree with this sentiment fully. I don't think it is unbalanced to give players the chests they find, on the contrary, I believe it is very logical to be able to use the chests you find. On the other hand, empty reward chests in the world with no use will be nothing but an annoyance. Therefore, I believe replacing regular chests with reward chests will make the gameplay worse. It seems you are trying to fix a problem that does not exist.
I think setting the maxItems property to null when it is unbounded is reasonable. Better than my first proposal to do that using a boolean. If extensibility is what you want, enums are amazing. |
Note that the rewards chests are used for the quests, not the ones really exist in the levels. Therefore, your disagreement does not hold.
Also, having strictly defined fields that always have |
I have updated and ruled the usage and implementation of Then, for special conditional storage space for items, like custom maximum count of items and storage space that is variable to other conditions, slots or a custom implementation is recommended instead. This includes the implementations of slot entries as in #532. A kind of storage space like bundle in Minecraft should not be using this class.
Some information above is already mentioned in the comments added just a moment before. |
`localize` and `buffered` are removed w.r.t. MinicraftPlus#666
This depends on #630
Originally,
Inventory
resolves for both bounded and unlimited inventory types for item list menus and container inventories, but this is not the best design. So,Inventory
is instead made into an interface and 2 separate subclassesBoundedInventory
andUnlimitedInventory
are made for the corresponding situations. That said,BoundedInventory
only handle inventories that have a size limit whileUnlimitedInventory
does not make any constrains on the size limit by default. This makes the code neater without concerning about "different unused fields exist for each circumstance", which shall be regarded as bad practice.Then, a
RewardChest
is added to resolve the original problem that a chest is generated each time rewards are sent. Furthermore, world loading usedDeathChest
for saving inventory-overflowing items, which may not be well for players, so aRewardChest
without timer is used instead. Now, theRewardChest
cannot be treated as ordinary chest as items cannot be added and the chest is removed when its inventory is empty. This can reduce the chances players getting more survival-usable chests without any consumption of the desired materials. Also,RewardChest
provides an interactive menu, unlikeDeathChest
. Perhaps,DeathChest
should also be made with an interactive menu though.