McJty / YouTubeModding14

Source code for my YouTube modding tutorial series for Minecraft 1.15 and 1.16
MIT License
107 stars 35 forks source link

You should invalidate the LazyOptionals in TileEntities #10

Open LukeGi opened 4 years ago

LukeGi commented 4 years ago

In your tile entity classes with LazyOptional<?> fields, you should be overriding the invalidate method in the tile, and calling lazyOptional.invalidate(); on them.

LukeGi commented 4 years ago

By doing this you ensure that any other blocks that store a reference to the LazyOptional instance release their cached value resulting in no references to it, which will allow for proper garbage collection.