mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
Hide mods from the resource/data pack screen (#854)
* Hide mods from the resource/data pack screen * License
This commit is contained in:
parent
dfd0b839f4
commit
33474e5255
4 changed files with 44 additions and 3 deletions
fabric-resource-loader-v0/src/main
java/net/fabricmc/fabric
impl/resource/loader
mixin/resource/loader
resources
|
@ -23,12 +23,14 @@ import java.util.function.Consumer;
|
|||
import net.minecraft.resource.ResourcePack;
|
||||
import net.minecraft.resource.ResourcePackProfile;
|
||||
import net.minecraft.resource.ResourcePackProvider;
|
||||
import net.minecraft.resource.ResourcePackSource;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.ModResourcePack;
|
||||
|
||||
public class ModResourcePackCreator implements ResourcePackProvider {
|
||||
public static final ResourcePackSource RESOURCE_PACK_SOURCE = text -> new TranslatableText("pack.nameAndSource", text, new TranslatableText("pack.source.fabricmod"));
|
||||
private final ResourceType type;
|
||||
|
||||
public ModResourcePackCreator(ResourceType type) {
|
||||
|
@ -48,7 +50,7 @@ public class ModResourcePackCreator implements ResourcePackProvider {
|
|||
|
||||
T var3 = ResourcePackProfile.of("fabric/" + ((ModResourcePack) pack).getFabricModMetadata().getId(),
|
||||
false, () -> pack, factory, ResourcePackProfile.InsertionPosition.TOP,
|
||||
text -> new TranslatableText("pack.nameAndSource", text, new TranslatableText("pack.source.fabricmod")));
|
||||
RESOURCE_PACK_SOURCE);
|
||||
|
||||
if (var3 != null) {
|
||||
consumer.accept(var3);
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.AbstractPackScreen;
|
||||
import net.minecraft.client.gui.screen.pack.PackListWidget;
|
||||
import net.minecraft.client.gui.screen.pack.ResourcePackOrganizer;
|
||||
|
||||
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator;
|
||||
|
||||
@Mixin(AbstractPackScreen.class)
|
||||
public class MixinAbstractPackScreen {
|
||||
@Inject(method = "method_29672", at = @At("HEAD"), cancellable = true)
|
||||
private void addPackEntry(PackListWidget packListWidget, ResourcePackOrganizer.Pack pack, CallbackInfo info) {
|
||||
if (pack.getSource() == ModResourcePackCreator.RESOURCE_PACK_SOURCE) {
|
||||
info.cancel();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ import net.fabricmc.loader.api.ModContainer;
|
|||
import net.fabricmc.fabric.impl.resource.loader.ModNioResourcePack;
|
||||
|
||||
@Mixin(DataPackSettings.class)
|
||||
public class MixinClass_5359 {
|
||||
public class MixinDataPackSettings {
|
||||
@Shadow
|
||||
@Final
|
||||
@Mutable
|
|
@ -3,13 +3,14 @@
|
|||
"package": "net.fabricmc.fabric.mixin.resource.loader",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinClass_5359",
|
||||
"MixinDataPackSettings",
|
||||
"MixinDefaultResourcePack",
|
||||
"MixinKeyedResourceReloadListener$Server",
|
||||
"MixinReloadableResourceManagerImpl",
|
||||
"MixinResourcePackManager"
|
||||
],
|
||||
"client": [
|
||||
"MixinAbstractPackScreen",
|
||||
"MixinFormat4ResourcePack",
|
||||
"MixinKeyedResourceReloadListener$Client",
|
||||
"MixinMinecraftGame",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue