Hide mods from the resource/data pack screen ()

* Hide mods from the resource/data pack screen

* License
This commit is contained in:
modmuss50 2020-06-30 20:17:07 +01:00 committed by GitHub
parent dfd0b839f4
commit 33474e5255
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 3 deletions
fabric-resource-loader-v0/src/main

View file

@ -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);

View file

@ -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();
}
}
}

View file

@ -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

View file

@ -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",