EveryBlu Posted July 26, 2023 Posted July 26, 2023 I'm trying to add a custom enchantment that is only compatible with a new type of tiered weapon I made. I am using 1.19.3, forge version 44.0.1. I tried using EnchantmentCategory#create(), but it doesn't work. Here is the enchantment class: package everyblu.extendedarmory.common.enchantments; import everyblu.extendedarmory.common.item.LongswordItem; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentCategory; import org.jetbrains.annotations.NotNull; public class ThrustingEnchantment extends Enchantment { static EnchantmentCategory LONGSWORD_TYPE = EnchantmentCategory.create("thrusting", item -> item instanceof LongswordItem); public ThrustingEnchantment() { super(Rarity.RARE, LONGSWORD_TYPE, new EquipmentSlot[]{EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND}); } @Override public int getMaxLevel() { return 3; } @Override public void doPostAttack(@NotNull LivingEntity attacker, @NotNull Entity target, int tier) { if (attacker.getLevel().isClientSide()) { ClientLevel level = ((ClientLevel) attacker.getLevel()); if (tier >= 1) level.addParticle(ParticleTypes.SONIC_BOOM, target.position().x,target.position().y, target.position().z, 0, 0, 0); //This part is not finished. } } } Here is my enchants init class: package everyblu.extendedarmory.common.register; import everyblu.extendedarmory.ExtendedArmory; import everyblu.extendedarmory.common.enchantments.CutlassLuckEnchantment; import everyblu.extendedarmory.common.enchantments.ThrustingEnchantment; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; public class ModEnchants { public static final DeferredRegister<Enchantment> ENCHANTMENTS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, ExtendedArmory.MODID); public static RegistryObject<Enchantment> Thrusting = ENCHANTMENTS.register("thrusting", ThrustingEnchantment::new); public static RegistryObject<Enchantment> CutlassLuck = ENCHANTMENTS.register("cutlassluck", CutlassLuckEnchantment::new); public static void register(IEventBus eventBus) { ENCHANTMENTS.register(eventBus); } } Quote
EveryBlu Posted August 27, 2023 Author Posted August 27, 2023 (edited) Nevermind I was stupid. "item" doesn't exist anywhere else. I was following a guide and didn't know what I was doing. Edited August 27, 2023 by EveryBlu Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.