Skip to content

Commit

Permalink
Bump yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
apple502j committed Feb 9, 2024
1 parent 54b4400 commit 6c5d520
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

import com.mojang.serialization.Lifecycle;

import net.minecraft.class_9248;
import net.minecraft.registry.DefaultedRegistry;
import net.minecraft.registry.MutableRegistry;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.SimpleDefaultedRegistry;
import net.minecraft.registry.SimpleRegistry;
import net.minecraft.registry.entry.RegistryEntryInfo;
import net.minecraft.util.Identifier;

import net.fabricmc.fabric.mixin.registry.sync.RegistriesAccessor;
Expand Down Expand Up @@ -146,7 +146,7 @@ public R buildAndRegister() {
}

//noinspection unchecked
RegistriesAccessor.getROOT().add((RegistryKey<MutableRegistry<?>>) key, registry, class_9248.field_49136);
RegistriesAccessor.getROOT().add((RegistryKey<MutableRegistry<?>>) key, registry, RegistryEntryInfo.DEFAULT);

return registry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import net.minecraft.class_9248;
import net.minecraft.registry.MutableRegistry;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.SimpleRegistry;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.entry.RegistryEntryInfo;
import net.minecraft.util.Identifier;

import net.fabricmc.fabric.api.event.Event;
Expand Down Expand Up @@ -151,7 +151,7 @@ private void onChange(RegistryKey<T> registryKey) {
}

@Inject(method = "add", at = @At("RETURN"))
private void set(RegistryKey<T> key, T entry, class_9248 arg, CallbackInfoReturnable<RegistryEntry.Reference<T>> info) {
private void set(RegistryKey<T> key, T entry, RegistryEntryInfo arg, CallbackInfoReturnable<RegistryEntry.Reference<T>> info) {
// We need to restore the 1.19 behavior of binding the value to references immediately.
// Unfrozen registries cannot be interacted with otherwise, because the references would throw when
// trying to access their values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ private void onLoad(CallbackInfo ci) {

for (ResourcePackProfile profile : profiles) {
// Always add "Fabric Mods" pack to enabled resource packs.
if (profile.getName().equals(ModResourcePackCreator.FABRIC)) {
resourcePacks.add(profile.getName());
if (profile.getId().equals(ModResourcePackCreator.FABRIC)) {
resourcePacks.add(profile.getId());
continue;
}

try (ResourcePack pack = profile.createResourcePack()) {
if (pack instanceof ModNioResourcePack builtinPack && builtinPack.getActivationType().isEnabledByDefault()) {
if (trackedPacks.add(builtinPack.getName())) {
resourcePacks.add(profile.getName());
if (trackedPacks.add(builtinPack.getId())) {
resourcePacks.add(profile.getId());
} else {
removedPacks.remove(builtinPack.getName());
removedPacks.remove(builtinPack.getId());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.minecraft.class_9224;
import net.minecraft.resource.AbstractFileResourcePack;
import net.minecraft.resource.InputSupplier;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourcePackInfo;
import net.minecraft.resource.ResourceType;
import net.minecraft.resource.metadata.ResourceMetadataReader;
import net.minecraft.text.Text;
Expand All @@ -68,7 +68,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
private final ResourceType type;
private final ResourcePackActivationType activationType;
private final Map<ResourceType, Set<String>> namespaces;
private final class_9224 metadata;
private final ResourcePackInfo metadata;
/**
* Whether the pack is bundled and loaded by default, as opposed to registered built-in packs.
* @see ModResourcePackUtil#appendModResourcePacks(List, ResourceType, String)
Expand Down Expand Up @@ -102,7 +102,7 @@ public static ModNioResourcePack create(String id, ModContainer mod, String subP
Text displayName = subPath == null
? Text.translatable("pack.name.fabricMod", mod.getMetadata().getName())
: Text.translatable("pack.name.fabricMod.subPack", mod.getMetadata().getName(), Text.translatable("resourcePack." + subPath + ".name"));
class_9224 metadata = new class_9224(
ResourcePackInfo metadata = new ResourcePackInfo(
packId,
displayName,
ModResourcePackCreator.RESOURCE_PACK_SOURCE,
Expand All @@ -113,7 +113,7 @@ public static ModNioResourcePack create(String id, ModContainer mod, String subP
return ret.getNamespaces(type).isEmpty() ? null : ret;
}

private ModNioResourcePack(String id, ModContainer mod, List<Path> paths, ResourceType type, ResourcePackActivationType activationType, boolean modBundled, class_9224 metadata) {
private ModNioResourcePack(String id, ModContainer mod, List<Path> paths, ResourceType type, ResourcePackActivationType activationType, boolean modBundled, ResourcePackInfo metadata) {
this.id = id;
this.mod = mod;
this.basePaths = paths;
Expand Down Expand Up @@ -285,7 +285,7 @@ public <T> T parseMetadata(ResourceMetadataReader<T> metaReader) throws IOExcept
}

@Override
public class_9224 method_56926() {
public ResourcePackInfo getInfo() {
return metadata;
}

Expand All @@ -303,7 +303,7 @@ public ResourcePackActivationType getActivationType() {
}

@Override
public String getName() {
public String getId() {
return id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;

import net.minecraft.class_9224;
import net.minecraft.class_9225;
import net.minecraft.resource.ResourcePackInfo;
import net.minecraft.resource.ResourcePackPosition;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourcePackProvider;
import net.minecraft.resource.ResourcePackSource;
Expand Down Expand Up @@ -68,7 +68,7 @@ public boolean canBeEnabledLater() {
}
};
public static final ModResourcePackCreator CLIENT_RESOURCE_PACK_PROVIDER = new ModResourcePackCreator(ResourceType.CLIENT_RESOURCES);
private static final class_9225 ACTIVATION_INFO = new class_9225(true, ResourcePackProfile.InsertionPosition.TOP, false);
private static final ResourcePackPosition ACTIVATION_INFO = new ResourcePackPosition(true, ResourcePackProfile.InsertionPosition.TOP, false);

private final ResourceType type;

Expand All @@ -95,7 +95,7 @@ public void register(Consumer<ResourcePackProfile> consumer) {
4. User resource packs
*/

class_9224 metadata = new class_9224(
ResourcePackInfo metadata = new ResourcePackInfo(
FABRIC,
Text.translatable("pack.name.fabricMods"),
RESOURCE_PACK_SOURCE,
Expand Down Expand Up @@ -128,7 +128,7 @@ private void registerModPack(Consumer<ResourcePackProfile> consumer, @Nullable S

for (ModResourcePack pack : packs) {
ResourcePackProfile profile = ResourcePackProfile.create(
pack.method_56926(),
pack.getInfo(),
new ModResourcePackFactory(pack),
this.type,
ACTIVATION_INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraft.class_9224;
import net.minecraft.resource.OverlayResourcePack;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourcePackInfo;
import net.minecraft.resource.ResourcePackProfile;

import net.fabricmc.fabric.api.resource.ModResourcePack;

public record ModResourcePackFactory(ModResourcePack pack) implements ResourcePackProfile.PackFactory {
@Override
public ResourcePack open(class_9224 var1) {
public ResourcePack open(ResourcePackInfo var1) {
return pack;
}

@Override
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
public ResourcePack openWithOverlays(ResourcePackInfo var1, ResourcePackProfile.Metadata metadata) {
if (metadata.overlays().isEmpty()) {
return pack;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,27 @@ public static void appendModResourcePacks(List<ModResourcePack> packs, ResourceT
}

public static void refreshAutoEnabledPacks(List<ResourcePackProfile> enabledProfiles, Map<String, ResourcePackProfile> allProfiles) {
LOGGER.debug("[Fabric] Starting internal pack sorting with: {}", enabledProfiles.stream().map(ResourcePackProfile::getName).toList());
LOGGER.debug("[Fabric] Starting internal pack sorting with: {}", enabledProfiles.stream().map(ResourcePackProfile::getId).toList());
enabledProfiles.removeIf(profile -> ((FabricResourcePackProfile) profile).fabric_isHidden());
LOGGER.debug("[Fabric] Removed all internal packs, result: {}", enabledProfiles.stream().map(ResourcePackProfile::getName).toList());
LOGGER.debug("[Fabric] Removed all internal packs, result: {}", enabledProfiles.stream().map(ResourcePackProfile::getId).toList());
ListIterator<ResourcePackProfile> it = enabledProfiles.listIterator();
Set<String> seen = new LinkedHashSet<>();

while (it.hasNext()) {
ResourcePackProfile profile = it.next();
seen.add(profile.getName());
seen.add(profile.getId());

for (ResourcePackProfile p : allProfiles.values()) {
FabricResourcePackProfile fp = (FabricResourcePackProfile) p;

if (fp.fabric_isHidden() && fp.fabric_parentsEnabled(seen) && seen.add(p.getName())) {
if (fp.fabric_isHidden() && fp.fabric_parentsEnabled(seen) && seen.add(p.getId())) {
it.add(p);
LOGGER.debug("[Fabric] cur @ {}, auto-enabled {}, currently enabled: {}", profile.getName(), p.getName(), seen);
LOGGER.debug("[Fabric] cur @ {}, auto-enabled {}, currently enabled: {}", profile.getId(), p.getId(), seen);
}
}
}

LOGGER.debug("[Fabric] Final sorting result: {}", enabledProfiles.stream().map(ResourcePackProfile::getName).toList());
LOGGER.debug("[Fabric] Final sorting result: {}", enabledProfiles.stream().map(ResourcePackProfile::getId).toList());
}

public static boolean containsDefault(String filename, boolean modBundled) {
Expand All @@ -129,7 +129,7 @@ public static InputStream getDefaultIcon() throws IOException {
public static InputStream openDefault(ModContainer container, ResourceType type, String filename) throws IOException {
switch (filename) {
case "pack.mcmeta":
String description = Objects.requireNonNullElse(container.getMetadata().getName(), "");
String description = Objects.requireNonNullElse(container.getMetadata().getId(), "");
String metadata = serializeMetadata(SharedConstants.getGameVersion().getResourceVersion(type), description);
return IOUtils.toInputStream(metadata, Charsets.UTF_8);
case "pack.png":
Expand Down Expand Up @@ -162,8 +162,8 @@ public static String serializeMetadata(int packVersion, String description) {
}

public static Text getName(ModMetadata info) {
if (info.getName() != null) {
return Text.literal(info.getName());
if (info.getId() != null) {
return Text.literal(info.getId());
} else {
return Text.translatable("pack.name.fabricMod", info.getId());
}
Expand All @@ -186,15 +186,15 @@ public static DataConfiguration createDefaultDataConfiguration() {
// as the data pack screen automatically put any data pack as disabled except the Default data pack.
for (ResourcePackProfile profile : moddedResourcePacks) {
if (profile.getSource() == ModResourcePackCreator.RESOURCE_PACK_SOURCE) {
enabled.add(profile.getName());
enabled.add(profile.getId());
continue;
}

try (ResourcePack pack = profile.createResourcePack()) {
if (pack instanceof ModNioResourcePack && ((ModNioResourcePack) pack).getActivationType().isEnabledByDefault()) {
enabled.add(profile.getName());
enabled.add(profile.getId());
} else {
disabled.add(profile.getName());
disabled.add(profile.getId());
}
}
}
Expand All @@ -214,7 +214,7 @@ public static DataPackSettings createTestServerSettings(List<String> enabled, Li
// Collect modded profiles
Set<String> moddedProfiles = new HashSet<>();
ModResourcePackCreator modResourcePackCreator = new ModResourcePackCreator(ResourceType.SERVER_DATA);
modResourcePackCreator.register(profile -> moddedProfiles.add(profile.getName()));
modResourcePackCreator.register(profile -> moddedProfiles.add(profile.getId()));

// Remove them from the enabled list
List<String> moveToTheEnd = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import org.jetbrains.annotations.Nullable;

import net.minecraft.SharedConstants;
import net.minecraft.class_9224;
import net.minecraft.resource.InputSupplier;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourcePackInfo;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourceType;
import net.minecraft.resource.metadata.PackResourceMetadata;
Expand All @@ -36,7 +36,7 @@
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public record PlaceholderResourcePack(ResourceType type, class_9224 metadata) implements ResourcePack {
public record PlaceholderResourcePack(ResourceType type, ResourcePackInfo metadata) implements ResourcePack {
private static final Text DESCRIPTION_TEXT = Text.translatable("pack.description.modResources");

public PackResourceMetadata getMetadata() {
Expand Down Expand Up @@ -89,27 +89,27 @@ public <T> T parseMetadata(ResourceMetadataReader<T> metaReader) {
}

@Override
public class_9224 method_56926() {
public ResourcePackInfo getInfo() {
return metadata;
}

@Override
public String getName() {
public String getId() {
return ModResourcePackCreator.FABRIC;
}

@Override
public void close() {
}

public record Factory(ResourceType type, class_9224 metadata) implements ResourcePackProfile.PackFactory {
public record Factory(ResourceType type, ResourcePackInfo metadata) implements ResourcePackProfile.PackFactory {
@Override
public ResourcePack open(class_9224 var1) {
public ResourcePack open(ResourcePackInfo var1) {
return new PlaceholderResourcePack(this.type, metadata);
}

@Override
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
public ResourcePack openWithOverlays(ResourcePackInfo var1, ResourcePackProfile.Metadata metadata) {
return open(var1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.minecraft.class_9224;
import net.minecraft.class_9225;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourcePackInfo;
import net.minecraft.resource.ResourcePackPosition;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourceReloader;
import net.minecraft.resource.ResourceType;
Expand Down Expand Up @@ -115,26 +115,26 @@ public static void registerBuiltinResourcePacks(ResourceType resourceType, Consu
// Add the built-in pack only if namespaces for the specified resource type are present.
if (!pack.getNamespaces(resourceType).isEmpty()) {
// Make the resource pack profile for built-in pack, should never be always enabled.
class_9224 info = new class_9224(
entry.getRight().getName(),
ResourcePackInfo info = new ResourcePackInfo(
entry.getRight().getId(),
entry.getLeft(),
new BuiltinModResourcePackSource(pack.getFabricModMetadata().getName()),
Optional.empty()
);
class_9225 info2 = new class_9225(
ResourcePackPosition info2 = new ResourcePackPosition(
pack.getActivationType() == ResourcePackActivationType.ALWAYS_ENABLED,
ResourcePackProfile.InsertionPosition.TOP,
false // TODO check me
);

ResourcePackProfile profile = ResourcePackProfile.create(info, new ResourcePackProfile.PackFactory() {
@Override
public ResourcePack open(class_9224 var1) {
public ResourcePack open(ResourcePackInfo var1) {
return entry.getRight();
}

@Override
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
public ResourcePack openWithOverlays(ResourcePackInfo var1, ResourcePackProfile.Metadata metadata) {
// Don't support overlays in builtin res packs.
return entry.getRight();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class DatapackCommandMixin {
private static final DynamicCommandExceptionType INTERNAL_PACK_EXCEPTION = new DynamicCommandExceptionType(
packName -> Text.stringifiedTranslatable("commands.datapack.fabric.internal", packName));

@Redirect(method = "method_13136", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackManager;getEnabledNames()Ljava/util/Collection;"))
@Redirect(method = "method_13136", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourcePackManager;getEnabledIds()Ljava/util/Collection;"))
private static Collection<String> filterEnabledPackSuggestions(ResourcePackManager dataPackManager) {
return dataPackManager.getEnabledProfiles().stream().filter(profile -> !((FabricResourcePackProfile) profile).fabric_isHidden()).map(ResourcePackProfile::getName).toList();
return dataPackManager.getEnabledProfiles().stream().filter(profile -> !((FabricResourcePackProfile) profile).fabric_isHidden()).map(ResourcePackProfile::getId).toList();
}

@WrapOperation(method = "method_13120", at = @At(value = "INVOKE", target = "Ljava/util/stream/Stream;filter(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;", ordinal = 0))
Expand All @@ -63,6 +63,6 @@ private static Stream<ResourcePackProfile> filterDisabledPackSuggestions(Stream<

@Inject(method = "getPackContainer", at = @At(value = "INVOKE", target = "Ljava/util/Collection;contains(Ljava/lang/Object;)Z", shift = At.Shift.BEFORE))
private static void errorOnInternalPack(CommandContext<ServerCommandSource> context, String name, boolean enable, CallbackInfoReturnable<ResourcePackProfile> cir, @Local ResourcePackProfile profile) throws CommandSyntaxException {
if (((FabricResourcePackProfile) profile).fabric_isHidden()) throw INTERNAL_PACK_EXCEPTION.create(profile.getName());
if (((FabricResourcePackProfile) profile).fabric_isHidden()) throw INTERNAL_PACK_EXCEPTION.create(profile.getId());
}
}
Loading

0 comments on commit 6c5d520

Please sign in to comment.