Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Basically my previous project/mod was using snapshots mappings, the current project I have uses mojangs mappings, for some reason it isn't working, Here are some examples below:

ย 

My current code (mojang mappings, which doesn't work):

    public static final RegistryObject<Item> DECLESE_SWORD = ITEMS.register("declese_sword",
            () -> new SwordItem(ModItemTier.DECLESE, 2, -2.4f,
                    new Item.Properties().tab(ModItemGroup.FRV_GROUP))
            {
                @Override
                public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker)
                {
                    if(!attacker.level.isClientSide())
                    {
                        target.addEffect(new EffectInstance(Effects.POISON, 100, 1));
                    }
                    return super.hurtEnemy(stack, target, attacker);
                }
            });

And the old working code (Snapshot mappings):

    public static final RegistryObject<Item> CORRUPT_SWORD = ITEMS.register("corrupt_sword",
            () -> new SwordItem(ModItemTier.CORRUPT, 90, -2f,
                    new Item.Properties().isImmuneToFire().group(ModItemGroup.FRV_GROUP))
            {
                @Override
                public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
                    if(!attacker.world.isRemote()) {
                        target.addPotionEffect(new EffectInstance(Effects.WITHER, 1000, 2));
                        target.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 1000, 2));
                        target.addPotionEffect(new EffectInstance(Effects.POISON, 1000, 2));
                    }
                    return super.hitEntity(stack, target, attacker);
                }
            });

What could be the cause of it?

12 minutes ago, Feroov said:

My current code (mojang mappings, which doesn't work):

whats the error, since the code looks okay

  • Author
6 minutes ago, Luis_ST said:

whats the error, since the code looks okay

There are no errors, the game runs fine, when I hit any entity it just doesn't apply the effect

  • Author
9 hours ago, Luis_ST said:

is the hurtEnemy method called and how did you test if the target gets/doesn't get the effect?

Yes it is being called, I use IntelliJ, its called from the ItemStack class, and I tested directly just running the game hitting few entities basically

  • Author

Ok I actually found out it actually works with other effects, but poison doesn't seem to be working, interesting

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.