Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Event That Fired When the Player Pickups An Arrow From Ground?
The update for 1.13 is being worked on - please be patient. (Updated 02/19/19)
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
JanneSoon

Event That Fired When the Player Pickups An Arrow From Ground?

Started by JanneSoon, July 25, 2018

9 posts in this topic

JanneSoon    1

JanneSoon

JanneSoon    1

  • Tree Puncher
  • JanneSoon
  • Members
  • 1
  • 21 posts
  • Report post
Posted July 25, 2018 (edited)

Hello everyone. I'm stuck at somewhere in modding. I need to customize the arrow drop (getting the arrow back from the ground you shot). All i want is; the EntityArrow on the ground gives Broken Arrow(my mod item) by a chance instead of Arrow item from vanilla. Isn't it possible to do?

I looked into LivingDropsEvent, EntityItemPickupEvent and ItemPickupEvent but i couldn't find a way to do it. These events fired only when the player pickups an arrow as an item(dropped item) from the ground. Help me please :(

Thank you.

I'm currently on 1.12.2

Edited July 25, 2018 by JanneSoon

Share this post


Link to post
Share on other sites

m00nl1ght    2

m00nl1ght

m00nl1ght    2

  • Tree Puncher
  • m00nl1ght
  • Members
  • 2
  • 14 posts
  • Report post
Posted July 25, 2018

Unfortunately, there is no such event. The arrow is added to the players inventory directly in EntityArrow#onCollideWithPlayer.

 

Share this post


Link to post
Share on other sites

JanneSoon    1

JanneSoon

JanneSoon    1

  • Tree Puncher
  • JanneSoon
  • Members
  • 1
  • 21 posts
  • Report post
Posted July 25, 2018
3 minutes ago, m00nl1ght said:

Unfortunately, there is no such event. The arrow is added to the players inventory directly in EntityArrow#onCollideWithPlayer.

 

:( There's no way to do that i wish so?

Share this post


Link to post
Share on other sites

m00nl1ght    2

m00nl1ght

m00nl1ght    2

  • Tree Puncher
  • m00nl1ght
  • Members
  • 2
  • 14 posts
  • Report post
Posted July 25, 2018

You could create a pull request on Forge's github if you really need this hook/event. Here you can find information about pull requests.

Share this post


Link to post
Share on other sites

jabelar    584

jabelar

jabelar    584

  • Reality Controller
  • jabelar
  • Members
  • 584
  • 3266 posts
  • Report post
Posted July 25, 2018
6 hours ago, JanneSoon said:

:( There's no way to do that i wish so?

You can still do it but would require doing something a bit intrusive. For example, one approach is to replace all EntityArrow with your own version that extends EntityArrow and overrides the collision method.

 

Another approach would be to set the public pickupStatus field in every EntityArrow to EntityArrow.PickupStatus.DISALLOWED and then handle the entity update event and process the collision yourself.

Share this post


Link to post
Share on other sites

Cadiboo    148

Cadiboo

Cadiboo    148

  • World Shaper
  • Cadiboo
  • Members
  • 148
  • 2137 posts
  • Report post
Posted August 9, 2018
On 7/26/2018 at 1:12 AM, jabelar said:

You can still do it but would require doing something a bit intrusive. For example, one approach is to replace all EntityArrow with your own version that extends EntityArrow and overrides the collision method.

 

Another approach would be to set the public pickupStatus field in every EntityArrow to EntityArrow.PickupStatus.DISALLOWED and then handle the entity update event and process the collision yourself.

Could you also use reflection to replace that bit of code that handles pickups in EntityArrow with your code?

Share this post


Link to post
Share on other sites

Animefan8888    491

Animefan8888

Animefan8888    491

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 491
  • 4324 posts
  • Report post
Posted August 9, 2018
7 minutes ago, Cadiboo said:

Could you also use reflection to replace that bit of code that handles pickups in EntityArrow with your code?

No, reflection allows you to access code that would otherwise be inaccessible, it doesn't allow you to modify a method.

Share this post


Link to post
Share on other sites

Cadiboo    148

Cadiboo

Cadiboo    148

  • World Shaper
  • Cadiboo
  • Members
  • 148
  • 2137 posts
  • Report post
Posted August 9, 2018
Just now, Animefan8888 said:

No, reflection allows you to access code that would otherwise be inaccessible, it doesn't allow you to modify a method.

I meant ASM, isn’t ASM an advanced form of reflection?

Share this post


Link to post
Share on other sites

Animefan8888    491

Animefan8888

Animefan8888    491

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 491
  • 4324 posts
  • Report post
Posted August 9, 2018
Just now, Cadiboo said:

I meant ASM, isn’t ASM an advanced form of reflection?

No they are completely different, and ASM is a terrible thing that is not recommended on this forum.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 1
Go To Topic Listing Modder Support

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Drachenbauer
      Error with block registration

      By Drachenbauer · Posted 11 minutes ago

      i changed the ItemBlock-line in the constructor of the BalloonBlock into this: ItemInit.ITEMS.add(new ItemBlock(this, getDefaultProperties()).setRegistryName(this.getRegistryName()));   but the block still does not appear in my creative-inventory...
    • fieldbox
      Could not reserve enough space for 3145728KB object heap

      By fieldbox · Posted 23 minutes ago

      It says 1.8.0_191. I think that's a 32-bit JRE, whoops. (I installed it a while ago)   EDIT: I just checked. It's in Program Files (x86). Definitely 32-bit.   EDIT 2: After installing a new JRE, it still isn't working. Same error.
    • DaemonUmbra
      Could not reserve enough space for 3145728KB object heap

      By DaemonUmbra · Posted 25 minutes ago

      What does it say when you type java -version?
    • Davyboy2346
      Mods on Minecraft windows 10 edition

      By Davyboy2346 · Posted 26 minutes ago

      It would explain why it doesn't seem to work! Thank you
    • DaemonUmbra
      Mods on Minecraft windows 10 edition

      By DaemonUmbra · Posted 26 minutes ago

      Forge only works with Java edition, it has been discussed previously and there will be no support for Bedrock.
  • Topics

    • Drachenbauer
      16
      Error with block registration

      By Drachenbauer
      Started Tuesday at 03:50 PM

    • fieldbox
      2
      Could not reserve enough space for 3145728KB object heap

      By fieldbox
      Started 29 minutes ago

    • Davyboy2346
      3
      Mods on Minecraft windows 10 edition

      By Davyboy2346
      Started 31 minutes ago

    • oridos
      1
      Having trouble launching the client test through eclipse

      By oridos
      Started 2 hours ago

    • Kost
      0
      Server is not working, need help

      By Kost
      Started 51 minutes ago

  • Who's Online (See full list)

    • fieldbox
    • PulseBeat_02
    • Davyboy2346
    • DaemonUmbra
    • anna_cat
    • Drachenbauer
    • johnpalladiniyt
    • loordgek
    • Cheekibreekio
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Event That Fired When the Player Pickups An Arrow From Ground?
  • Theme
  • Contact Us

Copyright © 2017 ForgeDevelopment LLC Powered by Invision Community