Skip to content

Commit

Permalink
Update to 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ampflower committed Sep 24, 2023
1 parent c200f42 commit 661097b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/tfar/fastbench/MixinHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -71,21 +71,21 @@ public static ItemStack handleShiftCraft(Player player, AbstractContainerMenu co
Recipe<CraftingContainer> recipe = (Recipe<CraftingContainer>) 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;
}

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;
}
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@

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;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import tfar.fastbench.interfaces.CraftingInventoryDuck;

@Mixin(CraftingContainer.class)
@Mixin(TransientCraftingContainer.class)
public class CraftingContainerMixin implements CraftingInventoryDuck {

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemStack> getItems();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tfar/fastbench/mixin/CraftingMenuMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<ItemStack> list) {
if (((CraftingInventoryDuck) craftSlots).getCheckMatrixChanges() &&
this.container instanceof RecipeHolder recipeHolder) {
var recipeUsed = recipeHolder.getRecipeUsed();
Expand All @@ -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<CraftingContainer> lastRecipe = (Recipe<CraftingContainer>) ((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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 661097b

Please sign in to comment.