Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • Author

Thanks, the problem with worldObj.getClosestPlayerToEntity was, that the entity wasn't in the world yet at the moment the event triggered.

  • Author

Oh, I didn't even see that... Don't use

getClosestPlayerToEntity

. Use

EntityArrow::shootingEntity

.

There is no getter in EntityArrow class.

  • Author

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

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.

  • Author

 

 

@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");

};

}

}

 

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.