Jump to content

[SOLVED]Cannot Support That Enchantment


Thanatos_0173

Recommended Posts

Hello.

I've created an enchantment, applied on Sword and wich give a poison effect to a entity when hitten with this sword.

In the code everything seems ok, but when I'm trying to put the enchantment on the Netherite sword, it says:

Netherite Sword cannot support that enchantment

Can someone help me to fix that problem ?

 

Here is the code:

 

EnchantmentInit Class:

 

public class EnchantementInit {
      public static final DeferredRegister<Enchantment> ENCHANTMENTS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS,
              main.MODID);

    public static final RegistryObject<Enchantment> POISON_ENCHANT = ENCHANTMENTS.register("poison_enchant",()-> new PoisonEnchant(
            Enchantment.Rarity.COMMON,EnchantmentCategory.WEAPON,EquipmentSlot.MAINHAND));

    public static void register(IEventBus eventBus){
        ENCHANTMENTS.register(eventBus);
    }

}

PoisonEnchant Class:

public class PoisonEnchant extends Enchantment {

    public PoisonEnchant(Rarity rarity, EnchantmentCategory type, EquipmentSlot... slots) {
          super(rarity, type, slots);
     }



    @Override
    public int getMaxLevel() {
        return 6;
    }

    @Override
    public int getMinLevel() {
          return 1;
       }

    @Override
    public boolean canApplyAtEnchantingTable(ItemStack p_canApplyAtEnchantingTable_1_) {
          return false;
      }

    @Override
    public boolean isCurse() {
        return false;
    }




    @Override
    public boolean isAllowedOnBooks() {
         return false;
      }




    @Override
    public void doPostAttack(LivingEntity entity, Entity target, int level) {
        if(target instanceof LivingEntity){
            ((LivingEntity) target).addEffect(new MobEffectInstance(MobEffects.POISON));

        }

      }

}

Main Class:

    public main() {
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);

        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
        EnchantementInit.register(bus);
    
        ModItems.ITEMS.register(bus);
        ModBlocks.BLOCKS.register(bus);



    }

Thanks for helping

Edited by Thanatos_0173
I solved the problem. Just put the enchantments class into the same package, and set PoisonEnchant on protected
Link to comment
Share on other sites

  • Thanatos_0173 changed the title to [SOLVED]Cannot Support That Enchantment
Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • A friend found this code, but I don't know where. It seems to be very outdated, maybe from 1.12? and so uses TextureManager$loadTexture and TextureManager$deleteTexture which both don't seem to exist anymore. It also uses Minecraft.getMinecraft().mcDataDir.getCanonicalPath() which I replaced with the resource location of my texture .getPath()? Not sure if thats entirely correct. String textureName = "entitytest.png"; File textureFile = null; try { textureFile = new File(Minecraft.getMinecraft().mcDataDir.getCanonicalPath(), textureName); } catch (Exception ex) { } if (textureFile != null && textureFile.exists()) { ResourceLocation MODEL_TEXTURE = Resources.OTHER_TESTMODEL_CUSTOM; TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); texturemanager.deleteTexture(MODEL_TEXTURE); Object object = new ThreadDownloadImageData(textureFile, null, MODEL_TEXTURE, new ImageBufferDownload()); texturemanager.loadTexture(MODEL_TEXTURE, (ITextureObject)object); return true; } else { return false; }   Then I've been trying to go through the source code of the reload resource packs from minecraft, to see if I can "cache" some data and simply reload some textures and swap them out, but I can't seem to figure out where exactly its "loading" the texture files and such. Minecraft$reloadResourcePacks(bool) seems to be mainly controlling the loading screen, and using this.resourcePackRepository.reload(); which is PackRepository$reload(), but that function seems to be using this absolute confusion of a line List<String> list = this.selected.stream().map(Pack::getId).collect(ImmutableList.toImmutableList()); and then this.discoverAvailable() and this.rebuildSelected. The rebuild selected seemed promising, but it seems to just be going through each pack and doing this to them? pack.getDefaultPosition().insert(list, pack, Functions.identity(), false); e.g. putting them into a list of packs and returning that into this.selected? Where do the textures actually get baked/loaded/whatever? Any info on how Minecraft reloads resource packs or how the texture manager works would be appreciated!
    • This might be a long shot , but do you remember how you fixed that?
    • Yeah, I'll start with the ones I added last night.  Wasn't crashing until today and wasn't crashing at all yesterday (+past few days since removing Cupboard), so deductive reasoning says it's likeliest to be one of the new ones.  A few horse armor mods and a corn-based add-on to Farmer's Delight, the latter which I hope to keep - I could do without the horse armor mods if necessary.  Let me try a few things and we'll see. 
    • Add crash-reports with sites like https://mclo.gs/ Add this mod: https://www.curseforge.com/minecraft/mc-mods/packet-fixer/files/5416165
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.