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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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    7592

diesieben07

diesieben07    7592

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7592
  • 55029 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

    • poopoodice
      [1.16.4] How i can open a container by clicking on my mob

      By poopoodice · Posted 1 minute ago

      Well, since  public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity <--------) { return new MyModContainer(id,playerInventory, world,extraDataWriter); } you already have the player, why don't you just pass the player in? Also getEntityByID is using entityID not UUID, use ServerWorld#getEntityByUuid/getPlayerByUuid although it is not necessary because you've got the player already.  
    • MKR0902
      1.12.2 Forge Server Not starting with command arguements

      By MKR0902 · Posted 11 minutes ago

      trying to start the forge server with more memory using the command  java -Xmx1G -Xms1G -jar minecraftforge-universal-1.6.2-9.10.0.804.jar nogui but keep getting the error: launcher.lang.reflect.InvocationTargetException also happens if I use the megabyte version, so like 1024M.
    • Thorius
      I don't know how forge works

      By Thorius · Posted 11 minutes ago

      For the client you have to select the location of your minecraft installation, .minecraft
    • Thorius
      I don't know how forge works

      By Thorius · Posted 16 minutes ago

      The place where you installed the server with forge should have a folder named mods propably. Put your mods in there.
    • Mark74
      I don't know how forge works

      By Mark74 · Posted 38 minutes ago

      Hi! I started a Server with Forge, and now i want to install some mods in this server, but i don't know how to do it. In the forge installer i have the option to install client, but when i want to install it in a folder in Disk D, there is an error : "The directory is missing a launcher profile. Please run the minecraft launcher first." But i have the minecraft opened so idk what to do or how it works.
  • Topics

    • Klarks
      39
      [1.16.4] How i can open a container by clicking on my mob

      By Klarks
      Started Saturday at 09:56 PM

    • MKR0902
      0
      1.12.2 Forge Server Not starting with command arguements

      By MKR0902
      Started 11 minutes ago

    • Mark74
      2
      I don't know how forge works

      By Mark74
      Started 38 minutes ago

    • Amazinwave
      0
      Amazinwave

      By Amazinwave
      Started 38 minutes ago

    • EthanDev
      2
      Why does Forge installer 1.8.9 have Vape as an execution parent?

      By EthanDev
      Started 2 hours ago

  • Who's Online (See full list)

    • Thorius
    • vemerion
    • CookieLukas
    • Joshthehoneskid
    • adem
    • MKR0902
    • Nuparu00
    • Beethoven92
    • FlashHUN
    • Wintersky20
    • Amazinwave
    • Mark74
    • simpsii
  • 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