Jump to content

Recommended Posts

Posted

I was wondering how i would go about giving a tool and enchantment without having to enchant it, ie when you craft it it comes with an enchantment, sort of like how you can make armour give a potion effect when worn in the armour slots?

some example code would be usefull or any constuctive help at all :)

Use examples, i have aspergers.

Examples make sense to me.

Posted

I somewhere read that when creating a recipe you can pass it an enchanted item as a result and it should work.

 

EDIT: Yep, it works. Sample code:

        ItemStack hoe = new ItemStack(hoeJaffarrol);
        hoe.addEnchantment(Enchantment.fortune, 2);    // <<
        hoe.addEnchantment(Enchantment.unbreaking, 2); // <<
        GameRegistry.addRecipe(hoe, "JJL", "LS ", " S ", 'J', jaffarrol, 'S', Item.stick, 'L', limsew);

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Posted

thankyou :) i was wondering if it was also possible to make it so that when i am using "ModdedPickaxe" i have potio effect miningspeed increase potion effect?

Use examples, i have aspergers.

Examples make sense to me.

Posted

I think it could be done via onUpdate (called every tick when in players inventory) or onBlockDestroyed (less cpu intensive, but not exactly thing you wanted).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Posted

Yes, i was thinking about this, probably onServerTick Class but i am not sure of how the method would work? if you dont know dont worry i will investigate it later :)

Use examples, i have aspergers.

Examples make sense to me.

Posted

yea, using tick handler would be possible. you'd probably use the player tick on a server side, I recommend using scheduled tick handler (to not stress a server too much, checking every tick for every player seems a bit much, every 10 or 20 ticks should be fine).

 

brief howto of tickhandler: implement IScheduledTickHandler, ticks() should return player. on tickEnd you'll do the testing of a player for your tool and applying potion effect to the player. the TickType is well commented. when you have done tick handler you just register it in your load method (via TickRegistry.registerTickHandler) and you're done :).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Posted

Idofindthat example code helps me the most becasue then i can be 100% sure that i amcorrect in it and i can refer to it later on if i have problems :) i have already got a method for adding potion effects to armours i will post itlater for you to scan over but i am wondering if it is a similar method with just tools instead of armours. On another note the way i have handled armours is so that if you are wearing helmet or plate or legs or boots you get potion slowness (for example) i was wondering if there was a way for me to have it so that it is when you are wearing helmet and plate and boots and legs.

thankyou :)

Use examples, i have aspergers.

Examples make sense to me.

Posted

Can someone show me an example of how i can do this? i do not understand the one that the first person tried to tell me :/

Use examples, i have aspergers.

Examples make sense to me.

Posted

i tried to add this but it didnt work?

i tired to put his code in and i finally got it to work without an error but it simply didnt do anything?

Use examples, i have aspergers.

Examples make sense to me.

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...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

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