From a473e128ad01fb8d289fcaab216c2e33ee76bdc7 Mon Sep 17 00:00:00 2001 From: TheidenHD Date: Tue, 11 Jun 2024 23:00:58 +0200 Subject: [PATCH] Fix ToolMaterial --- src/main/java/vazkii/psi/api/PsiAPI.java | 17 ++++-- .../api/material/PsimetalToolMaterial.java | 52 ------------------- 2 files changed, 14 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java diff --git a/src/main/java/vazkii/psi/api/PsiAPI.java b/src/main/java/vazkii/psi/api/PsiAPI.java index 93d58ff8..11de4e45 100644 --- a/src/main/java/vazkii/psi/api/PsiAPI.java +++ b/src/main/java/vazkii/psi/api/PsiAPI.java @@ -17,10 +17,16 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; +import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.Tiers; import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.common.ForgeTier; +import net.minecraftforge.common.TierSortingRegistry; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.CapabilityToken; @@ -35,14 +41,15 @@ import vazkii.psi.api.internal.DummyMethodHandler; import vazkii.psi.api.internal.IInternalMethodHandler; import vazkii.psi.api.material.PsimetalArmorMaterial; -import vazkii.psi.api.material.PsimetalToolMaterial; import vazkii.psi.api.spell.ISpellAcceptor; import vazkii.psi.api.spell.ISpellImmune; import vazkii.psi.api.spell.SpellPiece; import vazkii.psi.api.spell.detonator.IDetonationHandler; +import vazkii.psi.common.item.base.ModItems; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -80,8 +87,12 @@ public final class PsiAPI { private static final Map> mainPieceForGroup = new HashMap<>(); public static final PsimetalArmorMaterial PSIMETAL_ARMOR_MATERIAL = new PsimetalArmorMaterial("psimetal", 18, new int[] { 2, 5, 6, 2 }, - 12, SoundEvents.ARMOR_EQUIP_IRON, 0F, () -> Ingredient.of(Registry.ITEM.get(new ResourceLocation(MOD_ID, "psimetal"))), 0.0f); - public static final PsimetalToolMaterial PSIMETAL_TOOL_MATERIAL = new PsimetalToolMaterial(); + 12, SoundEvents.ARMOR_EQUIP_IRON, 0F, () -> Ingredient.of(ForgeRegistries.ITEMS.getValue(new ResourceLocation(MOD_ID, "psimetal"))), 0.0f); + public static final Tier PSIMETAL_TOOL_MATERIAL = TierSortingRegistry.registerTier( + new ForgeTier(3, 900, 7.8F, 2F, 12, BlockTags.NEEDS_DIAMOND_TOOL, () -> Ingredient.of(ModItems.psimetal)), + new ResourceLocation(MOD_ID, "psimetal_tier"), + List.of(Tiers.DIAMOND), List.of(Tiers.NETHERITE)); + /** * Registers a Spell Piece. diff --git a/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java b/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java deleted file mode 100644 index a7f4cf10..00000000 --- a/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This class is distributed as part of the Psi Mod. - * Get the Source Code in github: - * https://github.com/Vazkii/Psi - * - * Psi is Open Source and distributed under the - * Psi License: https://psi.vazkii.net/license.php - */ -package vazkii.psi.api.material; - -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.LazyLoadedValue; -import net.minecraft.world.item.Tier; -import net.minecraft.world.item.crafting.Ingredient; - -import vazkii.psi.api.PsiAPI; - -public class PsimetalToolMaterial implements Tier { - private static final LazyLoadedValue REPAIR_MATERIAL = new LazyLoadedValue<>( - () -> Ingredient.of(Registry.ITEM.get(new ResourceLocation(PsiAPI.MOD_ID, "psimetal")))); - - @Override - public int getUses() { - return 900; - } - - @Override - public float getSpeed() { - return 7.8F; - } - - @Override - public float getAttackDamageBonus() { - return 2F; - } - - @Override - public int getLevel() { - return 3; - } - - @Override - public int getEnchantmentValue() { - return 12; - } - - @Override - public Ingredient getRepairIngredient() { - return REPAIR_MATERIAL.get(); - } -}