Jump to content

Recommended Posts

Posted (edited)

Hi, and thanks for taking the time to review this.

I am working on my first Minecraft mod for 1.19.2.  The mod is simple, adding several "coin" items to the game and including these coins as part of mob drops.  I'm using this to better understand how to create mods, and I've become stuck on an issue for a few days.

The mod installs with no errors.  It works, in that the LivingDrops event callback will drop an additional vanilla item when I code it to do so.  But when I try to drop one of my added coin items, no coins drop.

CODE HERE: https://goonlinetools.com/snapshot/code/#onzeadw2yq9c8mll8s9uw

I've read everything I can, looked at a few other similar mods, Googled as best as I can, and I can't figure out why my custom item isn't dropping.  I'm not sure if I'm incorrectly initializing the coin items, or incorrectly referencing them in the event handler, or if there is another problem somewhere I just am not seeing. 

Would someone please review these two snippets and let me know if there is something glaringly obvious I'm overlooking? 

Thanks!

Edited by MikeD
Posted

Pretty sure you need to use annotations @SubscribeEvent to tell it to listen to that specific method.  https://emxtutorials.wordpress.com/adding-custom-drops-to-vanilla-mobs/

copy code from that tutorial 

Hi I'm DJ_Laser!

I just started modding so please bear with me as I learn these things.

I'm currently working on a mod called BetterAllays! Stay tuned for it to release hopefully sometime in 2023!

Have a great day!

Posted

Also Use @ModEventBusSubscriber on the class to auto register your event method 

Hi I'm DJ_Laser!

I just started modding so please bear with me as I learn these things.

I'm currently working on a mod called BetterAllays! Stay tuned for it to release hopefully sometime in 2023!

Have a great day!

Posted

Thanks, DJ_Laser.  Have both in there (I just hadn't provided the entirety of the code).  As I mentioned, the event method works.  I can replace my COIN_COPPER item reference with Items.DIRT and it adds a dirt block drop to every mob I kill.  So the LivingDropsEvent code is working.  But when I try to drop one of the custom item coins... nothing.

Posted (edited)
Quote

I just hadn't provided the entirety of the code

You should post the entire *real* code.

We aren't going to spend time trying to debug code you aren't actually using.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted (edited)

Your posted code works for me. (Tested with 1.18.2)

Quote

Not sure why you'd think I posted code I wasn't using?

The original code you posted didn't have the subscribe annotations. So, it wasn't the real code. Probably still isn't?

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted (edited)
24 minutes ago, warjort said:

Your posted code works for me. (Tested with 1.18.2)

The original code you posted didn't have the subscribe annotations. So, it wasn't the real code. Probably still isn't?

Thanks for checking, warjort.  Yes, it's the real code.  The code works for me, as well, but it fails to drop the coin objects (works with vanilla items like Items.DIRT).  So I'm trying to determine where the issue is.  I'm on 1.19.2, and the coins do not drop.

Did you get coin entities to drop for you on 1.18.2?  I know the textures would be missing, but that's further than I'm getting, if so.

Edited by MikeD

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.