ashtonr12 Posted March 6, 2013 Posted March 6, 2013 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 Quote Use examples, i have aspergers. Examples make sense to me.
mnn Posted March 6, 2013 Posted March 6, 2013 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); Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
ashtonr12 Posted March 7, 2013 Author Posted March 7, 2013 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? Quote Use examples, i have aspergers. Examples make sense to me.
mnn Posted March 7, 2013 Posted March 7, 2013 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). Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
ashtonr12 Posted March 7, 2013 Author Posted March 7, 2013 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 Quote Use examples, i have aspergers. Examples make sense to me.
mnn Posted March 7, 2013 Posted March 7, 2013 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 . Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
ashtonr12 Posted March 7, 2013 Author Posted March 7, 2013 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 Quote Use examples, i have aspergers. Examples make sense to me.
ashtonr12 Posted March 7, 2013 Author Posted March 7, 2013 I couldnt get the code you gave me to work? Quote Use examples, i have aspergers. Examples make sense to me.
ashtonr12 Posted March 7, 2013 Author Posted March 7, 2013 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 Quote Use examples, i have aspergers. Examples make sense to me.
ashtonr12 Posted March 8, 2013 Author Posted March 8, 2013 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? Quote Use examples, i have aspergers. Examples make sense to me.
Recommended Posts
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.