Skip to content

Commit

Permalink
Hide mods from the resource/data pack screen (#854)
Browse files Browse the repository at this point in the history
* Hide mods from the resource/data pack screen

* License
  • Loading branch information
modmuss50 authored Jun 30, 2020
1 parent dfd0b83 commit 33474e5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
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) {
Expand All @@ -48,7 +50,7 @@ public <T extends ResourcePackProfile> void register(Consumer<T> consumer, Resou

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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import net.fabricmc.fabric.impl.resource.loader.ModNioResourcePack;

@Mixin(DataPackSettings.class)
public class MixinClass_5359 {
public class MixinDataPackSettings {
@Shadow
@Final
@Mutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 33474e5

Please sign in to comment.