Jump to content

[SOLVED] [1.18.2] How to prevent a spawned falling entity to drop items when is destroyed?


JimiIT92

Recommended Posts

I made a custom Pointed Dripstone that, when the block above is broken, it falls and on landing it spawns some dripstone drops (like vanilla dripstone does). However what if I don't want those drops but instead I just want the FallingBlockEntity that is spawned to just be destroyed? I tried this in the onFall and onBrokenAfterFall methods

fallingBlockEntity.dropItem = false;

but that doesn't seem to do anything. 

I also tried to listen for the LivingDropsEvent but since the dropped dripstone aren't technically drops, but rather ItemEntitys added to the world, that event never gets called.
I even tried to listen to the EntityJoinWorldEvent and indeed I can cancel it and no dripstone will be "dropped". However there's no way that I've found to actually tell if the ItemEntity has been "spawned" by the Falling Entity or not. I can only check if it has been tossed as a drop by an entity (checking the entity owner), but I guess that's not ideal.
So how can I stop the falling entity to "drop" items when it lands?

Edited by JimiIT92
solved

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

The dropItem is only for when your block lands on say a fence and turns into a item. It doesn't stop the block getting placed otherwise.

There doesn't appear to be an event where you can handle this. The one thing that behaves like you want is the Anvil and then only if the anvil's damage goes to zero from fall damage. This all hardcoded by mojang.

If you use a mixin accessor to change the private field cancelDrop to true it should do what you want (that is what the anvil code does).

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.

Link to comment
Share on other sites

Yes, this is exactly what I want to change. Not the fact that the block is placed (although it never does), but rather the "drops". I was trying to avoid using mixins as much as I can, and was rather curious about if there was a "proper" event to listen to change this behaviour

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

If you don't like mixins you can always use an access transformer.

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.

Link to comment
Share on other sites

3 hours ago, warjort said:

If you use a mixin accessor to change the private field cancelDrop to true it should do what you want (that is what the anvil code does).

mixin is in all cases the last option you should choose,
if this is possible with Reflection or an AT it should be used instead

Link to comment
Share on other sites

I ended up using an AT to make the FallingBlockEntity constructor with the pos public, as this is what I need in the dripstone code and so I can create an extended entity that overrides the fall method and set the dropItem property to false

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

  • JimiIT92 changed the title to [SOLVED] [1.18.2] How to prevent a spawned falling entity to drop items when is destroyed?

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.



×
×
  • Create New...

Important Information

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