1.16.5 Trying to trigger the loyalty trident before the trident hits

Discussion in 'Spigot Plugin Development' started by FlameFOxYT, Dec 8, 2020.

  1. I'm trying to make trident trigger Loyalty 60 ticks after being thrown (Instead of returning only after it hits),
    any of you have any suggestions how can i do that?
  2. Use projectileshootevent and if player and projectile equals trident, create a runnable to a class to do this:

    Code (Text):
    EntityThrownTrident t = ((CraftTrident) e.getEntity()).getHandle();
                net.minecraft.server.v1_15_R1.ItemStack a = t.trident;
    Use that to get the itemstack and then remove the entity and add the itemstack to the player's inventory.

    I dunno if loyalty drops the trident at the location if the inventory is full or not, so you might need to check that.
  3. Thanks for the help, thats not what i meant, deleting the entity is easy, im talking about trident loyalty effect when it returns to the player with a sound and the effect.
  4. There's sadly no easy one-call method way, but you can just do it as Minecraft does it. Take a look at net.minecraft.server.v1_16_R3.EntityThrownTrident.class.

    1. Convert your trident to the internal EntityThrownTrident.
    2. Set the noClip flag to true. entityThrownTrident.o(true);
    3. Calculate a vector between the trident position and player position. Then apply that vector as "motion" so the trident flies towards the player.
    4. Play the ITEM_TRIDENT_RETURN sound.