Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10] Adding a potion effect to armor
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
untamemadman

[1.7.10] Adding a potion effect to armor

By untamemadman, August 25, 2014 in Modder Support

  • Reply to this topic
  • Start new topic
  • Prev
  • 1
  • 2
  • Next
  • Page 1 of 2  

Recommended Posts

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 25, 2014

How do I add a potion effect to armor in 1.7.10

I found a tutorial for 1.7.2 that said I just have to add:

 

    @Override

    public void onArmorTick(World world, EntityPlayer player, ItemStack armor)

    {

        player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 500, 1, true));

    }

 

to my Armor code but it doesn't give the player Night vision when he equip it. any help?

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 25, 2014

That should work, but I am not sure why you are specifying a duration of 500 ticks.

Also you should probably only add the effect on the server side not the client.

  • Quote

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 25, 2014

Would it be better to only have it for maybe 10 ticks and it will refresh?

Also just checking, I do make it server side using    @SideOnly(Server)?

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 25, 2014

onArmorTick is called every tick so even a duration of just 2 ticks would be enough.

And you should read this about @SideOnly: http://www.minecraftforge.net/forum/index.php/topic,22764.0.html

  • Quote

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 25, 2014

I made it server side and changed the tick time but it still doesn't work.

here is my code: http://goo.gl/XNE7vO

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 25, 2014

You either did not read or did not understand the tutorial I posted. The title already tells you your mistake.

  • Quote

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

You either did not read or did not understand the tutorial I posted. The title already tells you your mistake.

 

I understand the difference between Server and Client, but I don't understand what you mean by the alternatives

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 26, 2014

Read the title of the tutorial. Do not use @SideOnly. It does not do what you think it does. Read the tutorial to learn what it actually does.

  • Quote

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

Ok, say I don't use @SideOnly. Why won't my code work still

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 26, 2014

Because you are adding it on the client side as well. Only add the potion effect on the server.

  • Quote

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

And how would I do that without using "@SideOnly", because your tutorial isn't clear on that

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

daafganggdg    3

daafganggdg

daafganggdg    3

  • Creeper Killer
  • daafganggdg
  • Members
  • 3
  • 141 posts
Posted August 26, 2014

u can simply check with world.isRemote :)

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 26, 2014

And how would I do that without using "@SideOnly", because your tutorial isn't clear on that

Yes, it is clear. There's a section about what to use instead.
  • Quote

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

And how would I do that without using "@SideOnly", because your tutorial isn't clear on that

Yes, it is clear. There's a section about what to use instead.

 

Well I was confused by it.

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

I have this now:

 

    @Override

    public void onArmorTick(World world, EntityPlayer player, ItemStack armor)

    {

        if(world.isRemote == true)

        {

            player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 2, 1, true));

        }

    }

 

Can you tell me if that is done correctly?

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 26, 2014

You didn't understand the meaning of .isRemote. If it's false, you are on the server. If it's true, you are on the client.

Also doing if (x == true) is redundant. if (x) is the same.

  • Quote

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

So how should I do it?

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 26, 2014

Check for the server, not the client.

  • Quote

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

Check for the server, not the client.

 

So "if(world.isRemote = false)"

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

Eternaldoom    110

Eternaldoom

Eternaldoom    110

  • Dragon Slayer
  • Eternaldoom
  • Forge Modder
  • 110
  • 592 posts
Posted August 26, 2014

if(!world.isRemote)

  • Quote

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

if(!world.isRemote)

 

My code is:

 

    @Override

    public void onArmorTick(World world, EntityPlayer player, ItemStack armor)

    {

        if(!world.isRemote)

        {

            player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 2, 1, true));

        }

    }

 

But the player still doesn't get night vision

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 26, 2014
So "if(world.isRemote = false)"

*facedesk*

Please, for the love of god, learn basic java before modding. Thank you.

 

Add a breakpoint in your method and check if it's actually being called.

  • Quote

Share this post


Link to post
Share on other sites

Eternaldoom    110

Eternaldoom

Eternaldoom    110

  • Dragon Slayer
  • Eternaldoom
  • Forge Modder
  • 110
  • 592 posts
Posted August 26, 2014

I use a PlayerTickEvent for armor bonuses. Maybe try that?

  • Quote

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Share this post


Link to post
Share on other sites

untamemadman    0

untamemadman

untamemadman    0

  • Tree Puncher
  • untamemadman
  • Forge Modder
  • 0
  • 30 posts
Posted August 26, 2014

Can someone just give me a chunk of code that will give the user of a peace of armor Night Vision

  • Quote

width=468 height=60http://vps.untamemadman.pw/pics/ForumSignature.gif[/img]

Share this post


Link to post
Share on other sites

diesieben07    7609

diesieben07

diesieben07    7609

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7609
  • 55158 posts
Posted August 26, 2014

You already have the right code. The cause must be somewhere else. As I said, please use a breakpoint to determine if the method is actually getting called.

  • Quote

Share this post


Link to post
Share on other sites
  • Prev
  • 1
  • 2
  • Next
  • Page 1 of 2  

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • forgotendeath09
      why is 3 in the middle of 7

      By forgotendeath09 · Posted 19 minutes ago

      when you load up forge 1.12.2 the top is displayed as 0/7, once it gets to 3/7 the bar below is in the middle; this is very wrong please consider changing this it drives me crazy every time i launch a modded world.
    • F0RZera
      have an error when trying to connect to LAN server with mods

      By F0RZera · Posted 20 minutes ago

      Ok thanks
    • DeNub
      Cannot create a modded forge server for 1.16.4

      By DeNub · Posted 22 minutes ago

      Its working all well now. Thank you for the support and being patient with me.
    • BobbyLikesCake
      1.16.4 Modded not loading singleplayer worlds

      By BobbyLikesCake · Posted 53 minutes ago

      Ok, Thanks I did modify quark slightly but I hope if I delete all of them I can just edit them once again
    • diesieben07
      1.16.4 Modded not loading singleplayer worlds

      By diesieben07 · Posted 55 minutes ago

      If you didn't modify any of them then its fine, they will just regenerate.
  • Topics

    • forgotendeath09
      0
      why is 3 in the middle of 7

      By forgotendeath09
      Started 19 minutes ago

    • F0RZera
      10
      have an error when trying to connect to LAN server with mods

      By F0RZera
      Started 5 hours ago

    • DeNub
      27
      Cannot create a modded forge server for 1.16.4

      By DeNub
      Started 11 hours ago

    • BobbyLikesCake
      13
      1.16.4 Modded not loading singleplayer worlds

      By BobbyLikesCake
      Started 4 hours ago

    • Dr.Nickenstein
      3
      Method to get the current durability?

      By Dr.Nickenstein
      Started 11 hours ago

  • Who's Online (See full list)

    • Ecpgamez
    • Tetron27
    • UnknownVoice
    • brockmoen
    • Nitrix
    • gogohugo2013
    • forgotendeath09
    • LexManos
    • diesieben07
    • DeNub
    • Dez_Flame_Fox
    • F0RZera
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10] Adding a potion effect to armor
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community