[Suggestion] Potion effects for riders of a vehicle
gyrohero opened this issue ยท 1 comments
My intent with this is to allow certain vehicles to cause all of their riders to incur potion effects depending on the purpose of the vehicle. My inspiration was the idea of having military helicopters give their riders the night vision effect. Other possible applications would be an armored vehicle that gives its riders the resistance effect, or an ambulance/medevac helicopter that gives its riders a small amount of regeneration. Using the existing MC potion effect framework should limit how much work is needed for this, while yielding some nice extra possibilities for pack authors.
As for implementation, here's how I see it happening:
- Within the mcinterface package (possibly WrapperEntity), create some method like .addEffect that will call the .addPotionEffect() method on an EntityLivingBase representing the rider. I'm not sure exactly how to check that the rider is an EntityLivingBase and not just an Entity, as I'm still new to Java and MC mod development.
- Within EntityVehicleB_Rideable, call the .addEffect method on the rider within the addRider and updateRider methods, to ensure the effect is continuously applied.
- As for the JSONdef, I see the important properties being:
- the name of the effect (can be drawn from the names enumerated in net.minecraft.init.MobEffects)
- the amplifier
- the duration, in ticks -- this will let pack authors figure out how to balance the effect not wearing out while still in the vehicle vs. the effect going away soon after exiting. The amount of appropriate residual effects may vary with the application anyway.
If you think this seems feasible, I may be able to work on some code on my own. The biggest uncertainty for me is the Entity vs. EntityLivingBase thing I mentioned.
I'd say it's feasible for sure. All the places you said where the hooks need to be are correct. As to testing if the entity is an EntityLivingBase, you can just do "if(entity instanceof EntityLivingBase)". Throw a PR and I'll take a look, and if it works, I'll put it in. Just don't forget the handbook!