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 8c018b1..01b0caa 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.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 +version=3.5.0+gnifty3 # External Dependencies -magna_version=1.8.0-1.19.2 -mod_menu_version=3.0.1 +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.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.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 e7c75bd..adb0446 100644 --- a/src/main/java/draylar/vh/VanillaHammers.java +++ b/src/main/java/draylar/vh/VanillaHammers.java @@ -1,30 +1,40 @@ 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; 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.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; -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")))); + private static final RegistryKey ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, id("group")); @Override public void onInitialize() { MagnaOptionals.optInForCurse(); StaticContent.load(id("hammers"), HammerData.class); + 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() + ); registerCallbackHandlers(); } diff --git a/src/main/java/draylar/vh/data/HammerData.java b/src/main/java/draylar/vh/data/HammerData.java index 2543a25..f3c6a3b 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,8 +28,8 @@ public class HammerData implements ContentData { private final boolean isExtra; private final int burnTime; private final boolean hasExtraKnockback; - private final String group; - private transient ItemGroup cachedGroup; + + public static final Set 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, String group) { this.id = id; @@ -45,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 @@ -54,7 +54,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,22 +78,11 @@ 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); - 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)) { - cachedGroup = itemGroup; - break; - } - } + // add hammer to item group + ENTRY_SET.add(hammerItem.getDefaultStack()); } - - return cachedGroup; } public boolean hasExtraKnockback() { diff --git a/src/main/java/draylar/vh/item/ExtendedHammerItem.java b/src/main/java/draylar/vh/item/ExtendedHammerItem.java index d1978f6..617c57a 100644 --- a/src/main/java/draylar/vh/item/ExtendedHammerItem.java +++ b/src/main/java/draylar/vh/item/ExtendedHammerItem.java @@ -1,11 +1,10 @@ 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.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 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/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" }, 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": [