This commit is contained in:
modmuss50 2024-02-07 19:01:58 +00:00
parent b77b568afd
commit 54b4400cee
26 changed files with 197 additions and 165 deletions
fabric-api-lookup-api-v1/src/testmod/java/net/fabricmc/fabric/test/lookup/compat
fabric-data-generation-api-v1/src/main
java/net/fabricmc/fabric/api/datagen/v1/provider
resources
fabric-dimensions-v1/src/main
fabric-item-api-v1/src
client/java/net/fabricmc/fabric/mixin/item/client
testmod/java/net/fabricmc/fabric/test/item
fabric-item-group-api-v1/src/main/java/net/fabricmc/fabric/api/itemgroup/v1
fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client
fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/mixin/object/builder
fabric-registry-sync-v0/src/main/java/net/fabricmc/fabric
fabric-rendering-v1/src/testmod/java/net/fabricmc/fabric/test/rendering
fabric-resource-loader-v0/src
fabric-transfer-api-v1/src/main/java/net/fabricmc/fabric/mixin/transfer
fabric-transitive-access-wideners-v1/src/main/resources
gradle.properties

View file

@ -60,7 +60,7 @@ final class WrappedInventory implements ItemInsertable, ItemExtractable {
if (inv.isValid(i, input)) {
ItemStack stack = inv.getStack(i);
if (stack.isEmpty() || ItemStack.canCombine(stack, input)) {
if (stack.isEmpty() || ItemStack.areItemsAndNbtEqual(stack, input)) {
int remainingSpace = Math.min(inv.getMaxCountPerStack(), stack.getItem().getMaxCount()) - stack.getCount();
int inserted = Math.min(remainingSpace, input.getCount());

View file

@ -87,7 +87,7 @@ public abstract class FabricRecipeProvider extends RecipeProvider {
}
@Override
public CompletableFuture<?> method_56888(DataWriter writer, RegistryWrapper.WrapperLookup wrapperLookup) {
public CompletableFuture<?> run(DataWriter writer, RegistryWrapper.WrapperLookup wrapperLookup) {
Set<Identifier> generatedRecipes = Sets.newHashSet();
List<CompletableFuture<?>> list = new ArrayList<>();
generate(new RecipeExporter() {

View file

@ -64,7 +64,7 @@ transitive-accessible field net/minecraft/data/server/loottable/BlockLootTableGe
### Generated access wideners below
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider method_56888 (Lnet/minecraft/data/DataWriter;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Ljava/util/concurrent/CompletableFuture;
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider run (Lnet/minecraft/data/DataWriter;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)Ljava/util/concurrent/CompletableFuture;
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider saveRecipeAdvancement (Lnet/minecraft/data/DataWriter;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;Lnet/minecraft/advancement/AdvancementEntry;)Ljava/util/concurrent/CompletableFuture;
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generate (Lnet/minecraft/data/server/recipe/RecipeExporter;)V
transitive-accessible method net/minecraft/data/server/recipe/RecipeProvider generateFamilies (Lnet/minecraft/data/server/recipe/RecipeExporter;Lnet/minecraft/resource/featuretoggle/FeatureSet;)V

View file

@ -0,0 +1,47 @@
/*
* 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.dimension;
import com.mojang.datafixers.Products;
import com.mojang.datafixers.kinds.App;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.world.dimension.DimensionOptions;
import net.minecraft.world.dimension.DimensionOptionsRegistryHolder;
import net.fabricmc.fabric.impl.dimension.FailSoftMapCodec;
@Mixin(DimensionOptionsRegistryHolder.class)
public class DimensionOptionsRegistryHolderMixin {
/**
* Fix the issue that cannot load world after uninstalling a dimension mod/datapack.
* After uninstalling a dimension mod/datapack, the dimension config in `level.dat` file cannot be deserialized.
* The solution is to make it fail-soft.
*/
@Redirect(method = "method_45516", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;group(Lcom/mojang/datafixers/kinds/App;)Lcom/mojang/datafixers/Products$P1;"))
private static Products.P1 useFailSoftMap(RecordCodecBuilder.Instance instance, App app) {
return instance.group(
new FailSoftMapCodec<>(RegistryKey.createCodec(RegistryKeys.DIMENSION), DimensionOptions.CODEC)
.fieldOf("dimensions").forGetter(DimensionOptionsRegistryHolder::dimensions)
);
}
}

View file

@ -1,62 +0,0 @@
/*
* 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.dimension;
import java.util.Map;
import com.mojang.serialization.Codec;
import com.mojang.serialization.Lifecycle;
import com.mojang.serialization.codecs.UnboundedMapCodec;
import org.apache.commons.lang3.Validate;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryCodecs;
import net.minecraft.registry.RegistryKey;
import net.fabricmc.fabric.impl.dimension.FailSoftMapCodec;
@Mixin(RegistryCodecs.class)
public class RegistryCodecsMixin {
/**
* Fix the issue that cannot load world after uninstalling a dimension mod/datapack.
* After uninstalling a dimension mod/datapack, the dimension config in `level.dat` file cannot be deserialized.
* The solution is to make it fail-soft.
* Currently (1.19.3), `createKeyedRegistryCodec` is only used in dimension codec.
*/
@ModifyVariable(
method = "createKeyedRegistryCodec",
at = @At(
value = "INVOKE_ASSIGN",
target = "Lcom/mojang/serialization/Codec;unboundedMap(Lcom/mojang/serialization/Codec;Lcom/mojang/serialization/Codec;)Lcom/mojang/serialization/codecs/UnboundedMapCodec;",
remap = false
),
ordinal = 1 // there are two local variables of `Codec` type. Modify the second.
)
private static <E> Codec<Map<RegistryKey<E>, E>> modifyCodecLocalVariable(
Codec<Map<RegistryKey<E>, E>> originalVariable,
RegistryKey<? extends Registry<E>> registryRef,
Lifecycle lifecycle, Codec<E> elementCodec
) {
// make sure that it's not modifying the wrong variable
Validate.isTrue(originalVariable instanceof UnboundedMapCodec<?, ?>);
return new FailSoftMapCodec<>(RegistryKey.createCodec(registryRef), elementCodec);
}
}

View file

@ -4,7 +4,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"EntityMixin",
"RegistryCodecsMixin",
"DimensionOptionsRegistryHolderMixin",
"Schema2832Mixin",
"TaggedChoiceMixin",
"TaggedChoiceTypeMixin"

View file

@ -45,12 +45,12 @@ public class ClientPlayerInteractionManagerMixin {
@Redirect(
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/item/ItemStack;canCombine(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z"
target = "Lnet/minecraft/item/ItemStack;areItemsAndNbtEqual(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z"
),
method = "isCurrentlyBreaking"
)
private boolean fabricItemContinueBlockBreakingInject(ItemStack stack, ItemStack otherStack) {
boolean stackUnchanged = ItemStack.canCombine(stack, this.selectedStack);
boolean stackUnchanged = ItemStack.areItemsAndNbtEqual(stack, this.selectedStack);
if (!stackUnchanged) {
// The stack changed and vanilla is about to cancel block breaking progress. Check if the item wants to continue block breaking instead.

View file

@ -34,7 +34,7 @@ import net.minecraft.util.Util;
import net.fabricmc.api.ModInitializer;
public class ArmorKnockbackResistanceTest implements ModInitializer {
private static final RegistryEntry<ArmorMaterial> WOOD_ARMOR = Registry.registerReference(Registries.field_48976, new Identifier("fabric-item-api-v1-testmod", "wood"), createTestArmorMaterial());
private static final RegistryEntry<ArmorMaterial> WOOD_ARMOR = Registry.registerReference(Registries.ARMOR_MATERIAL, new Identifier("fabric-item-api-v1-testmod", "wood"), createTestArmorMaterial());
@Override
public void onInitialize() {
@ -53,7 +53,7 @@ public class ArmorKnockbackResistanceTest implements ModInitializer {
0,
SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,
() -> Ingredient.ofItems(Items.LEATHER),
List.of(new ArmorMaterial.class_9196(new Identifier("fabric-item-api-v1-testmod", "wood"))),
List.of(new ArmorMaterial.Layer(new Identifier("fabric-item-api-v1-testmod", "wood"))),
0,
0.5F
);

View file

@ -38,7 +38,7 @@ import net.fabricmc.fabric.test.item.FoodGameInitializer;
public final class FoodGameTest implements FabricGameTest {
@GameTest(templateName = EMPTY_STRUCTURE)
public void damageFoodTest(TestContext context) {
PlayerEntity player = context.createMockCreativePlayer(GameMode.SURVIVAL);
PlayerEntity player = context.createMockPlayer(GameMode.SURVIVAL);
HungerManager hungerManager = player.getHungerManager();
for (int damage : new int[]{0, 1, 10, 19}) {
@ -61,7 +61,7 @@ public final class FoodGameTest implements FabricGameTest {
@GameTest(templateName = EMPTY_STRUCTURE)
public void nameFoodTest(TestContext context) {
PlayerEntity player = context.createMockCreativePlayer(GameMode.SURVIVAL);
PlayerEntity player = context.createMockPlayer(GameMode.SURVIVAL);
HungerManager hungerManager = player.getHungerManager();
hungerManager.setFoodLevel(0);
hungerManager.setSaturationLevel(0);
@ -80,9 +80,9 @@ public final class FoodGameTest implements FabricGameTest {
@GameTest(templateName = EMPTY_STRUCTURE)
public void nameMeatTest(TestContext context) {
PlayerEntity player = context.createMockCreativePlayer(GameMode.SURVIVAL);
PlayerEntity player = context.createMockPlayer(GameMode.SURVIVAL);
WolfEntity wolf = context.spawnEntity(EntityType.WOLF, context.getRelative(Vec3d.ZERO));
wolf.setTamed(true);
wolf.setTamed(true, true);
wolf.setOwner(player);
wolf.setHealth(1f);
ItemStack meat = FoodGameInitializer.NAME.getDefaultStack();

View file

@ -214,7 +214,7 @@ public class FabricItemGroupEntries implements ItemGroup.Entries {
/**
* Adds stacks after an existing stack in the group, or at the end, if the stack isn't in the group.
*
* @param afterLast Add {@code newStacks} after the last group entry matching this stack (compared using {@link ItemStack#canCombine}).
* @param afterLast Add {@code newStacks} after the last group entry matching this stack (compared using {@link ItemStack#areItemsAndNbtEqual}).
* @param newStacks The stacks to add. Only {@linkplain #isEnabled(ItemStack) enabled} stacks will be added.
* @param visibility Determines whether the stack will be shown in the tab itself, returned
* for searches, or both.
@ -331,7 +331,7 @@ public class FabricItemGroupEntries implements ItemGroup.Entries {
/**
* Adds stacks before an existing stack to the group, or at the end, if the stack isn't in the group.
*
* @param beforeFirst Add {@code newStacks} before the first group entry matching this stack (compared using {@link ItemStack#canCombine}).
* @param beforeFirst Add {@code newStacks} before the first group entry matching this stack (compared using {@link ItemStack#areItemsAndNbtEqual}).
* @param newStacks The stacks to add. Only {@linkplain #isEnabled(ItemStack) enabled} stacks will be added.
* @param visibility Determines whether the stack will be shown in the tab itself, returned
* for searches, or both.
@ -431,7 +431,7 @@ public class FabricItemGroupEntries implements ItemGroup.Entries {
checkStacks(newStacks);
for (int i = 0; i < addTo.size(); i++) {
if (ItemStack.canCombine(anchor, addTo.get(i))) {
if (ItemStack.areItemsAndNbtEqual(anchor, addTo.get(i))) {
addTo.subList(i, i).addAll(newStacks);
return;
}
@ -446,7 +446,7 @@ public class FabricItemGroupEntries implements ItemGroup.Entries {
// Iterate in reverse to add after the last match
for (int i = addTo.size() - 1; i >= 0; i--) {
if (ItemStack.canCombine(anchor, addTo.get(i))) {
if (ItemStack.areItemsAndNbtEqual(anchor, addTo.get(i))) {
addTo.subList(i + 1, i + 1).addAll(newStacks);
return;
}

View file

@ -99,7 +99,7 @@ abstract class ClientPlayNetworkHandlerMixin {
* Also invoked during GameJoin, but before Networking API fires the Ready event.
*/
@SuppressWarnings("ConstantConditions")
@Inject(method = "refreshTagBasedData", at = @At("RETURN"))
@Inject(method = "onSynchronizeTags", at = @At("RETURN"))
private void hookOnSynchronizeTags(CallbackInfo ci) {
ClientPlayNetworkHandler self = (ClientPlayNetworkHandler) (Object) this;
CommonLifecycleEvents.TAGS_LOADED.invoker().onTagsLoaded(self.getRegistryManager(), true);

View file

@ -16,15 +16,11 @@
package net.fabricmc.fabric.mixin.object.builder;
import java.io.File;
import java.io.FileInputStream;
import java.io.PushbackInputStream;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.datafixers.DataFixer;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import net.minecraft.datafixer.DataFixTypes;
import net.minecraft.nbt.NbtCompound;
@ -35,10 +31,12 @@ class PersistentStateManagerMixin {
/**
* Handle mods passing a null DataFixTypes to a PersistentState.Type.
*/
@Inject(method = "readNbt", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NbtHelper;getDataVersion(Lnet/minecraft/nbt/NbtCompound;I)I"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private void handleNullDataFixType(String id, DataFixTypes dataFixTypes, int currentSaveVersion, CallbackInfoReturnable<NbtCompound> cir, File file, FileInputStream fileInputStream, PushbackInputStream pushbackInputStream, NbtCompound nbtCompound) {
@WrapOperation(method = "readNbt", at = @At(value = "INVOKE", target = "Lnet/minecraft/datafixer/DataFixTypes;update(Lcom/mojang/datafixers/DataFixer;Lnet/minecraft/nbt/NbtCompound;II)Lnet/minecraft/nbt/NbtCompound;"))
private NbtCompound handleNullDataFixType(DataFixTypes dataFixTypes, DataFixer dataFixer, NbtCompound nbt, int oldVersion, int newVersion, Operation<NbtCompound> original) {
if (dataFixTypes == null) {
cir.setReturnValue(nbtCompound);
return nbt;
}
return original.call(dataFixTypes, dataFixer, nbt, oldVersion, newVersion);
}
}

View file

@ -20,6 +20,7 @@ import java.util.EnumSet;
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;
@ -145,7 +146,7 @@ public final class FabricRegistryBuilder<T, R extends MutableRegistry<T>> {
}
//noinspection unchecked
RegistriesAccessor.getROOT().add((RegistryKey<MutableRegistry<?>>) key, registry, Lifecycle.stable());
RegistriesAccessor.getROOT().add((RegistryKey<MutableRegistry<?>>) key, registry, class_9248.field_49136);
return registry;
}

View file

@ -16,6 +16,7 @@
package net.fabricmc.fabric.mixin.registry.sync;
import java.util.Set;
import java.util.function.BiConsumer;
import com.mojang.serialization.DynamicOps;
@ -54,7 +55,7 @@ abstract class SerializableRegistriesMixin {
*/
@Dynamic("method_56597: Optional.ifPresent in serialize")
@Inject(method = "method_56596", at = @At("HEAD"), cancellable = true)
private static void filterNonSyncedEntriesAgain(RegistryLoader.Entry entry, DynamicOps dynamicOps, BiConsumer biConsumer, Registry registry, CallbackInfo ci) {
private static void filterNonSyncedEntriesAgain(Set set, RegistryLoader.Entry entry, DynamicOps dynamicOps, BiConsumer biConsumer, Registry registry, CallbackInfo ci) {
boolean canSkip = DynamicRegistriesImpl.SKIP_EMPTY_SYNC_REGISTRIES.contains(registry.getKey());
if (canSkip && registry.size() == 0) {

View file

@ -46,6 +46,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
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;
@ -150,7 +151,7 @@ public abstract class SimpleRegistryMixin<T> implements MutableRegistry<T>, Rema
}
@Inject(method = "add", at = @At("RETURN"))
private void set(RegistryKey<T> key, T entry, Lifecycle lifecycle, CallbackInfoReturnable<RegistryEntry.Reference<T>> info) {
private void set(RegistryKey<T> key, T entry, class_9248 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.

View file

@ -38,7 +38,7 @@ import net.fabricmc.api.ModInitializer;
public class TooltipComponentTestInit implements ModInitializer {
public static Item CUSTOM_TOOLTIP_ITEM = new CustomTooltipItem();
public static RegistryEntry<ArmorMaterial> TEST_ARMOR_MATERIAL = Registry.registerReference(Registries.field_48976, new Identifier("fabric-rendering-v1-testmod", "test_material"), createTestArmorMaterial());
public static RegistryEntry<ArmorMaterial> TEST_ARMOR_MATERIAL = Registry.registerReference(Registries.ARMOR_MATERIAL, new Identifier("fabric-rendering-v1-testmod", "test_material"), createTestArmorMaterial());
public static Item CUSTOM_ARMOR_ITEM = new ArmorItem(TEST_ARMOR_MATERIAL, ArmorItem.Type.CHESTPLATE, new Item.Settings());
@Override
@ -72,7 +72,7 @@ public class TooltipComponentTestInit implements ModInitializer {
0,
SoundEvents.ITEM_ARMOR_EQUIP_LEATHER,
() -> Ingredient.ofItems(Items.LEATHER),
List.of(new ArmorMaterial.class_9196(new Identifier("fabric-rendering-v1-testmod", "test_material"))),
List.of(new ArmorMaterial.Layer(new Identifier("fabric-rendering-v1-testmod", "test_material"))),
0,
0
);

View file

@ -34,6 +34,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;
@ -41,11 +42,13 @@ import org.jetbrains.annotations.Nullable;
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.ResourceType;
import net.minecraft.resource.metadata.ResourceMetadataReader;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.PathUtil;
@ -65,6 +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;
/**
* Whether the pack is bundled and loaded by default, as opposed to registered built-in packs.
* @see ModResourcePackUtil#appendModResourcePacks(List, ResourceType, String)
@ -95,12 +99,21 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
if (paths.isEmpty()) return null;
String packId = subPath == null ? id : id + "_" + subPath;
ModNioResourcePack ret = new ModNioResourcePack(packId, mod, paths, type, activationType, modBundled);
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(
packId,
displayName,
ModResourcePackCreator.RESOURCE_PACK_SOURCE,
Optional.empty()
);
ModNioResourcePack ret = new ModNioResourcePack(packId, mod, paths, type, activationType, modBundled, metadata);
return ret.getNamespaces(type).isEmpty() ? null : ret;
}
private ModNioResourcePack(String id, ModContainer mod, List<Path> paths, ResourceType type, ResourcePackActivationType activationType, boolean modBundled) {
private ModNioResourcePack(String id, ModContainer mod, List<Path> paths, ResourceType type, ResourcePackActivationType activationType, boolean modBundled, class_9224 metadata) {
this.id = id;
this.mod = mod;
this.basePaths = paths;
@ -108,6 +121,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
this.activationType = activationType;
this.modBundled = modBundled;
this.namespaces = readNamespaces(paths, mod.getMetadata().getId());
this.metadata = metadata;
}
@Override
@ -115,7 +129,7 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
// See DirectoryResourcePack.
return new ModNioResourcePack(id, mod, basePaths.stream().map(
path -> path.resolve(overlay)
).toList(), type, activationType, modBundled);
).toList(), type, activationType, modBundled, metadata);
}
static Map<ResourceType, Set<String>> readNamespaces(List<Path> paths, String modId) {
@ -270,6 +284,11 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
}
}
@Override
public class_9224 method_56926() {
return metadata;
}
@Override
public void close() {
}
@ -288,11 +307,6 @@ public class ModNioResourcePack implements ResourcePack, ModResourcePack {
return id;
}
@Override
public boolean isAlwaysStable() {
return this.modBundled;
}
private static boolean exists(Path path) {
// NIO Files.exists is notoriously slow when checking the file system
return path.getFileSystem() == DEFAULT_FS ? path.toFile().exists() : Files.exists(path);

View file

@ -18,6 +18,7 @@ package net.fabricmc.fabric.impl.resource.loader;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Predicate;
@ -25,6 +26,8 @@ import java.util.function.Predicate;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;
import net.minecraft.class_9224;
import net.minecraft.class_9225;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourcePackProvider;
import net.minecraft.resource.ResourcePackSource;
@ -65,6 +68,8 @@ public class ModResourcePackCreator implements ResourcePackProvider {
}
};
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 final ResourceType type;
public ModResourcePackCreator(ResourceType type) {
@ -90,14 +95,18 @@ public class ModResourcePackCreator implements ResourcePackProvider {
4. User resource packs
*/
consumer.accept(ResourcePackProfile.create(
class_9224 metadata = new class_9224(
FABRIC,
Text.translatable("pack.name.fabricMods"),
true,
new PlaceholderResourcePack.Factory(this.type),
RESOURCE_PACK_SOURCE,
Optional.empty()
);
consumer.accept(ResourcePackProfile.create(
metadata,
new PlaceholderResourcePack.Factory(this.type, metadata),
this.type,
ResourcePackProfile.InsertionPosition.TOP,
RESOURCE_PACK_SOURCE
ACTIVATION_INFO
));
// Build a list of mod resource packs.
@ -118,17 +127,11 @@ public class ModResourcePackCreator implements ResourcePackProvider {
ModResourcePackUtil.appendModResourcePacks(packs, this.type, subPath);
for (ModResourcePack pack : packs) {
Text displayName = subPath == null
? Text.translatable("pack.name.fabricMod", pack.getFabricModMetadata().getName())
: Text.translatable("pack.name.fabricMod.subPack", pack.getFabricModMetadata().getName(), Text.translatable("resourcePack." + subPath + ".name"));
ResourcePackProfile profile = ResourcePackProfile.create(
pack.getName(),
displayName,
subPath == null,
pack.method_56926(),
new ModResourcePackFactory(pack),
this.type,
ResourcePackProfile.InsertionPosition.TOP,
RESOURCE_PACK_SOURCE
ACTIVATION_INFO
);
if (profile != null) {

View file

@ -19,6 +19,7 @@ package net.fabricmc.fabric.impl.resource.loader;
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.ResourcePackProfile;
@ -27,12 +28,12 @@ import net.fabricmc.fabric.api.resource.ModResourcePack;
public record ModResourcePackFactory(ModResourcePack pack) implements ResourcePackProfile.PackFactory {
@Override
public ResourcePack open(String name) {
public ResourcePack open(class_9224 var1) {
return pack;
}
@Override
public ResourcePack openWithOverlays(String name, ResourcePackProfile.Metadata metadata) {
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
if (metadata.overlays().isEmpty()) {
return pack;
} else {

View file

@ -25,6 +25,7 @@ import org.apache.commons.io.IOUtils;
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.ResourcePackProfile;
@ -35,7 +36,7 @@ import net.minecraft.resource.metadata.ResourceMetadataReader;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public record PlaceholderResourcePack(ResourceType type) implements ResourcePack {
public record PlaceholderResourcePack(ResourceType type, class_9224 metadata) implements ResourcePack {
private static final Text DESCRIPTION_TEXT = Text.translatable("pack.description.modResources");
public PackResourceMetadata getMetadata() {
@ -87,6 +88,11 @@ public record PlaceholderResourcePack(ResourceType type) implements ResourcePack
return ResourceMetadataMap.of(PackResourceMetadata.SERIALIZER, getMetadata()).get(metaReader);
}
@Override
public class_9224 method_56926() {
return metadata;
}
@Override
public String getName() {
return ModResourcePackCreator.FABRIC;
@ -96,15 +102,15 @@ public record PlaceholderResourcePack(ResourceType type) implements ResourcePack
public void close() {
}
public record Factory(ResourceType type) implements ResourcePackProfile.PackFactory {
public record Factory(ResourceType type, class_9224 metadata) implements ResourcePackProfile.PackFactory {
@Override
public ResourcePack open(String name) {
return new PlaceholderResourcePack(this.type);
public ResourcePack open(class_9224 var1) {
return new PlaceholderResourcePack(this.type, metadata);
}
@Override
public ResourcePack openWithOverlays(String name, ResourcePackProfile.Metadata metadata) {
return open(name);
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
return open(var1);
}
}
}

View file

@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
@ -32,6 +33,8 @@ import com.google.common.collect.Lists;
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.ResourcePackProfile;
import net.minecraft.resource.ResourceReloader;
@ -112,18 +115,30 @@ public class ResourceManagerHelperImpl implements ResourceManagerHelper {
// 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.
ResourcePackProfile profile = ResourcePackProfile.create(entry.getRight().getName(), entry.getLeft(), pack.getActivationType() == ResourcePackActivationType.ALWAYS_ENABLED, new ResourcePackProfile.PackFactory() {
class_9224 info = new class_9224(
entry.getRight().getName(),
entry.getLeft(),
new BuiltinModResourcePackSource(pack.getFabricModMetadata().getName()),
Optional.empty()
);
class_9225 info2 = new class_9225(
pack.getActivationType() == ResourcePackActivationType.ALWAYS_ENABLED,
ResourcePackProfile.InsertionPosition.TOP,
false // TODO check me
);
ResourcePackProfile profile = ResourcePackProfile.create(info, new ResourcePackProfile.PackFactory() {
@Override
public ResourcePack open(String name) {
public ResourcePack open(class_9224 var1) {
return entry.getRight();
}
@Override
public ResourcePack openWithOverlays(String string, ResourcePackProfile.Metadata metadata) {
public ResourcePack openWithOverlays(class_9224 var1, ResourcePackProfile.Metadata metadata) {
// Don't support overlays in builtin res packs.
return entry.getRight();
}
}, resourceType, ResourcePackProfile.InsertionPosition.TOP, new BuiltinModResourcePackSource(pack.getFabricModMetadata().getName()));
}, resourceType, info2);
consumer.accept(profile);
}
}

View file

@ -19,7 +19,6 @@ package net.fabricmc.fabric.mixin.resource.loader;
import java.util.Set;
import java.util.function.Predicate;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
@ -27,6 +26,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.class_9224;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourcePackSource;
@ -45,15 +45,15 @@ import net.fabricmc.fabric.impl.resource.loader.ResourcePackSourceTracker;
abstract class ResourcePackProfileMixin implements FabricResourcePackProfile {
@Unique
private static final Predicate<Set<String>> DEFAULT_PARENT_PREDICATE = parents -> true;
@Shadow
@Final
private ResourcePackSource source;
@Unique
private Predicate<Set<String>> parentsPredicate = DEFAULT_PARENT_PREDICATE;
@Shadow
public abstract class_9224 method_56933();
@Inject(method = "createResourcePack", at = @At("RETURN"))
private void onCreateResourcePack(CallbackInfoReturnable<ResourcePack> info) {
ResourcePackSourceTracker.setSource(info.getReturnValue(), source);
ResourcePackSourceTracker.setSource(info.getReturnValue(), method_56933().source());
}
@Override

View file

@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.Predicate;
@ -35,6 +36,8 @@ import org.junit.jupiter.api.Test;
import net.minecraft.Bootstrap;
import net.minecraft.SharedConstants;
import net.minecraft.class_9224;
import net.minecraft.class_9225;
import net.minecraft.resource.ResourcePackProfile;
import net.fabricmc.fabric.impl.resource.loader.FabricResourcePackProfile;
@ -203,15 +206,19 @@ public class ModResourcePackUtilTests {
}
private ResourcePackProfile mockProfile(Map<String, ResourcePackProfile> profiles, String id, @Nullable Predicate<Set<String>> parents) {
ResourcePackProfile profile = ResourcePackProfile.of(
id,
null,
false,
ResourcePackProfile profile = new ResourcePackProfile(
new class_9224(
id,
null,
null,
Optional.empty()
),
null,
null,
null,
false,
ModResourcePackCreator.RESOURCE_PACK_SOURCE
new class_9225(
false,
null,
false)
);
if (parents != null) ((FabricResourcePackProfile) profile).fabric_setParentsPredicate(parents);

View file

@ -73,7 +73,7 @@ public abstract class AbstractFurnaceBlockEntityMixin extends LockableContainerB
ItemStack stack = newStack;
// Update cook time if needed. Code taken from AbstractFurnaceBlockEntity#setStack.
boolean bl = !stack.isEmpty() && ItemStack.canCombine(stack, itemStack);
boolean bl = !stack.isEmpty() && ItemStack.areItemsAndNbtEqual(stack, itemStack);
if (!bl) {
this.cookTimeTotal = getCookTime(this.world, (AbstractFurnaceBlockEntity) (Object) this);

View file

@ -306,7 +306,7 @@ transitive-accessible field net/minecraft/client/render/RenderPhase LIGHTNING_PR
transitive-accessible field net/minecraft/client/render/RenderPhase TRIPWIRE_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase END_PORTAL_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase END_GATEWAY_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase field_48949 Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase CLOUDS_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase LINES_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase GUI_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;
transitive-accessible field net/minecraft/client/render/RenderPhase GUI_OVERLAY_PROGRAM Lnet/minecraft/client/render/RenderPhase$ShaderProgram;

View file

@ -2,9 +2,9 @@ org.gradle.jvmargs=-Xmx2560M
org.gradle.parallel=true
fabric.loom.multiProjectOptimisation=true
version=0.95.5
minecraft_version=24w05a
yarn_version=+build.2
version=0.95.6
minecraft_version=24w06a
yarn_version=+build.1
loader_version=0.15.6
installer_version=0.11.1
@ -13,7 +13,7 @@ curseforge_minecraft_version=1.20.5-Snapshot
# Do not manually update, use the bumpversions task:
fabric-api-base-version=0.4.38
fabric-api-lookup-api-v1-version=1.6.51
fabric-api-lookup-api-v1-version=1.6.52
fabric-biome-api-v1-version=13.0.19
fabric-block-api-v1-version=1.0.18
fabric-block-view-api-v2-version=1.0.6
@ -21,44 +21,44 @@ fabric-blockrenderlayer-v1-version=1.1.48
fabric-command-api-v1-version=1.2.43
fabric-command-api-v2-version=2.2.22
fabric-commands-v0-version=0.2.60
fabric-content-registries-v0-version=6.0.5
fabric-content-registries-v0-version=6.0.6
fabric-crash-report-info-v1-version=0.2.25
fabric-data-attachment-api-v1-version=1.0.5
fabric-data-generation-api-v1-version=16.0.0
fabric-dimensions-v1-version=2.1.63
fabric-data-attachment-api-v1-version=1.0.6
fabric-data-generation-api-v1-version=16.0.1
fabric-dimensions-v1-version=2.1.64
fabric-entity-events-v1-version=1.6.1
fabric-events-interaction-v0-version=0.7.3
fabric-events-lifecycle-v0-version=0.2.77
fabric-events-lifecycle-v0-version=0.2.78
fabric-game-rule-api-v1-version=1.0.48
fabric-gametest-api-v1-version=1.3.4
fabric-item-api-v1-version=4.0.1
fabric-item-group-api-v1-version=4.0.25
fabric-gametest-api-v1-version=1.3.5
fabric-item-api-v1-version=4.0.2
fabric-item-group-api-v1-version=4.0.26
fabric-key-binding-api-v1-version=1.0.43
fabric-keybindings-v0-version=0.2.41
fabric-lifecycle-events-v1-version=2.2.34
fabric-loot-api-v2-version=2.1.9
fabric-lifecycle-events-v1-version=2.2.35
fabric-loot-api-v2-version=2.1.10
fabric-message-api-v1-version=6.0.7
fabric-mining-level-api-v1-version=2.1.65
fabric-mining-level-api-v1-version=2.1.66
fabric-model-loading-api-v1-version=1.0.10
fabric-models-v0-version=0.4.9
fabric-networking-api-v1-version=4.0.1
fabric-object-builder-api-v1-version=14.0.2
fabric-object-builder-api-v1-version=14.0.3
fabric-particles-v1-version=2.0.0
fabric-recipe-api-v1-version=3.0.1
fabric-registry-sync-v0-version=5.0.2
fabric-registry-sync-v0-version=5.0.3
fabric-renderer-api-v1-version=3.2.7
fabric-renderer-indigo-version=1.5.7
fabric-renderer-registries-v1-version=3.2.55
fabric-renderer-registries-v1-version=3.2.56
fabric-rendering-data-attachment-v1-version=0.3.44
fabric-rendering-fluids-v1-version=3.0.35
fabric-rendering-v0-version=1.1.58
fabric-rendering-v1-version=4.1.0
fabric-rendering-v0-version=1.1.59
fabric-rendering-v1-version=4.1.1
fabric-resource-conditions-api-v1-version=2.3.17
fabric-resource-loader-v0-version=0.11.20
fabric-resource-loader-v0-version=0.11.21
fabric-screen-api-v1-version=2.0.19
fabric-screen-handler-api-v1-version=1.3.58
fabric-screen-handler-api-v1-version=1.3.59
fabric-sound-api-v1-version=1.0.19
fabric-transfer-api-v1-version=4.0.13
fabric-transitive-access-wideners-v1-version=6.0.4
fabric-transfer-api-v1-version=4.0.14
fabric-transitive-access-wideners-v1-version=6.0.5
fabric-convention-tags-v1-version=1.5.13
fabric-client-tags-api-v1-version=1.1.9