mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-15 04:30:29 +00:00
Defer monitor tile update when placed by another TE
This commit is contained in:
parent
53dd15a213
commit
99b719299c
@ -20,6 +20,7 @@ import net.minecraft.tileentity.TileEntityType;
|
|||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.fml.RegistryObject;
|
import net.minecraftforge.fml.RegistryObject;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -85,9 +86,14 @@ public class BlockMonitor extends BlockGeneric
|
|||||||
if( entity instanceof TileMonitor && !world.isClientSide )
|
if( entity instanceof TileMonitor && !world.isClientSide )
|
||||||
{
|
{
|
||||||
TileMonitor monitor = (TileMonitor) entity;
|
TileMonitor monitor = (TileMonitor) entity;
|
||||||
monitor.contractNeighbours();
|
// Defer the block update if we're being placed by another TE. See #691
|
||||||
monitor.contract();
|
if ( livingEntity == null || livingEntity instanceof FakePlayer )
|
||||||
monitor.expand();
|
{
|
||||||
|
monitor.updateNeighborsDeferred();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
monitor.updateNeighbors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ public class TileMonitor extends TileGeneric
|
|||||||
private LazyOptional<IPeripheral> peripheralCap;
|
private LazyOptional<IPeripheral> peripheralCap;
|
||||||
private final Set<IComputerAccess> computers = new HashSet<>();
|
private final Set<IComputerAccess> computers = new HashSet<>();
|
||||||
|
|
||||||
|
private boolean needsUpdate = false;
|
||||||
private boolean destroyed = false;
|
private boolean destroyed = false;
|
||||||
private boolean visiting = false;
|
private boolean visiting = false;
|
||||||
|
|
||||||
@ -147,6 +148,12 @@ public class TileMonitor extends TileGeneric
|
|||||||
@Override
|
@Override
|
||||||
public void blockTick()
|
public void blockTick()
|
||||||
{
|
{
|
||||||
|
if ( needsUpdate )
|
||||||
|
{
|
||||||
|
needsUpdate = false;
|
||||||
|
updateNeighbors();
|
||||||
|
}
|
||||||
|
|
||||||
if( xIndex != 0 || yIndex != 0 || serverMonitor == null ) return;
|
if( xIndex != 0 || yIndex != 0 || serverMonitor == null ) return;
|
||||||
|
|
||||||
serverMonitor.clearChanged();
|
serverMonitor.clearChanged();
|
||||||
@ -525,6 +532,18 @@ public class TileMonitor extends TileGeneric
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateNeighborsDeferred()
|
||||||
|
{
|
||||||
|
needsUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateNeighbors()
|
||||||
|
{
|
||||||
|
contractNeighbours();
|
||||||
|
contract();
|
||||||
|
expand();
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings( "StatementWithEmptyBody" )
|
@SuppressWarnings( "StatementWithEmptyBody" )
|
||||||
void expand()
|
void expand()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user