-
-
Notifications
You must be signed in to change notification settings - Fork 703
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
Feature: Subpack loading #4958
Feature: Subpack loading #4958
Conversation
For what ever reason, it seems like the settings object is capable of having other elements like a server form, but it doesnt actually do anything. So I think that this is good atm |
huh, interesting. We could also parse those, but given that they're non-functional, parsing just type + text seems fine |
yeah probably doesnt need to be parsed in terms of minimums and maximums because majority of packs wouldn't have it anyway |
also, maybe this should be api/2.4.2 ? |
That's unlikely - we want to get |
api/src/main/java/org/geysermc/geyser/api/pack/ResourcePack.java
Outdated
Show resolved
Hide resolved
/** | ||
* Represents a subpack of a resource pack | ||
*/ | ||
interface Subpack { |
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.
* Gets the name of the subpack. | ||
* It can be sent to the Bedrock client alongside the pack | ||
* to load a particular subpack within a resource pack. | ||
* | ||
* @return the subpack name |
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.
Refer as this subpack
instead of the subpack
, and as required in other methods
* Gets the memory tier of the subpack. | ||
* One memory tier requires 0.25 GB of free memory | ||
* that a device must have to run a sub-pack. | ||
* | ||
* @return the memory tier | ||
*/ | ||
@Nullable | ||
Float memoryTier(); |
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.
* Gets the memory tier of the subpack. | |
* One memory tier requires 0.25 GB of free memory | |
* that a device must have to run a sub-pack. | |
* | |
* @return the memory tier | |
*/ | |
@Nullable | |
Float memoryTier(); | |
* Gets the memory tier of this Subpack, representing how much RAM a device must have to run it. | |
* Each memory tier requires 0.25 GB of RAM. For example, a memory tier of 0 is no requirement, | |
* and a memory tier of 4 requires 1GB of RAM. | |
* | |
* @return the memory tier | |
*/ | |
@Nullable | |
Float memoryTier(); |
It seems like it is based off of device specs, not the active amount of free memory? Also it seems like the memory tier is an integer? Otherwise comment on the discrepancy with MS docs
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 copied the values from the GeyserMC/packconverter generated stuff; in there it's a float
The memory thing is explicitly explained on the ms docs, where 1 "memory tier unit" requires 0.25 GB of storage.
From my testing, it seems like this value does not even matter for our usecase, as the user can't change which subpack to use on their own (that can only be set when the pack is loaded on the client, and not while in a world)
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 copied the values from the GeyserMC/packconverter generated stuff; in there it's a float
ok.
The memory thing is explicitly explained on the ms docs, where 1 "memory tier unit" requires 0.25 GB of storage.
I mean it doesn't use the word "unit", it just says "each tier represents .25 GB". I've never interpreted the words "unit" or "tier" as fractional. Can you share the pack you've tested with and I'll try it with the client directly?
/** | ||
* Sets the content key of the resource pack. Lack of a content key can be represented by an empty string. | ||
*/ | ||
void contentKey(@Nullable String contentKey); |
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.
Considering that the content key is static with respect to the resource pack data source, I'm under the impression this shouldn't be allowed to change.
The PackCodec, responsible for reading the resource pack manifest, is also responsible for determining the resource pack content key.
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'm aware of the current pack codec impl that tries to resolve a key file - but I don't see a reason why a user couldn't provide the key themselves :p
Although yeah, we could probably also make sure it can only be set once
/** | ||
* Sets the subpack name that clients should load. | ||
* It must match one of the subpacks that can be found in the manifest. | ||
*/ | ||
void subpackName(@Nullable String subpackName); |
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.
The addition of the two mutations seems dangerous. The first thought is that we don't want to be mutating packs that are in the Geyser registry just because of the way we are sending them to the client.
More importantly, packs need to be thread safe because they are shared by sessions, if I understand correctly?
We could add additions to SessionLoadResourcePacksEvent, without need for deprecations:
public abstract @NonNull List<Entry> entries();
public abstract boolean register(@NonNull ResourcePack resourcePack, @NonNull String subpack);
public interface Entry {
@NonNull ResourcePack resourcePack();
@NonNull String subpack();
}
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.
Personally, I'd like to avoid adding multiple register methods - they'd have to be duplicated for the eventual GeyserDefineResourcePacks event
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.
Then make Entry
a separate class and use that for any register methods that take any more parameters than just ResourcePack
. Or something like that.
api/src/main/java/org/geysermc/geyser/api/pack/ResourcePack.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Konicai <[email protected]>
Going to close this - Konicai pointed out vital flaws with this implementation (thanks konicai!), so i've began working on a different approach. master...onebeastchris:Geyser:subpacks-rewrite is the current idea; it will probably change further. |
Implements #4939
Potential usages:
Further, this also adds setters for
contentKey
and thesubpackName
to theResourcePack
interface. These would, imo, also benefit remote resource pack - those values cannot be read directly from the resource pack, so it makes sense to allow these to be modifies after reading the pack.