Jump to content

[1.19.4] How to prevent leash knots from disappearing?


JimiIT92

Recommended Posts

I want to make the player be able to attach a leash to a fence without a mob leashed to it.

So essentially have a fence persisting like this
t9GOX83.png

However when I realod the world the leash knot is gone, and I don't understand why (I know it's a vanilla feature, but even looking at the entity code I can't find out why it breaks so I can override it).

What I've tried so far is to intercept the EntityLeaveLevelEvent, but that seems to not be firing when reloading the world and removing the entity.
So what is actually been fired when the lead disappear, so I can prevent it? Where should I look into?

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

HangingEntity.survives() ?

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

27 minutes ago, warjort said:

HangingEntity.survives() ?

That was the first method I've looked into, but doesn't seem to be called on world reload. Also the leash knot entity overrides the base method by simply checking the block is "knotted" to is a fence block, which in this case it is

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

Don't know then. Looks like a job for your debugger.

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

Unless what you are actually doing is just creating a ghost entity on the client?

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

I think I figured out what the problem is: the leash knot entity type has the noSave() attribute set
 

public static final EntityType<LeashFenceKnotEntity> LEASH_KNOT = register("leash_knot", EntityType.Builder.<LeashFenceKnotEntity>of(LeashFenceKnotEntity::new, MobCategory.MISC).noSave().sized(0.375F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE));

What I've tried is to create a custom entity that extends the LeashFenceKnotEntity class and when registering it I removed the noSave attribute, and sure enough it worked: the leash stayed through world reloads.
But that raises another question: can I remove this attribute from the vanilla entity? Since having to create a custom entity imply that I have to replace all vanilla leash knots with custom ones when they are added (which is not optimal I guess)

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

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.