-
Notifications
You must be signed in to change notification settings - Fork 424
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
Refactor resource loader internals #3473
Merged
modmuss50
merged 24 commits into
FabricMC:1.20.4
from
apple502j:resource-loader/grouping-redo
Jan 28, 2024
Merged
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d871109
First step toward fixing resource pack grouping
apple502j dcffe91
Placeholder pack and pack dependency
apple502j aa5e0a4
Various fixes
apple502j 50665fc
Fix wrong variable in serialization code
apple502j 689413f
Hide packs in PackScreen and DatapackCommand
apple502j 9cb6b31
Apparently Japanese people aren't alone in having their currency sign…
apple502j efe6941
Inject directly to Pack
apple502j df32795
Add temporary logging, fix bug
apple502j ea2b529
Add proper sorting
apple502j 0bf7686
Improve logging
apple502j 2cac02c
Fix duplicate name registration
apple502j 76ae3b0
Fix client pack handling
apple502j 02e45d7
Fix FMJ
apple502j 94ad868
Stop using interface injection for internal interface
apple502j eb74aba
Delete unused GroupResourcePack
apple502j 683d6b7
Move refreshAutoEnabledPacks to util
apple502j f45deb3
Improve logging
apple502j fc1a71e
Make a few things private
apple502j c0af7c9
Use vanilla metadata serialization logic
apple502j 0d4d8ab
Improve javadoc
apple502j 2c92a17
Add junit test
apple502j a5e12d9
Some final refactors
apple502j 150d210
Update ja_jp.json
apple502j c577cf0
Merge branch '1.20.4' into resource-loader/grouping-redo
modmuss50 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 0 additions & 63 deletions
63
...ava/net/fabricmc/fabric/impl/client/resource/loader/FabricWrappedVanillaResourcePack.java
This file was deleted.
Oops, something went wrong.
77 changes: 0 additions & 77 deletions
77
.../fabricmc/fabric/mixin/resource/loader/client/DefaultClientResourcePackProviderMixin.java
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
...t/java/net/fabricmc/fabric/mixin/resource/loader/client/GameOptionsWriteVisitorMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.mixin.resource.loader.client; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.resource.ResourcePackManager; | ||
import net.minecraft.resource.ResourcePackProfile; | ||
|
||
/** | ||
* Mixins to the anonymous class in #write method. | ||
*/ | ||
@Mixin(targets = "net/minecraft/client/option/GameOptions$3") | ||
public class GameOptionsWriteVisitorMixin { | ||
@Unique | ||
private static List<String> toPackListString(List<String> packs) { | ||
List<String> copy = new ArrayList<>(packs.size()); | ||
ResourcePackManager manager = MinecraftClient.getInstance().getResourcePackManager(); | ||
|
||
for (String pack : packs) { | ||
ResourcePackProfile profile = manager.getProfile(pack); | ||
|
||
// Nonexistent pack profiles should be handled in the same way as vanilla | ||
if (profile == null || !profile.isHidden()) copy.add(pack); | ||
} | ||
|
||
return copy; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@ModifyArg(method = "visitObject", at = @At(value = "INVOKE", target = "Ljava/util/function/Function;apply(Ljava/lang/Object;)Ljava/lang/Object;")) | ||
private <T> T skipHiddenPacks(T value, @Local String key) { | ||
if ("resourcePacks".equals(key) && value instanceof List) { | ||
return (T) toPackListString((List<String>) value); | ||
} | ||
|
||
return value; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ent/java/net/fabricmc/fabric/mixin/resource/loader/client/ResourcePackOrganizerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.mixin.resource.loader.client; | ||
|
||
import java.util.List; | ||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
|
||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import net.minecraft.client.gui.screen.pack.ResourcePackOrganizer; | ||
import net.minecraft.resource.ResourcePackManager; | ||
import net.minecraft.resource.ResourcePackProfile; | ||
|
||
@Mixin(ResourcePackOrganizer.class) | ||
public class ResourcePackOrganizerMixin { | ||
@Shadow | ||
@Final | ||
List<ResourcePackProfile> enabledPacks; | ||
|
||
@Shadow | ||
@Final | ||
List<ResourcePackProfile> disabledPacks; | ||
|
||
/** | ||
* Do not list hidden packs in either enabledPacks or disabledPacks. | ||
* They are managed entirely by ResourcePackManager on save, and are invisible to client. | ||
*/ | ||
@Inject(method = "<init>", at = @At("TAIL")) | ||
private void removeHiddenPacksInit(Runnable updateCallback, Function iconIdSupplier, ResourcePackManager resourcePackManager, Consumer applier, CallbackInfo ci) { | ||
this.enabledPacks.removeIf(ResourcePackProfile::isHidden); | ||
this.disabledPacks.removeIf(ResourcePackProfile::isHidden); | ||
} | ||
|
||
@Inject(method = "refresh", at = @At("TAIL")) | ||
private void removeHiddenPacksRefresh(CallbackInfo ci) { | ||
this.enabledPacks.removeIf(ResourcePackProfile::isHidden); | ||
this.disabledPacks.removeIf(ResourcePackProfile::isHidden); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 0 additions & 86 deletions
86
...ader-v0/src/main/java/net/fabricmc/fabric/impl/resource/loader/FabricModResourcePack.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Injecting here is much easier than maintaining the ordinals among the
visitObject
calls inaccept
.