Make TEs invalidate capabilities when the chunk they are in unloads (#7529)
Fixed LazyOptional potentially notifying invalidation listeners multiple times.
This commit is contained in:
parent
27220a5ad8
commit
1a539ffebc
2 changed files with 18 additions and 7 deletions
|
@ -49,7 +49,7 @@
|
|||
this.field_145850_b.func_175666_e(this.field_174879_c, this.field_195045_e.func_177230_c());
|
||||
}
|
||||
}
|
||||
@@ -133,6 +140,8 @@
|
||||
@@ -133,8 +140,15 @@
|
||||
|
||||
public void func_145843_s() {
|
||||
this.field_145846_f = true;
|
||||
|
@ -57,8 +57,15 @@
|
|||
+ requestModelDataUpdate();
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public void onChunkUnloaded() {
|
||||
+ this.invalidateCaps();
|
||||
+ }
|
||||
+
|
||||
public void func_145829_t() {
|
||||
@@ -175,6 +184,13 @@
|
||||
this.field_145846_f = false;
|
||||
}
|
||||
@@ -175,6 +189,13 @@
|
||||
return this.field_200663_e;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,13 +318,17 @@ public class LazyOptional<T>
|
|||
* call this, if they are covered with a microblock panel, thus cutting off pipe
|
||||
* connectivity to this side.
|
||||
* <p>
|
||||
* Also should be called for all when a TE is invalidated, or a world/chunk
|
||||
* unloads, or a entity dies, etc... This allows modders to keep a cache of
|
||||
* capability objects instead of re-checking them every tick.
|
||||
* Also should be called for all when a TE is invalidated (for example, when
|
||||
* the TE is removed or unloaded), or a world/chunk unloads, or a entity dies,
|
||||
* etc... This allows modders to keep a cache of capability objects instead of
|
||||
* re-checking them every tick.
|
||||
*/
|
||||
public void invalidate()
|
||||
{
|
||||
this.isValid = false;
|
||||
this.listeners.forEach(e -> e.accept(this));
|
||||
if (this.isValid)
|
||||
{
|
||||
this.isValid = false;
|
||||
this.listeners.forEach(e -> e.accept(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue