mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Temporary fix for Forge 1.17 setRemoved() regression
This commit is contained in:
parent
b9310e93a9
commit
10f84bcd79
7 changed files with 66 additions and 16 deletions
|
@ -185,12 +185,17 @@ public class KineticTileEntity extends SmartTileEntity
|
|||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRemovedNotDueToChunkUnload() {
|
||||
if (!level.isClientSide) {
|
||||
if (hasNetwork())
|
||||
getOrCreateNetwork().remove(this);
|
||||
detachKinetics();
|
||||
}
|
||||
super.setRemoved();
|
||||
super.setRemovedNotDueToChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -86,10 +86,15 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender
|
|||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
detachWheel();
|
||||
super.setRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRemovedNotDueToChunkUnload() {
|
||||
detachWheel();
|
||||
super.setRemovedNotDueToChunkUnload();
|
||||
}
|
||||
|
||||
protected void refreshWheelSpeed() {
|
||||
if (poweredWheel == null)
|
||||
return;
|
||||
|
|
|
@ -362,9 +362,14 @@ public class ClockworkBearingTileEntity extends KineticTileEntity
|
|||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRemovedNotDueToChunkUnload() {
|
||||
if (!level.isClientSide)
|
||||
disassemble();
|
||||
super.setRemoved();
|
||||
super.setRemovedNotDueToChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -59,9 +59,14 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
|
|||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRemovedNotDueToChunkUnload() {
|
||||
if (!level.isClientSide)
|
||||
disassemble();
|
||||
super.setRemoved();
|
||||
super.setRemovedNotDueToChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -173,10 +173,15 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity
|
|||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRemovedNotDueToChunkUnload() {
|
||||
this.remove = true;
|
||||
if (!level.isClientSide)
|
||||
disassemble();
|
||||
super.setRemoved();
|
||||
super.setRemovedNotDueToChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -197,12 +197,17 @@ public class BasinTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
onEmptied();
|
||||
itemCapability.invalidate();
|
||||
fluidCapability.invalidate();
|
||||
super.setRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRemovedNotDueToChunkUnload() {
|
||||
onEmptied();
|
||||
super.setRemovedNotDueToChunkUnload();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, Direction side) {
|
||||
|
|
|
@ -146,10 +146,30 @@ public abstract class SmartTileEntity extends SyncedTileEntity implements IParti
|
|||
.reduce(ItemRequirement.NONE, (a, b) -> a.with(b.getRequiredItems()), (a, b) -> a.with(b));
|
||||
}
|
||||
|
||||
/* TODO: Remove this hack once this issue is resolved: https://github.com/MinecraftForge/MinecraftForge/issues/8302
|
||||
Once the PR linked in the issue is accepted, we should use the new method for determining whether setRemoved was
|
||||
called due to a chunk unload or not, and remove this volatile workaround
|
||||
*/
|
||||
private boolean unloaded;
|
||||
|
||||
@Override
|
||||
public void onChunkUnloaded() {
|
||||
super.onChunkUnloaded();
|
||||
unloaded = true;
|
||||
}
|
||||
|
||||
protected void setRemovedNotDueToChunkUnload() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
forEachBehaviour(TileEntityBehaviour::remove);
|
||||
super.setRemoved();
|
||||
|
||||
if (!unloaded) {
|
||||
setRemovedNotDueToChunkUnload();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLazyTickRate(int slowTickRate) {
|
||||
|
|
Loading…
Reference in a new issue