Jump to content

[1.10.2]Impossible to create bow enchantment


fcelon

Recommended Posts

I tried to create a bow enchantment, that adds shot arrows custom ability (like explosion upon impact), but it seems to be impossible in 1.10. I tried to use ArrowLooseEvent, but there is no information about EntinyArrow, that was shot, so I can't give it custom tag. I also tried EntityConstructingEvent, but for EntinyArrow is no way to get the entity, that shot the arrow, so I can't check if the is it the player with enchanted bow. Finally, I tried to get closest player to the arrow and test if he has the enchantment, but it always returns null.

 

 

@SubscribeEvent(priority=EventPriority.HIGHEST, receiveCanceled=true)

public void onEvent(EntityEvent.EntityConstructing event)

{

if (event.getEntity() instanceof EntityArrow)

{

EntityArrow arrow = (EntityArrow) event.getEntity();

System.out.println("arrow detected");

EntityPlayer player = arrow.worldObj.getClosestPlayerToEntity(arrow, 5D);

if(EnchantmentHelper.getEnchantedItem(ModEnchantments.blast, player) !=null)

{

arrow.addTag("explosive");

System.out.println("Blast detected");

};

}

}

 

 

I have absolutely no idea, why Forge doesn' t allow us to get the entity, that shot the arrow and why worldObj.getClosestPlayerToEntity doesn't work for me.

Link to comment
Share on other sites

Sorry, but I'm still quite unfamiliar with Java. When I tried use Arrow.shootingEntity, it always returned me null. What should I do?

Post your code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

 

 

@SubscribeEvent(priority=EventPriority.HIGHEST, receiveCanceled=true)

public void onEvent(EntityJoinWorldEvent event)

{

if (event.getEntity() instanceof EntityArrow)

{

EntityArrow arrow = (EntityArrow) event.getEntity();

System.out.println("arrow detected");

EntityLivingBase player = (EntityLivingBase) arrow.shootingEntity;

if(EnchantmentHelper.getEnchantedItem(ModEnchantments.blast, player) !=null)

{

arrow.addTag("explosive");

System.out.println("Blast detected");

};

}

}

 

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.