Fixes removal of facades not invalidating the cached server-side collision boxes. (#4663)

This commit is contained in:
shartte
2020-08-31 23:10:25 +02:00
committed by GitHub
parent e90dd2f9c6
commit 957bc4c5cc
2 changed files with 12 additions and 2 deletions
@@ -37,15 +37,18 @@ public class FacadeContainer implements IFacadeContainer {
private final int facades = 6;
private final CableBusStorage storage;
private final Runnable changeCallback;
public FacadeContainer(final CableBusStorage cbs) {
public FacadeContainer(final CableBusStorage cbs, Runnable changeCallback) {
this.storage = cbs;
this.changeCallback = changeCallback;
}
@Override
public boolean addFacade(final IFacadePart a) {
if (this.getFacade(a.getSide()) == null) {
this.storage.setFacade(a.getSide().ordinal(), a);
this.notifyChange();
return true;
}
return false;
@@ -56,6 +59,7 @@ public class FacadeContainer implements IFacadeContainer {
if (side != null && side != AEPartLocation.INTERNAL) {
if (this.storage.getFacade(side.ordinal()) != null) {
this.storage.setFacade(side.ordinal(), null);
this.notifyChange();
if (host != null) {
host.markForUpdate();
}
@@ -84,6 +88,7 @@ public class FacadeContainer implements IFacadeContainer {
for (int x = 0; x < this.facades; x++) {
this.storage.setFacade(x, newFacades[x]);
}
this.notifyChange();
}
@Override
@@ -175,4 +180,9 @@ public class FacadeContainer implements IFacadeContainer {
}
return true;
}
private void notifyChange() {
this.changeCallback.run();
}
}
@@ -125,7 +125,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
@Override
public IFacadeContainer getFacadeContainer() {
return new FacadeContainer(this);
return new FacadeContainer(this, this::invalidateShapes);
}
@Override