Fix facades not updating cached bounds (#4667)
* Move model loader registration to the mod constructor because forge runs the model registry event concurrently, apparently.
* Do not register the loaders during data generation.
* Fixes removal of facades not invalidating the cached server-side collision boxes. (#4663)
(cherry picked from commit 957bc4c5cc)
This commit is contained in:
@@ -37,15 +37,18 @@ public class FacadeContainer implements IFacadeContainer {
|
|||||||
|
|
||||||
private final int facades = 6;
|
private final int facades = 6;
|
||||||
private final CableBusStorage storage;
|
private final CableBusStorage storage;
|
||||||
|
private final Runnable changeCallback;
|
||||||
|
|
||||||
public FacadeContainer(final CableBusStorage cbs) {
|
public FacadeContainer(final CableBusStorage cbs, Runnable changeCallback) {
|
||||||
this.storage = cbs;
|
this.storage = cbs;
|
||||||
|
this.changeCallback = changeCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addFacade(final IFacadePart a) {
|
public boolean addFacade(final IFacadePart a) {
|
||||||
if (this.getFacade(a.getSide()) == null) {
|
if (this.getFacade(a.getSide()) == null) {
|
||||||
this.storage.setFacade(a.getSide().ordinal(), a);
|
this.storage.setFacade(a.getSide().ordinal(), a);
|
||||||
|
this.notifyChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -56,6 +59,7 @@ public class FacadeContainer implements IFacadeContainer {
|
|||||||
if (side != null && side != AEPartLocation.INTERNAL) {
|
if (side != null && side != AEPartLocation.INTERNAL) {
|
||||||
if (this.storage.getFacade(side.ordinal()) != null) {
|
if (this.storage.getFacade(side.ordinal()) != null) {
|
||||||
this.storage.setFacade(side.ordinal(), null);
|
this.storage.setFacade(side.ordinal(), null);
|
||||||
|
this.notifyChange();
|
||||||
if (host != null) {
|
if (host != null) {
|
||||||
host.markForUpdate();
|
host.markForUpdate();
|
||||||
}
|
}
|
||||||
@@ -84,6 +88,7 @@ public class FacadeContainer implements IFacadeContainer {
|
|||||||
for (int x = 0; x < this.facades; x++) {
|
for (int x = 0; x < this.facades; x++) {
|
||||||
this.storage.setFacade(x, newFacades[x]);
|
this.storage.setFacade(x, newFacades[x]);
|
||||||
}
|
}
|
||||||
|
this.notifyChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -175,4 +180,9 @@ public class FacadeContainer implements IFacadeContainer {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void notifyChange() {
|
||||||
|
this.changeCallback.run();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IFacadeContainer getFacadeContainer() {
|
public IFacadeContainer getFacadeContainer() {
|
||||||
return new FacadeContainer(this);
|
return new FacadeContainer(this, this::invalidateShapes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user