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
|
@ -49,7 +49,7 @@
|
||||||
this.field_145850_b.func_175666_e(this.field_174879_c, this.field_195045_e.func_177230_c());
|
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() {
|
public void func_145843_s() {
|
||||||
this.field_145846_f = true;
|
this.field_145846_f = true;
|
||||||
|
@ -57,8 +57,15 @@
|
||||||
+ requestModelDataUpdate();
|
+ requestModelDataUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ @Override
|
||||||
|
+ public void onChunkUnloaded() {
|
||||||
|
+ this.invalidateCaps();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
public void func_145829_t() {
|
public void func_145829_t() {
|
||||||
@@ -175,6 +184,13 @@
|
this.field_145846_f = false;
|
||||||
|
}
|
||||||
|
@@ -175,6 +189,13 @@
|
||||||
return this.field_200663_e;
|
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
|
* call this, if they are covered with a microblock panel, thus cutting off pipe
|
||||||
* connectivity to this side.
|
* connectivity to this side.
|
||||||
* <p>
|
* <p>
|
||||||
* Also should be called for all when a TE is invalidated, or a world/chunk
|
* Also should be called for all when a TE is invalidated (for example, when
|
||||||
* unloads, or a entity dies, etc... This allows modders to keep a cache of
|
* the TE is removed or unloaded), or a world/chunk unloads, or a entity dies,
|
||||||
* capability objects instead of re-checking them every tick.
|
* etc... This allows modders to keep a cache of capability objects instead of
|
||||||
|
* re-checking them every tick.
|
||||||
*/
|
*/
|
||||||
public void invalidate()
|
public void invalidate()
|
||||||
{
|
{
|
||||||
this.isValid = false;
|
if (this.isValid)
|
||||||
this.listeners.forEach(e -> e.accept(this));
|
{
|
||||||
|
this.isValid = false;
|
||||||
|
this.listeners.forEach(e -> e.accept(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue