From acbc5aca940d8f39cd34028f1d757c44d11e369b Mon Sep 17 00:00:00 2001 From: Crec0 <83436716+Crec0@users.noreply.github.com> Date: Sun, 18 Dec 2022 17:53:30 -0800 Subject: [PATCH 1/5] Update versions --- gradle.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 191a39e..1cee5a3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use or https://modmuss50.me/fabric.html - minecraft_version=1.19.1 - yarn_mappings=1.19.1+build.6 - loader_version=0.14.9 + minecraft_version=1.19.3 + yarn_mappings=1.19.3+build.3 + loader_version=0.14.11 # check available versions on maven for the given minecraft version you are using - carpet_core_version=1.4.83+v220727 + carpet_core_version=1.4.91+v221207 # Mod Properties - mod_version = 1.4.83 + mod_version = 1.4.91 maven_group = carpet-autocraftingtable archives_base_name = carpet-autocraftingtable From b29277726510179e0ee33fdec12a8059b12ff263 Mon Sep 17 00:00:00 2001 From: Crec0 <83436716+Crec0@users.noreply.github.com> Date: Sun, 18 Dec 2022 17:53:46 -0800 Subject: [PATCH 2/5] Add quiltflower and update loom --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 24221a2..d8db2dd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' + id 'fabric-loom' version '1.0-SNAPSHOT' + id 'io.github.juuxel.loom-quiltflower' version '1.8.0' id 'maven-publish' } From 69e65182fd2ce19a2f970224047af701e31b1802 Mon Sep 17 00:00:00 2001 From: Crec0 <83436716+Crec0@users.noreply.github.com> Date: Sun, 18 Dec 2022 17:59:42 -0800 Subject: [PATCH 3/5] Update build.gradle --- build.gradle | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/build.gradle b/build.gradle index d8db2dd..a0f994b 100644 --- a/build.gradle +++ b/build.gradle @@ -37,48 +37,40 @@ processResources { inputs.property "version", project.version filesMatching("fabric.mod.json") { - expand "version": project.mod_version + expand "version": project.version } } -// ensure that the encoding is set to UTF-8, no matter what the system default is -// this fixes some edge cases with special characters not displaying correctly -// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - +tasks.withType(JavaCompile).configureEach { it.options.release = 17 } -// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task -// if it is present. -// If you remove this task, sources will not be generated. -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = "sources" - from sourceSets.main.allSource +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() } jar { - from "LICENSE" + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}"} + } } // configure the maven publication publishing { publications { mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven - artifact(jar) { - builtBy remapJar - } - artifact(sourcesJar) { - builtBy remapSourcesJar - } + from components.java } } - // select the repositories you want to publish to + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // uncomment to publish to the local maven - // mavenLocal() + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. } } From fda58059e9ce5dd9dec87734b471e9d8424352a4 Mon Sep 17 00:00:00 2001 From: Crec0 <83436716+Crec0@users.noreply.github.com> Date: Sun, 18 Dec 2022 18:31:53 -0800 Subject: [PATCH 4/5] Update to 1.19.3 --- .../AutoCraftingTableContainer.java | 2 +- .../CraftingTableBlockEntity.java | 11 ++++++----- .../mixins/BootStrapMixin.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/carpet_autocraftingtable/AutoCraftingTableContainer.java b/src/main/java/carpet_autocraftingtable/AutoCraftingTableContainer.java index 8175039..00845c4 100644 --- a/src/main/java/carpet_autocraftingtable/AutoCraftingTableContainer.java +++ b/src/main/java/carpet_autocraftingtable/AutoCraftingTableContainer.java @@ -102,7 +102,7 @@ public void onContentChanged(Inventory inv) { } @Override - public ItemStack transferSlot(PlayerEntity player, int index) { + public ItemStack quickMove(PlayerEntity player, int index) { ItemStack remainderResultStack = ItemStack.EMPTY; Slot slot = this.slots.get(index); if (slot.hasStack()) { diff --git a/src/main/java/carpet_autocraftingtable/CraftingTableBlockEntity.java b/src/main/java/carpet_autocraftingtable/CraftingTableBlockEntity.java index 817dd42..980a808 100644 --- a/src/main/java/carpet_autocraftingtable/CraftingTableBlockEntity.java +++ b/src/main/java/carpet_autocraftingtable/CraftingTableBlockEntity.java @@ -19,13 +19,14 @@ import net.minecraft.recipe.RecipeMatcher; import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.RecipeUnlocker; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.screen.ScreenHandler; import net.minecraft.text.Text; import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.ItemScatterer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; -import net.minecraft.util.registry.Registry; import java.util.ArrayList; import java.util.List; @@ -35,9 +36,9 @@ public class CraftingTableBlockEntity extends LockableContainerBlockEntity implements SidedInventory, RecipeUnlocker, RecipeInputProvider { public static final BlockEntityType TYPE = Registry.register( - Registry.BLOCK_ENTITY_TYPE, - "carpet:crafting_table", - BlockEntityType.Builder.create(CraftingTableBlockEntity::new, Blocks.CRAFTING_TABLE).build(null) + Registries.BLOCK_ENTITY_TYPE, + "carpet:crafting_table", + BlockEntityType.Builder.create(CraftingTableBlockEntity::new, Blocks.CRAFTING_TABLE).build(null) ); private static final int[] OUTPUT_SLOTS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; private static final int[] INPUT_SLOTS = {1, 2, 3, 4, 5, 6, 7, 8, 9}; @@ -215,7 +216,7 @@ private ItemStack craft() { if (!remainingStack.isEmpty()) { if (current.isEmpty()) { inventory.set(i, remainingStack); - } else if (ItemStack.areItemsEqualIgnoreDamage(current, remainingStack) && ItemStack.areEqual(current, remainingStack)) { + } else if (ItemStack.canCombine(current, remainingStack)) { current.increment(remainingStack.getCount()); } else { ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), remainingStack); diff --git a/src/main/java/carpet_autocraftingtable/mixins/BootStrapMixin.java b/src/main/java/carpet_autocraftingtable/mixins/BootStrapMixin.java index 4f82208..777d220 100644 --- a/src/main/java/carpet_autocraftingtable/mixins/BootStrapMixin.java +++ b/src/main/java/carpet_autocraftingtable/mixins/BootStrapMixin.java @@ -13,7 +13,7 @@ public class BootStrapMixin { method="initialize", at=@At( value = "INVOKE", - target = "Lnet/minecraft/util/registry/Registry;freezeRegistries()V", + target = "Lnet/minecraft/registry/Registries;bootstrap()V", shift = At.Shift.BEFORE ) ) From adea427a7e56dc04b0b86557aa6f2ee78f7a864d Mon Sep 17 00:00:00 2001 From: Crec0 <83436716+Crec0@users.noreply.github.com> Date: Sun, 18 Dec 2022 18:32:39 -0800 Subject: [PATCH 5/5] Update to new settings api --- .../AutoCraftingTable.java | 24 +++++++++++++++++++ .../AutoCraftingTableSettings.java | 7 +++--- .../carpet-autocraftingtable/lang/en_us.json | 3 +++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/assets/carpet-autocraftingtable/lang/en_us.json diff --git a/src/main/java/carpet_autocraftingtable/AutoCraftingTable.java b/src/main/java/carpet_autocraftingtable/AutoCraftingTable.java index 62581ad..1277436 100644 --- a/src/main/java/carpet_autocraftingtable/AutoCraftingTable.java +++ b/src/main/java/carpet_autocraftingtable/AutoCraftingTable.java @@ -2,6 +2,15 @@ import carpet.CarpetExtension; import carpet.CarpetServer; +import com.google.common.reflect.TypeToken; +import com.google.gson.GsonBuilder; +import org.apache.commons.io.IOUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Map; public class AutoCraftingTable implements CarpetExtension { @@ -15,4 +24,19 @@ public void onGameStarted() { // let's /carpet handle our few simple settings CarpetServer.settingsManager.parseSettingsClass(AutoCraftingTableSettings.class); } + + @Override + public Map canHasTranslations(String lang) { + InputStream langFile = AutoCraftingTable.class.getClassLoader().getResourceAsStream("assets/carpet-autocraftingtable/lang/%s.json".formatted(lang)); + if (langFile == null) { + return Collections.emptyMap(); + } + String jsonData; + try { + jsonData = IOUtils.toString(langFile, StandardCharsets.UTF_8); + } catch (IOException e) { + return Collections.emptyMap(); + } + return new GsonBuilder().create().fromJson(jsonData, new TypeToken>() {}.getType()); + } } diff --git a/src/main/java/carpet_autocraftingtable/AutoCraftingTableSettings.java b/src/main/java/carpet_autocraftingtable/AutoCraftingTableSettings.java index ea78653..1f1ca75 100644 --- a/src/main/java/carpet_autocraftingtable/AutoCraftingTableSettings.java +++ b/src/main/java/carpet_autocraftingtable/AutoCraftingTableSettings.java @@ -1,15 +1,14 @@ package carpet_autocraftingtable; -import carpet.settings.Rule; +import carpet.api.settings.Rule; -import static carpet.settings.RuleCategory.CREATIVE; +import static carpet.api.settings.RuleCategory.CREATIVE; /** * Here is your example Settings class you can plug to use carpetmod /carpet settings command */ public class AutoCraftingTableSettings { - @Rule(desc = "Auto-crafting table", category = {CREATIVE, "extras"}) + @Rule(categories = {CREATIVE, "extras"}) public static boolean autoCraftingTable = false; - } diff --git a/src/main/resources/assets/carpet-autocraftingtable/lang/en_us.json b/src/main/resources/assets/carpet-autocraftingtable/lang/en_us.json new file mode 100644 index 0000000..f69c458 --- /dev/null +++ b/src/main/resources/assets/carpet-autocraftingtable/lang/en_us.json @@ -0,0 +1,3 @@ +{ + "carpet.rule.autoCraftingTable.desc": "Converts the vanilla crafting tables into carpet's auto-crafting table" +}