Add fix for leaking client TEs (#298)
* Add fix for leaking client TEs * Remove client-side markDirty() call
This commit is contained in:
@@ -32,6 +32,7 @@ import appeng.me.Grid;
|
|||||||
import appeng.tile.AEBaseTile;
|
import appeng.tile.AEBaseTile;
|
||||||
import appeng.util.IWorldCallable;
|
import appeng.util.IWorldCallable;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.collect.LinkedListMultimap;
|
import com.google.common.collect.LinkedListMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
@@ -66,7 +67,20 @@ public class TickHandler {
|
|||||||
return this.cliPlayerColors;
|
return this.cliPlayerColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a server or world callback which gets called the next time the queue is ticked.
|
||||||
|
* <p>
|
||||||
|
* Callbacks on the client are not support.
|
||||||
|
* <p>
|
||||||
|
* Using null as world will queue it into the global {@link TickEvent.ServerTickEvent}, otherwise it will be ticked with the
|
||||||
|
* corresponding {@link TickEvent.WorldTickEvent}.
|
||||||
|
*
|
||||||
|
* @param w null or the specific {@link World}
|
||||||
|
* @param c the callback
|
||||||
|
*/
|
||||||
public void addCallable(final World w, final IWorldCallable<?> c) {
|
public void addCallable(final World w, final IWorldCallable<?> c) {
|
||||||
|
Preconditions.checkArgument(w == null || !w.isRemote, "Can only register serverside callbacks");
|
||||||
|
|
||||||
if (w == null) {
|
if (w == null) {
|
||||||
this.serverQueue.add(c);
|
this.serverQueue.add(c);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -434,12 +434,16 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveChanges() {
|
public void saveChanges() {
|
||||||
if (this.world != null) {
|
// Clientside should not need to save/markDirty() data
|
||||||
this.world.markChunkDirty(this.pos, this);
|
if (this.world == null || this.world.isRemote) {
|
||||||
if (!this.markDirtyQueued) {
|
return;
|
||||||
TickHandler.INSTANCE.addCallable(null, this::markDirtyAtEndOfTick);
|
}
|
||||||
this.markDirtyQueued = true;
|
|
||||||
}
|
// Serverside is only queued once per tick to avoid costly operations
|
||||||
|
this.world.markChunkDirty(this.pos, this);
|
||||||
|
if (!this.markDirtyQueued) {
|
||||||
|
TickHandler.INSTANCE.addCallable(null, this::markDirtyAtEndOfTick);
|
||||||
|
this.markDirtyQueued = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user