So, here's the situation: I have injected a capability into a TileEntityDispenser so that I can store some data there, for example a BlockPos. When the dispenser fires a splash potion or tipped arrow that has a custom potion effect of mine, I want to pass this BlockPos data over to these projectiles. (For context, the potion effect is "teleportation" and the BlockPos data that is being transferred are the coordinates where a target that's hit by the projectile should be teleported.)
My two-part question is:
1) How do I transfer this data to the potion or tipped arrow when the dispenser fires it?
I looked at using BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY#putObject, but this would seem to require me to register a new Item, and I didn't have to create a new Item for the potion or arrow. I only created a new potion and potion effect.
2) Let's say I figure the first part out and I'm able to store the BlockPos data in the EntityPotion and EntityTippedArrow as capability data. When the potion or arrow hits a living target, how/when do I call my teleport method?
Normally the way I do this, when it's a player who throws the potion or shoots the arrow, is call my teleport method from the #affectEntity or #performEffect method in my potion class which extends PotionBase. Those methods allow me to get the player who threw the potion or fired the arrow and read the teleport destination data using a custom capability I injected into EntityPlayer. But in this case when the dispenser throws these projectiles, the dispenser that fired them is not available in those potion methods, i.e. the "attacking entity" is null. So I think I need another way to call my teleport method with the BlockPos data stored in the potion or arrow, but how?