From ec13ced2e9c3a76b8dda9fb30a5730ed1c0901ef Mon Sep 17 00:00:00 2001 From: gniftygnome <minecraft@gnifty.net> Date: Sat, 6 May 2023 13:17:01 -0700 Subject: [PATCH 1/3] Update to 1.19.4. Requires updated Magna in separate PR. --- gradle.properties | 18 ++++++------ src/main/java/draylar/vh/VanillaHammers.java | 12 ++++++-- src/main/java/draylar/vh/data/HammerData.java | 28 +++++++++++-------- .../draylar/vh/item/ExtendedHammerItem.java | 10 ++----- .../vh/material/CustomToolMaterial.java | 16 +++++------ .../draylar/vh/mixin/ItemGroupAccessor.java | 11 -------- src/main/resources/vanillahammers.mixin.json | 1 - 7 files changed, 45 insertions(+), 51 deletions(-) delete mode 100644 src/main/java/draylar/vh/mixin/ItemGroupAccessor.java diff --git a/gradle.properties b/gradle.properties index 8c018b1..e2c6ed0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,20 +2,20 @@ org.gradle.jvmargs=-Xmx1G # Minecraft Properties -minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.22 -loader_version=0.14.9 -fabric_version=0.63.0+1.19.2 +minecraft_version=1.19.4 +yarn_mappings=1.19.4+build.2 +loader_version=0.14.19 +fabric_version=0.80.0+1.19.4 # Metadata modid=vanilla-hammers -version=3.5.0 +version=3.5.0+gnifty1 # External Dependencies magna_version=1.8.0-1.19.2 -mod_menu_version=3.0.1 +mod_menu_version=6.2.2 libcd_version=3.0.3+1.16.3 static_content_version=1.0.2 -maybe_data_version=1.3.0-1.18.2 -omega_config_version=1.2.1-1.18.1 -cloth_config_version=5.0.38 \ No newline at end of file +maybe_data_version=1.3.2-1.19 +omega_config_version=1.2.3-1.18.1 +cloth_config_version=10.0.96 \ No newline at end of file diff --git a/src/main/java/draylar/vh/VanillaHammers.java b/src/main/java/draylar/vh/VanillaHammers.java index e7c75bd..ef03c9f 100644 --- a/src/main/java/draylar/vh/VanillaHammers.java +++ b/src/main/java/draylar/vh/VanillaHammers.java @@ -7,24 +7,30 @@ import draylar.vh.data.HammerData; import draylar.vh.item.ExtendedHammerItem; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; import net.fabricmc.fabric.api.event.player.AttackEntityCallback; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; +import net.minecraft.registry.Registries; +import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; public class VanillaHammers implements ModInitializer { public static String MODID = "vanilla-hammers"; public static VanillaHammersConfig CONFIG = OmegaConfig.register(VanillaHammersConfig.class); - public static final ItemGroup GROUP = FabricItemGroupBuilder.build(id("group"), () -> new ItemStack(Registry.ITEM.get(id("diamond_hammer")))); + public static ItemGroup GROUP; @Override public void onInitialize() { MagnaOptionals.optInForCurse(); StaticContent.load(id("hammers"), HammerData.class); + GROUP = FabricItemGroup.builder(id("group")) + .displayName(Text.literal("Vanilla Hammers")) + .icon(() -> new ItemStack(Registries.ITEM.get(id("diamond_hammer")))) + .entries((context, entries) -> entries.addAll(HammerData.ENTRY_SET)) + .build(); registerCallbackHandlers(); } diff --git a/src/main/java/draylar/vh/data/HammerData.java b/src/main/java/draylar/vh/data/HammerData.java index 2543a25..e6d6fad 100644 --- a/src/main/java/draylar/vh/data/HammerData.java +++ b/src/main/java/draylar/vh/data/HammerData.java @@ -4,12 +4,13 @@ import draylar.vh.VanillaHammers; import draylar.vh.item.ExtendedHammerItem; import draylar.vh.material.CustomToolMaterial; -import draylar.vh.mixin.ItemGroupAccessor; import net.fabricmc.fabric.api.registry.FuelRegistry; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; +import net.minecraft.item.*; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; + +import java.util.Set; public class HammerData implements ContentData { @@ -27,10 +28,12 @@ public class HammerData implements ContentData { private final boolean isExtra; private final int burnTime; private final boolean hasExtraKnockback; - private final String group; + private final Identifier group; private transient ItemGroup cachedGroup; - public HammerData(String id, int miningLevel, int durability, float blockBreakSpeed, float attackDamage, float attackSpeed, int enchantability, Identifier repairIngredient, boolean isFireImmune, boolean smelts, int breakRadius, boolean isExtra, int burnTime, boolean hasExtraKnockback, String group) { + public static final Set<ItemStack> ENTRY_SET = ItemStackSet.create(); + + public HammerData(String id, int miningLevel, int durability, float blockBreakSpeed, float attackDamage, float attackSpeed, int enchantability, Identifier repairIngredient, boolean isFireImmune, boolean smelts, int breakRadius, boolean isExtra, int burnTime, boolean hasExtraKnockback, Identifier group) { this.id = id; this.miningLevel = miningLevel; this.durability = durability; @@ -54,7 +57,7 @@ public void register(Identifier identifier) { if (!isExtra() || isExtra() && VanillaHammers.CONFIG.enableExtraMaterials) { // setup settings - Item.Settings settings = new Item.Settings().group(VanillaHammers.GROUP); + Item.Settings settings = new Item.Settings(); if (isFireImmune()) { settings.fireproof(); } @@ -78,15 +81,18 @@ public void register(Identifier identifier) { // add hammer to tag String path = getId() + "_hammer"; Identifier registryID = path.contains(":") ? new Identifier(path) : VanillaHammers.id(path); - Registry.register(Registry.ITEM, registryID, hammerItem); + Registry.register(Registries.ITEM, registryID, hammerItem); + + // add hammer to item group + ENTRY_SET.add(hammerItem.getDefaultStack()); } } public ItemGroup getGroup() { // attempt to get group from string - if (cachedGroup == null && (group != null && !group.isEmpty())) { - for (ItemGroup itemGroup : ItemGroup.GROUPS) { - if (((ItemGroupAccessor) itemGroup).getId().equals(group)) { + if (cachedGroup == null && group != null) { + for (ItemGroup itemGroup : ItemGroups.getGroups()) { + if (itemGroup.getId().equals(group)) { cachedGroup = itemGroup; break; } diff --git a/src/main/java/draylar/vh/item/ExtendedHammerItem.java b/src/main/java/draylar/vh/item/ExtendedHammerItem.java index d1978f6..d0fb07a 100644 --- a/src/main/java/draylar/vh/item/ExtendedHammerItem.java +++ b/src/main/java/draylar/vh/item/ExtendedHammerItem.java @@ -5,7 +5,6 @@ import draylar.magna.item.HammerItem; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.SimpleInventory; -import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.ToolMaterial; import net.minecraft.recipe.RecipeType; @@ -30,7 +29,7 @@ public HammerData getData() { @Override public BlockProcessor getProcessor(World world, PlayerEntity player, BlockPos pos, ItemStack heldStack) { - if(data.canSmelt()) { + if (data.canSmelt()) { return (tool, input) -> { Optional<SmeltingRecipe> cooked = world.getRecipeManager().getFirstMatch( RecipeType.SMELTING, @@ -39,7 +38,7 @@ public BlockProcessor getProcessor(World world, PlayerEntity player, BlockPos po ); if (cooked.isPresent()) { - return cooked.get().getOutput().copy(); + return cooked.get().getOutput(world.getRegistryManager()).copy(); } return input; @@ -48,9 +47,4 @@ public BlockProcessor getProcessor(World world, PlayerEntity player, BlockPos po return super.getProcessor(world, player, pos, heldStack); } } - - @Override - public boolean isIn(ItemGroup group) { - return super.isIn(group) || group.equals(data.getGroup()); - } } diff --git a/src/main/java/draylar/vh/material/CustomToolMaterial.java b/src/main/java/draylar/vh/material/CustomToolMaterial.java index f56b88e..0685bac 100644 --- a/src/main/java/draylar/vh/material/CustomToolMaterial.java +++ b/src/main/java/draylar/vh/material/CustomToolMaterial.java @@ -4,17 +4,17 @@ import draylar.vh.data.HammerData; import net.minecraft.item.ToolMaterial; import net.minecraft.recipe.Ingredient; +import net.minecraft.registry.Registries; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; public class CustomToolMaterial implements ToolMaterial { - private int enchantability; - private float miningSpeedMultiplier; - private int durability; - private float attackDamage; - private int miningLevel; - private Ingredient ingredient; + private final int enchantability; + private final float miningSpeedMultiplier; + private final int durability; + private final float attackDamage; + private final int miningLevel; + private final Ingredient ingredient; public CustomToolMaterial(int enchantability, float miningSpeedMultiplier, int durability, float attackDamage, int miningLevel, Ingredient ingredient) { this.enchantability = enchantability; @@ -32,7 +32,7 @@ public static CustomToolMaterial from(HammerData data) { (data.getDurability() == 0 ? 500 : data.getDurability()) * VanillaHammers.CONFIG.durabilityModifier, data.getAttackDamage() == 0 ? 4 : data.getAttackDamage(), data.getMiningLevel(), - Ingredient.ofItems(Registry.ITEM.get(data.getRepairIngredient() == null ? new Identifier("iron_ingot") : data.getRepairIngredient())) + Ingredient.ofItems(Registries.ITEM.get(data.getRepairIngredient() == null ? new Identifier("iron_ingot") : data.getRepairIngredient())) ); } diff --git a/src/main/java/draylar/vh/mixin/ItemGroupAccessor.java b/src/main/java/draylar/vh/mixin/ItemGroupAccessor.java deleted file mode 100644 index 21a4205..0000000 --- a/src/main/java/draylar/vh/mixin/ItemGroupAccessor.java +++ /dev/null @@ -1,11 +0,0 @@ -package draylar.vh.mixin; - -import net.minecraft.item.ItemGroup; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ItemGroup.class) -public interface ItemGroupAccessor { - @Accessor - String getId(); -} diff --git a/src/main/resources/vanillahammers.mixin.json b/src/main/resources/vanillahammers.mixin.json index 5bfc16f..4506645 100644 --- a/src/main/resources/vanillahammers.mixin.json +++ b/src/main/resources/vanillahammers.mixin.json @@ -4,7 +4,6 @@ "compatibilityLevel": "JAVA_8", "mixins": [ "HammerKnockbackMixin", - "ItemGroupAccessor", "SilkTouchEnchantmentMixin" ], "client": [ From 05ac72fb9653e4fec94c44a921c2e32565e4ca6f Mon Sep 17 00:00:00 2001 From: gniftygnome <minecraft@gnifty.net> Date: Mon, 20 Nov 2023 23:33:56 -0800 Subject: [PATCH 2/3] Update to 1.20.1. --- build.gradle | 19 +++++++++---------- gradle.properties | 18 +++++++++--------- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/java/draylar/vh/VanillaHammers.java | 14 +++++++++----- src/main/java/draylar/vh/data/HammerData.java | 19 +------------------ .../draylar/vh/item/ExtendedHammerItem.java | 4 ++-- 6 files changed, 31 insertions(+), 45 deletions(-) diff --git a/build.gradle b/build.gradle index 1d06347..0968a1d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' + id 'fabric-loom' version '1.2-SNAPSHOT' id 'maven-publish' } @@ -12,9 +12,9 @@ version = project.version + "-" + project.minecraft_version repositories { maven { url "https://maven.fabricmc.net/" } maven { url 'https://jitpack.io' } - maven { url "https://server.bbkr.space/artifactory/libs-release" } maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.terraformersmc.com/"} + maven { url "https://maven.draylar.dev/releases" } } dependencies { @@ -27,26 +27,25 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" // Magna (https://github.com/Draylar/magna) for hammers - include "com.github.Draylar:magna:${project.magna_version}" - modImplementation ("com.github.Draylar:magna:${project.magna_version}") { + include "dev.draylar:magna:${project.magna_version}" + modImplementation ("dev.draylar:magna:${project.magna_version}") { exclude group: "net.fabricmc" exclude group: "com.jamieswhiteshirt" exclude group: "me.shedaniel.cloth" - } - - modImplementation ("io.github.cottonmc:StaticData:1.1.2") { - exclude group: "net.fabricmc.fabric-api" + exclude module: "omega-config-base" } // Static Content (https://github.com/Draylar/static-content) for hammer loading and compat include "com.github.Draylar:static-content:${project.static_content_version}" modImplementation ("com.github.Draylar:static-content:${project.static_content_version}") { + exclude group: "com.github.Draylar" exclude group: "net.fabricmc" + exclude module: "omega-config-base" } // Config solutions + Cloth Config for Magna - modImplementation "com.github.Draylar.omega-config:omega-config-base:${project.omega_config_version}" - include "com.github.Draylar.omega-config:omega-config-base:${project.omega_config_version}" + modImplementation "dev.draylar.omega-config:omega-config-base:${project.omega_config_version}" + include "dev.draylar.omega-config:omega-config-base:${project.omega_config_version}" modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") { exclude(group: "net.fabricmc.fabric-api") } diff --git a/gradle.properties b/gradle.properties index e2c6ed0..11f6611 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,20 +2,20 @@ org.gradle.jvmargs=-Xmx1G # Minecraft Properties -minecraft_version=1.19.4 -yarn_mappings=1.19.4+build.2 -loader_version=0.14.19 -fabric_version=0.80.0+1.19.4 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.10 +loader_version=0.14.24 +fabric_version=0.90.7+1.20.1 # Metadata modid=vanilla-hammers -version=3.5.0+gnifty1 +version=3.5.0+gnifty2 # External Dependencies -magna_version=1.8.0-1.19.2 -mod_menu_version=6.2.2 +magna_version=1.10.0+1.20.1 +mod_menu_version=7.2.2 libcd_version=3.0.3+1.16.3 static_content_version=1.0.2 maybe_data_version=1.3.2-1.19 -omega_config_version=1.2.3-1.18.1 -cloth_config_version=10.0.96 \ No newline at end of file +omega_config_version=1.4.0+1.20.1 +cloth_config_version=11.1.106 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a2..84a0b92 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/draylar/vh/VanillaHammers.java b/src/main/java/draylar/vh/VanillaHammers.java index ef03c9f..adb0446 100644 --- a/src/main/java/draylar/vh/VanillaHammers.java +++ b/src/main/java/draylar/vh/VanillaHammers.java @@ -1,6 +1,6 @@ package draylar.vh; -import draylar.magna.api.optional.MagnaOptionals; +import dev.draylar.magna.api.optional.MagnaOptionals; import draylar.omegaconfig.OmegaConfig; import draylar.staticcontent.StaticContent; import draylar.vh.config.VanillaHammersConfig; @@ -12,6 +12,9 @@ import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; @@ -20,17 +23,18 @@ public class VanillaHammers implements ModInitializer { public static String MODID = "vanilla-hammers"; public static VanillaHammersConfig CONFIG = OmegaConfig.register(VanillaHammersConfig.class); - public static ItemGroup GROUP; + private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, id("group")); @Override public void onInitialize() { MagnaOptionals.optInForCurse(); StaticContent.load(id("hammers"), HammerData.class); - GROUP = FabricItemGroup.builder(id("group")) - .displayName(Text.literal("Vanilla Hammers")) + Registry.register(Registries.ITEM_GROUP, ITEM_GROUP, FabricItemGroup.builder() + .displayName(Text.translatable("itemGroup.vanilla-hammers.group")) .icon(() -> new ItemStack(Registries.ITEM.get(id("diamond_hammer")))) .entries((context, entries) -> entries.addAll(HammerData.ENTRY_SET)) - .build(); + .build() + ); registerCallbackHandlers(); } diff --git a/src/main/java/draylar/vh/data/HammerData.java b/src/main/java/draylar/vh/data/HammerData.java index e6d6fad..f3c6a3b 100644 --- a/src/main/java/draylar/vh/data/HammerData.java +++ b/src/main/java/draylar/vh/data/HammerData.java @@ -28,12 +28,10 @@ public class HammerData implements ContentData { private final boolean isExtra; private final int burnTime; private final boolean hasExtraKnockback; - private final Identifier group; - private transient ItemGroup cachedGroup; public static final Set<ItemStack> ENTRY_SET = ItemStackSet.create(); - public HammerData(String id, int miningLevel, int durability, float blockBreakSpeed, float attackDamage, float attackSpeed, int enchantability, Identifier repairIngredient, boolean isFireImmune, boolean smelts, int breakRadius, boolean isExtra, int burnTime, boolean hasExtraKnockback, Identifier group) { + public HammerData(String id, int miningLevel, int durability, float blockBreakSpeed, float attackDamage, float attackSpeed, int enchantability, Identifier repairIngredient, boolean isFireImmune, boolean smelts, int breakRadius, boolean isExtra, int burnTime, boolean hasExtraKnockback, String group) { this.id = id; this.miningLevel = miningLevel; this.durability = durability; @@ -48,7 +46,6 @@ public HammerData(String id, int miningLevel, int durability, float blockBreakSp this.isExtra = isExtra; this.burnTime = burnTime; this.hasExtraKnockback = hasExtraKnockback; - this.group = group; } @Override @@ -88,20 +85,6 @@ public void register(Identifier identifier) { } } - public ItemGroup getGroup() { - // attempt to get group from string - if (cachedGroup == null && group != null) { - for (ItemGroup itemGroup : ItemGroups.getGroups()) { - if (itemGroup.getId().equals(group)) { - cachedGroup = itemGroup; - break; - } - } - } - - return cachedGroup; - } - public boolean hasExtraKnockback() { return hasExtraKnockback; } diff --git a/src/main/java/draylar/vh/item/ExtendedHammerItem.java b/src/main/java/draylar/vh/item/ExtendedHammerItem.java index d0fb07a..617c57a 100644 --- a/src/main/java/draylar/vh/item/ExtendedHammerItem.java +++ b/src/main/java/draylar/vh/item/ExtendedHammerItem.java @@ -1,8 +1,8 @@ package draylar.vh.item; +import dev.draylar.magna.api.BlockProcessor; +import dev.draylar.magna.item.HammerItem; import draylar.vh.data.HammerData; -import draylar.magna.api.BlockProcessor; -import draylar.magna.item.HammerItem; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.SimpleInventory; import net.minecraft.item.ItemStack; From fa2c8101478e9b34317775683da1e974f98d7453 Mon Sep 17 00:00:00 2001 From: gniftygnome <minecraft@gnifty.net> Date: Thu, 14 Dec 2023 12:16:40 -0800 Subject: [PATCH 3/3] Update Netherite Hammer smithing recipe for the modern era. --- gradle.properties | 2 +- .../vanilla-hammers/recipes/netherite_hammer_smithing.json | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 11f6611..01b0caa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_version=0.90.7+1.20.1 # Metadata modid=vanilla-hammers -version=3.5.0+gnifty2 +version=3.5.0+gnifty3 # External Dependencies magna_version=1.10.0+1.20.1 diff --git a/src/main/resources/data/vanilla-hammers/recipes/netherite_hammer_smithing.json b/src/main/resources/data/vanilla-hammers/recipes/netherite_hammer_smithing.json index e729290..4d0d95b 100644 --- a/src/main/resources/data/vanilla-hammers/recipes/netherite_hammer_smithing.json +++ b/src/main/resources/data/vanilla-hammers/recipes/netherite_hammer_smithing.json @@ -1,5 +1,8 @@ { - "type": "minecraft:smithing", + "type": "minecraft:smithing_transform", + "template": { + "item": "minecraft:netherite_upgrade_smithing_template" + }, "base": { "item": "vanilla-hammers:diamond_hammer" },