Skip to content

Commit 9f1ffde

Browse files
committed
Update to 1.20.2
Version 1.0.12 - Expect a minor performance degradation because Mojang rewrite a huge chunk of the Recipe system. **This mod is in need of a rewrite, so that will be coming soon. It will hopefully bring massive performance improvements such as lithium's block entity sleeping!**
1 parent f5d4b6e commit 9f1ffde

File tree

5 files changed

+36
-23
lines changed

5 files changed

+36
-23
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import java.nio.charset.StandardCharsets
22

33
plugins {
4-
id 'fabric-loom' version '1.2-SNAPSHOT'
4+
id 'fabric-loom' version '1.3-SNAPSHOT'
55
id 'maven-publish'
6-
id("com.modrinth.minotaur") version "2.7.5"
6+
id("com.modrinth.minotaur") version "2.8.4"
77
}
88

99
sourceCompatibility = JavaVersion.VERSION_17
@@ -26,8 +26,8 @@ dependencies {
2626

2727
// Fabric API. This is technically optional, but you probably want it anyway.
2828
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
29-
modImplementation include("eu.pb4:polymer-core:0.5.0-rc.2+1.20-rc1")
30-
modImplementation include("xyz.nucleoid:server-translations-api:2.0.0-beta.2+1.19.4-pre2")
29+
modImplementation include("eu.pb4:polymer-core:0.6.0-rc.3+1.20.2-rc2")
30+
modImplementation include("xyz.nucleoid:server-translations-api:2.1.0+1.20.2-rc2")
3131
}
3232

3333
loom {

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
org.gradle.jvmargs=-Xmx1G
2-
minecraft_version=1.20-rc1
3-
yarn_mappings=1.20-rc1+build.2
4-
loader_version=0.14.21
5-
fabric_version=0.83.0+1.20
6-
mod_version=1.0.11
2+
minecraft_version=1.20.2
3+
yarn_mappings=1.20.2+build.1
4+
loader_version=0.14.22
5+
fabric_version=0.89.1+1.20.2
6+
mod_version=1.0.12
77
maven_group=com.github.tatercertified
88
archives_base_name=fabricautocrafter
99
modrinth_id=wbqioEpc

src/main/java/com/github/tatercertified/fabricautocrafter/AutoCraftingTableContainer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.minecraft.item.ItemStack;
1010
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
1111
import net.minecraft.recipe.Recipe;
12+
import net.minecraft.recipe.RecipeEntry;
1213
import net.minecraft.recipe.RecipeMatcher;
1314
import net.minecraft.recipe.RecipeUnlocker;
1415
import net.minecraft.screen.CraftingScreenHandler;
@@ -96,8 +97,8 @@ public void clearCraftingSlots() {
9697
}
9798

9899
@Override
99-
public boolean matches(Recipe<? super RecipeInputInventory> recipe) {
100-
return recipe.matches(this.crafting_inv, this.player.getWorld());
100+
public boolean matches(RecipeEntry<? extends Recipe<RecipeInputInventory>> recipe) {
101+
return recipe.value().matches(this.crafting_inv, this.player.getWorld());
101102
}
102103

103104
@Override

src/main/java/com/github/tatercertified/fabricautocrafter/CraftingTableBlockEntity.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@
1313
import net.minecraft.recipe.*;
1414
import net.minecraft.screen.ScreenHandler;
1515
import net.minecraft.text.Text;
16+
import net.minecraft.util.Identifier;
1617
import net.minecraft.util.ItemScatterer;
1718
import net.minecraft.util.collection.DefaultedList;
1819
import net.minecraft.util.math.BlockPos;
1920
import net.minecraft.util.math.Direction;
21+
import org.jetbrains.annotations.Nullable;
2022

2123
import java.util.ArrayList;
2224
import java.util.List;
25+
import java.util.Map;
2326
import java.util.Optional;
2427

2528
import static com.github.tatercertified.fabricautocrafter.AutoCrafterMod.TYPE;
@@ -35,7 +38,7 @@ public class CraftingTableBlockEntity extends LockableContainerBlockEntity imple
3538
private final CraftingInventory craftingInventory = new CraftingInventory(null, 3, 3);
3639
public DefaultedList<ItemStack> inventory;
3740
public ItemStack output = ItemStack.EMPTY;
38-
private Recipe<?> lastRecipe;
41+
private RecipeEntry<?> lastRecipe;
3942

4043
public CraftingTableBlockEntity(BlockPos pos, BlockState state) {
4144
super(TYPE, pos, state);
@@ -162,36 +165,45 @@ public void provideRecipeInputs(RecipeMatcher finder) {
162165
}
163166

164167
@Override
165-
public void setLastRecipe(Recipe<?> recipe) {
168+
public void setLastRecipe(@Nullable RecipeEntry<?> recipe) {
166169
lastRecipe = recipe;
167170
}
168171

169172
@Override
170-
public Recipe<?> getLastRecipe() {
173+
public RecipeEntry<?> getLastRecipe() {
171174
return lastRecipe;
172175
}
173176

177+
178+
174179
@Override
175180
public void clear() {
176181
this.inventory.clear();
177182
}
178183

179184
private Optional<CraftingRecipe> getCurrentRecipe() {
180-
//Optimization Code from Crec0
185+
// Optimization Code from Crec0
181186
if (this.world == null || this.isEmpty()) return Optional.empty();
182187

183-
CraftingRecipe lastRecipe = (CraftingRecipe) getLastRecipe();
184188
RecipeManager manager = this.world.getRecipeManager();
185189

186-
if (lastRecipe != null) {
187-
CraftingRecipe mapRecipe = manager.getAllOfType(RecipeType.CRAFTING).get(lastRecipe);
188-
if (mapRecipe != null && mapRecipe.matches(craftingInventory, world)) {
189-
return Optional.of(lastRecipe);
190+
var getLastRecipe = getLastRecipe();
191+
192+
if (getLastRecipe != null) {
193+
CraftingRecipe recipe = (CraftingRecipe) getLastRecipe.value();
194+
Map<Identifier, RecipeEntry<CraftingRecipe>> craftingRecipes = manager.getAllOfType(RecipeType.CRAFTING);
195+
if (craftingRecipes.containsKey(recipe) && craftingRecipes.get(recipe) != null) {
196+
CraftingRecipe mapRecipe = craftingRecipes.get(recipe).value();
197+
if (mapRecipe != null && mapRecipe.matches(craftingInventory, world)) {
198+
return Optional.of(recipe);
199+
}
190200
}
191201
}
192-
Optional<CraftingRecipe> recipe = manager.getFirstMatch(RecipeType.CRAFTING, craftingInventory, world);
202+
203+
Optional<RecipeEntry<CraftingRecipe>> recipe = manager.getFirstMatch(RecipeType.CRAFTING, craftingInventory, world);
193204
recipe.ifPresent(this::setLastRecipe);
194-
return recipe;
205+
206+
return recipe.map(RecipeEntry::value);
195207
}
196208

197209
private ItemStack craft() {

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"depends": {
2525
"fabricloader": "*",
2626
"fabric": "*",
27-
"minecraft": ">1.19.4",
27+
"minecraft": ">=1.20.2",
2828
"java": ">=17"
2929
}
3030
}

0 commit comments

Comments
 (0)