Posted June 25, 20187 yr As the title says, I am trying to give potion effects to each armour set when the player is wearing the full set, If anyone can help me, just tell me what parts of the code I need to send. I know it is inconvenient but I do not have a lot of experience with java so I may not be able to follow if you start using terms I do not understand. Edited June 25, 20187 yr by ChaoticSoul
June 25, 20187 yr Get the player's equipped items Check them against your armor types Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 27, 20187 yr Conveniently, I literally just coded this into my mod. You're going to want to have a class which is an @EventBusSubscriber, with a method annotated @SubscribeEvent which takes the parameter (TickEvent.PlayerTickEvent event). Then you want to make a variable NonNullList<ItemStack> armor = event.player.inventory.armorInventory; then check if(armor.get(0).getItem()=={the boots they should be wearing, as an Item object} && armor.get(1).getItem()=={the leggings they should be wearing, as an Item object} && armor.get(2).getItem()=={the chestplate they should be wearing, as an Item object} && armor.get(3).getItem()=={the helmet they should be wearing, as an Item object}){ event.player.addPotionEffect(new PotionEffect(MobEffects.{The effect you want},{how many ticks the effect should last},{the level of the effect, -1},false,{false if you want it not to have particles, true if you do}); } Keep in mind that the effect will be re-added every tick, so you only really need to put the duration at about 5, unless you are doing Night Vision. Night Vision will flicker if it has 10 seconds or less left, so you should put a duration of 220 for that. This also won't really work for Regen or Absorption, but those are a bit complicated to do. It should work for most passive potion effects (Strength, speed, jump boost, resistance, fire resistance, etc) If you don't understand anything here, you should probably read up on some modding tutorials; they can be very helpful in grasping some of the basics here. Going through some basic online lessons on java (say Code.org) can be helpful for beginners as well.
June 27, 20187 yr Rather than get(0), there is a method that will get an item stack based on its equipment type. Use that. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
June 29, 20187 yr Author On 6/27/2018 at 10:46 PM, Venrob said: Conveniently, I literally just coded this into my mod. You're going to want to have a class which is an @EventBusSubscriber, with a method annotated @SubscribeEvent which takes the parameter (TickEvent.PlayerTickEvent event). Then you want to make a variable NonNullList<ItemStack> armor = event.player.inventory.armorInventory; then check if(armor.get(0).getItem()=={the boots they should be wearing, as an Item object} && armor.get(1).getItem()=={the leggings they should be wearing, as an Item object} && armor.get(2).getItem()=={the chestplate they should be wearing, as an Item object} && armor.get(3).getItem()=={the helmet they should be wearing, as an Item object}){ event.player.addPotionEffect(new PotionEffect(MobEffects.{The effect you want},{how many ticks the effect should last},{the level of the effect, -1},false,{false if you want it not to have particles, true if you do}); } Keep in mind that the effect will be re-added every tick, so you only really need to put the duration at about 5, unless you are doing Night Vision. Night Vision will flicker if it has 10 seconds or less left, so you should put a duration of 220 for that. This also won't really work for Regen or Absorption, but those are a bit complicated to do. It should work for most passive potion effects (Strength, speed, jump boost, resistance, fire resistance, etc) If you don't understand anything here, you should probably read up on some modding tutorials; they can be very helpful in grasping some of the basics here. Going through some basic online lessons on java (say Code.org) can be helpful for beginners as well. SOLVED! Thank you so much, I have struggling with this for a week and it is finally working!
June 30, 20187 yr 10 hours ago, ChaoticSoul said: SOLVED! Thank you so much, I have struggling with this for a week and it is finally working! No problem! Like I said, I literally had just coded this exact thing!
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.