Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.20.2 #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.14.21
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.15.0
# check available versions on maven for the given minecraft version you are using
carpet_core_version=1.4.112+v230608
carpet_core_version=1.4.119+v230928


# Mod Properties
mod_version = 1.4.112
mod_version = 1.4.119
maven_group = carpet-autocraftingtable
archives_base_name = carpet-autocraftingtable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeMatcher;
import net.minecraft.recipe.RecipeUnlocker;
import net.minecraft.recipe.book.RecipeBookCategory;
Expand Down Expand Up @@ -59,8 +60,8 @@ public boolean canInsertIntoSlot(ItemStack stack, Slot slot) {
}

@Override
public boolean matches(Recipe<? super CraftingInventory> recipe) {
return this.blockEntity.matches(recipe);
public boolean matches(RecipeEntry<? extends Recipe<CraftingInventory>> recipe) {
return this.blockEntity.matches(recipe.value());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeInputProvider;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.recipe.RecipeMatcher;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.RecipeUnlocker;
import net.minecraft.recipe.*;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.screen.ScreenHandler;
Expand All @@ -44,7 +38,7 @@ public class CraftingTableBlockEntity extends LockableContainerBlockEntity imple
private static final int[] INPUT_SLOTS = {1, 2, 3, 4, 5, 6, 7, 8, 9};
public DefaultedList<ItemStack> inventory;
public ItemStack output = ItemStack.EMPTY;
private Recipe<?> lastRecipe;
private RecipeEntry<?> lastRecipe;
private final List<AutoCraftingTableContainer> openContainers = new ArrayList<>();

public CraftingTableBlockEntity(BlockPos pos, BlockState state) { //this(BlockEntityType.BARREL);
Expand Down Expand Up @@ -170,12 +164,12 @@ public void provideRecipeInputs(RecipeMatcher finder) {
}

@Override
public void setLastRecipe(Recipe<?> recipe) {
public void setLastRecipe(RecipeEntry<?> recipe) {
lastRecipe = recipe;
}

@Override
public Recipe<?> getLastRecipe() {
public RecipeEntry<?> getLastRecipe() {
return lastRecipe;
}

Expand All @@ -188,18 +182,28 @@ private Optional<CraftingRecipe> getCurrentRecipe() {
// No need to find recipes if the inventory is empty. Cannot craft anything.
if (this.world == null || this.isEmpty()) return Optional.empty();

CraftingRecipe lastRecipe = (CraftingRecipe) getLastRecipe();
CraftingRecipe lastRecipe;
try {
lastRecipe = (CraftingRecipe) getLastRecipe().value();
} catch (NullPointerException e) {
lastRecipe = null;
}
RecipeManager manager = this.world.getRecipeManager();

if (lastRecipe != null) {
CraftingRecipe mapRecipe = manager.getAllOfType(RecipeType.CRAFTING).get(lastRecipe);
CraftingRecipe mapRecipe;
try {
mapRecipe = manager.getAllOfType(RecipeType.CRAFTING).get(lastRecipe).value();
} catch (NullPointerException e) {
mapRecipe = null;
}
if (mapRecipe != null && mapRecipe.matches(craftingInventory, world)) {
return Optional.of(lastRecipe);
}
}
Optional<CraftingRecipe> recipe = manager.getFirstMatch(RecipeType.CRAFTING, craftingInventory, world);
Optional<RecipeEntry<CraftingRecipe>> recipe = manager.getFirstMatch(RecipeType.CRAFTING, craftingInventory, world);
recipe.ifPresent(this::setLastRecipe);
return recipe;
return recipe.map(RecipeEntry::value);
}

private ItemStack craft() {
Expand Down