Game Entry Dictionaries #371
TheLMiffy1111
started this conversation in
Draft
Replies: 1 comment 1 reply
-
Initial thoughts
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Add a game entry dictionary system to supersede the ore dictionary, and adding support for other game entries.
Goals
Non Goals
Motivation
Description
The Ore Dictionary uses an Ore Name ↔ Incremental ID ↔ ItemStack system, and uses a total of five collections to store data:
List<String> idToName
: List that maps IDs to Ore Names.Map<String, Integer> nameToId
: Map that reverse maps Ore Names to IDs.List<NonNullList<ItemStack>> idToStack
: List that maps IDs to ItemStacks.List<NonNullList<ItemStack>> idToStackUn
: List identical toidToStack
.Map<Integer, List<Integer>> stackToId
: Map that reverse maps ItemStack hashes to IDs.In addition to only supporting ItemStacks, we can see some additional problems in this implementation:
Integer
instead of specialized collections, which may cause excessive boxing/unboxing.Also, the method
getOres(String)
by default creates a new Ore Dictionary entry, which is usually unwanted and has cause many confusions.Although an Ore Dictionary replacement could be so that it is directly a Name → Entry system, to allow compatibility with all Ore Dictionary methods, we would still need a Name ↔ Incremental ID ↔ Entry system.
Therefore, we propose a new generic
GameEntryDictionary
class that reimplements all of Ore Dictionary using fastutil and maintains such a system:The Ore Dictionary can then be easily reimplemented by wrapping an Item/ItemStack dictionary.
For types, we should provide the following dictionaries, possibly in a
GameEntryDictionaries
class:To, again, maintain compatibility, we need to somehow handle Ore Dictionary wildcards. This can be done with one of two methods, wrapping new dictionaries in
OreDictionary
:Either<Item, ObjectIntPair<Item>>
.ItemVariant
class.Edit: Entries in dictionaries are ideally immutable and effectively keyable.
Dependencies
Either
class, which might also be provided by a Serde/Codec implementation.References
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions