diff --git a/gradle.properties b/gradle.properties index 0ab81c7..2326456 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G # Mod Properties -projectVersion=4.0.0 +projectVersion=4.1.0 maven_group=gay.ampflower.mod curseforgeId=914551 diff --git a/libs.versions.toml b/libs.versions.toml index 93208ea..0edb02d 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -1,9 +1,9 @@ [versions] # Minecraft -minecraft_version = "1.19.2" -minecraft_required = "1.17" -minecraft_compatible = "1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3" +minecraft_version = "1.20.1" +minecraft_required = "1.20" +minecraft_compatible = "1.20,1.20.1" fabric_loader = "0.14.21" diff --git a/src/main/java/tfar/fastbench/MixinHooks.java b/src/main/java/tfar/fastbench/MixinHooks.java index 7ef7850..01e0fa4 100644 --- a/src/main/java/tfar/fastbench/MixinHooks.java +++ b/src/main/java/tfar/fastbench/MixinHooks.java @@ -55,7 +55,7 @@ public static void slotChangedCraftingGrid(Level level, CraftingContainer inv, R if (recipe == null || !recipe.matches(inv, level)) recipe = findRecipe(inv, level); if (recipe != null) { - itemstack = recipe.assemble(inv); + itemstack = recipe.assemble(inv, level.registryAccess()); } result.setItem(0, itemstack); @@ -71,13 +71,13 @@ public static ItemStack handleShiftCraft(Player player, AbstractContainerMenu co Recipe recipe = (Recipe) craftResult.getRecipeUsed(); if (recipe != null && resultSlot != null && resultSlot.hasItem()) { - while (recipe.matches(input, player.level)) { + while (recipe.matches(input, player.level())) { ItemStack recipeOutput = resultSlot.getItem().copy(); outputCopy = recipeOutput.copy(); - recipeOutput.getItem().onCraftedBy(recipeOutput, player.level, player); + recipeOutput.getItem().onCraftedBy(recipeOutput, player.level(), player); - if (!player.level.isClientSide && !((ContainerAccessor) container).insert(recipeOutput, outStart, outEnd, true)) { + if (!player.level().isClientSide && !((ContainerAccessor) container).insert(recipeOutput, outStart, outEnd, true)) { duck.setCheckMatrixChanges(true); return ItemStack.EMPTY; } @@ -85,7 +85,7 @@ public static ItemStack handleShiftCraft(Player player, AbstractContainerMenu co resultSlot.onQuickCraft(recipeOutput, outputCopy); resultSlot.setChanged(); - if (!player.level.isClientSide && recipeOutput.getCount() == outputCopy.getCount()) { + if (!player.level().isClientSide && recipeOutput.getCount() == outputCopy.getCount()) { duck.setCheckMatrixChanges(true); return ItemStack.EMPTY; } @@ -95,7 +95,7 @@ public static ItemStack handleShiftCraft(Player player, AbstractContainerMenu co //player.drop(resultSlot.getItem(), false); } duck.setCheckMatrixChanges(true); - slotChangedCraftingGrid(player.level, input, craftResult); + slotChangedCraftingGrid(player.level(), input, craftResult); // Award the player the recipe for using it. Mimics vanilla behaviour. if (!recipe.isSpecial()) { diff --git a/src/main/java/tfar/fastbench/mixin/CraftingContainerMixin.java b/src/main/java/tfar/fastbench/mixin/CraftingContainerMixin.java index a13df3e..ccdd760 100644 --- a/src/main/java/tfar/fastbench/mixin/CraftingContainerMixin.java +++ b/src/main/java/tfar/fastbench/mixin/CraftingContainerMixin.java @@ -28,7 +28,7 @@ import net.minecraft.world.Container; import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.inventory.TransientCraftingContainer; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -36,7 +36,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; import tfar.fastbench.interfaces.CraftingInventoryDuck; -@Mixin(CraftingContainer.class) +@Mixin(TransientCraftingContainer.class) public class CraftingContainerMixin implements CraftingInventoryDuck { @Shadow diff --git a/src/main/java/tfar/fastbench/mixin/CraftingInventoryAccessor.java b/src/main/java/tfar/fastbench/mixin/CraftingInventoryAccessor.java index a2ee2db..2089bb8 100644 --- a/src/main/java/tfar/fastbench/mixin/CraftingInventoryAccessor.java +++ b/src/main/java/tfar/fastbench/mixin/CraftingInventoryAccessor.java @@ -15,12 +15,12 @@ package tfar.fastbench.mixin; import net.minecraft.core.NonNullList; -import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.inventory.TransientCraftingContainer; import net.minecraft.world.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(CraftingContainer.class) +@Mixin(TransientCraftingContainer.class) public interface CraftingInventoryAccessor { @Accessor NonNullList getItems(); diff --git a/src/main/java/tfar/fastbench/mixin/CraftingMenuMixin.java b/src/main/java/tfar/fastbench/mixin/CraftingMenuMixin.java index ab013ac..695df6a 100644 --- a/src/main/java/tfar/fastbench/mixin/CraftingMenuMixin.java +++ b/src/main/java/tfar/fastbench/mixin/CraftingMenuMixin.java @@ -65,7 +65,7 @@ protected CraftingMenuMixin(@Nullable MenuType type, int syncId) { @Overwrite public void slotsChanged(Container inventory) { - access.execute((lvl, pos) -> MixinHooks.slotChangedCraftingGrid(this.player.level, craftSlots, resultSlots)); + access.execute((lvl, pos) -> MixinHooks.slotChangedCraftingGrid(this.player.level(), craftSlots, resultSlots)); } @Inject(method = "quickMoveStack", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/tfar/fastbench/mixin/CraftingResultSlotMixin.java b/src/main/java/tfar/fastbench/mixin/CraftingResultSlotMixin.java index e73ef2d..3c806f4 100644 --- a/src/main/java/tfar/fastbench/mixin/CraftingResultSlotMixin.java +++ b/src/main/java/tfar/fastbench/mixin/CraftingResultSlotMixin.java @@ -43,6 +43,7 @@ import tfar.fastbench.interfaces.CraftingInventoryDuck; import java.util.Collections; +import java.util.List; @Mixin(ResultSlot.class) public class CraftingResultSlotMixin extends Slot { @@ -66,15 +67,15 @@ private ItemStack copy(Slot slot, int amount) { @Override public void set(ItemStack stack) { - if (player.level.isClientSide) { + if (player.level().isClientSide) { super.set(stack); } //do nothing } @Redirect(method = "checkTakeAchievements", - at = @At(value = "INVOKE",target = "Lnet/minecraft/world/inventory/RecipeHolder;awardUsedRecipes(Lnet/minecraft/world/entity/player/Player;)V")) - public void no(RecipeHolder recipeUnlocker, Player player) { + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/RecipeHolder;awardUsedRecipes(Lnet/minecraft/world/entity/player/Player;Ljava/util/List;)V")) + public void no(final RecipeHolder instance, final Player player, final List list) { if (((CraftingInventoryDuck) craftSlots).getCheckMatrixChanges() && this.container instanceof RecipeHolder recipeHolder) { var recipeUsed = recipeHolder.getRecipeUsed(); @@ -89,7 +90,7 @@ public void no(RecipeHolder recipeUnlocker, Player player) { @Inject(method = "onTake", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/crafting/RecipeManager;getRemainingItemsFor(Lnet/minecraft/world/item/crafting/RecipeType;Lnet/minecraft/world/Container;Lnet/minecraft/world/level/Level;)Lnet/minecraft/core/NonNullList;")) private void cache(Player player, ItemStack stack, CallbackInfo ci) { Recipe lastRecipe = (Recipe) ((ResultContainer)this.container).getRecipeUsed(); - MixinHooks.lastRecipe = lastRecipe != null && lastRecipe.matches(craftSlots, player.level) ? lastRecipe : null; + MixinHooks.lastRecipe = lastRecipe != null && lastRecipe.matches(craftSlots, player.level()) ? lastRecipe : null; MixinHooks.hascachedrecipe = true; } } \ No newline at end of file diff --git a/src/main/java/tfar/fastbench/mixin/PlayerContainerMixin.java b/src/main/java/tfar/fastbench/mixin/PlayerContainerMixin.java index 8430506..ff119c1 100644 --- a/src/main/java/tfar/fastbench/mixin/PlayerContainerMixin.java +++ b/src/main/java/tfar/fastbench/mixin/PlayerContainerMixin.java @@ -57,7 +57,7 @@ abstract class PlayerContainerMixin extends AbstractContainerMenu implements Cra @Inject(method = "slotsChanged", at = @At("HEAD"), cancellable = true) private void updateResult(Container inventory, CallbackInfo ci) { - MixinHooks.slotChangedCraftingGrid(owner.level, craftSlots, resultSlots); + MixinHooks.slotChangedCraftingGrid(owner.level(), craftSlots, resultSlots); } @Inject(method = "quickMoveStack", at = @At("HEAD"), cancellable = true)