Skip to content

Commit

Permalink
24w06a
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Feb 7, 2024
1 parent b77b568 commit 54b4400
Show file tree
Hide file tree
Showing 26 changed files with 197 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ItemStack tryInsert(ItemStack input, boolean simulate) {
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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Advancement.Builder getAdvancementBuilder() {
}

@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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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(

This comment has been minimized.

Copy link
@modmuss50

modmuss50 Feb 7, 2024

Author Member

If anyone can do better than this please let me know. Im not too happy about having to duplicate this. It unlikely going to change a lot however.

new FailSoftMapCodec<>(RegistryKey.createCodec(RegistryKeys.DIMENSION), DimensionOptions.CODEC)
.fieldOf("dimensions").forGetter(DimensionOptionsRegistryHolder::dimensions)
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"EntityMixin",
"RegistryCodecsMixin",
"DimensionOptionsRegistryHolderMixin",
"Schema2832Mixin",
"TaggedChoiceMixin",
"TaggedChoiceTypeMixin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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() {
Expand All @@ -53,7 +53,7 @@ private static ArmorMaterial createTestArmorMaterial() {
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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
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}) {
Expand All @@ -61,7 +61,7 @@ public void damageFoodTest(TestContext context) {

@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);
Expand All @@ -80,9 +80,9 @@ public void nameFoodTest(TestContext context) {

@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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void addAfter(ItemConvertible afterLast, Collection<ItemStack> newStacks,
/**
* 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.
Expand Down Expand Up @@ -331,7 +331,7 @@ public void addBefore(ItemConvertible beforeFirst, Collection<ItemStack> newStac
/**
* 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.
Expand Down Expand Up @@ -431,7 +431,7 @@ private static void addBefore(ItemStack anchor, Collection<ItemStack> newStacks,
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;
}
Expand All @@ -446,7 +446,7 @@ private static void addAfter(ItemStack anchor, Collection<ItemStack> newStacks,

// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void onClearWorld(CallbackInfo ci) {
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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;
Expand Down Expand Up @@ -145,7 +146,7 @@ public R buildAndRegister() {
}

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

return registry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,7 +55,7 @@ private static void filterNonSyncedEntries(DynamicRegistryManager.Entry<?> entry
*/
@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
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;
Expand Down Expand Up @@ -150,7 +151,7 @@ private void onChange(RegistryKey<T> registryKey) {
}

@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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

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
Expand Down Expand Up @@ -72,7 +72,7 @@ private static ArmorMaterial createTestArmorMaterial() {
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
);
Expand Down

0 comments on commit 54b4400

Please sign in to comment.