1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-12 18:30:29 +00:00

Split up modem and connection invalidation

This commit is contained in:
SquidDev 2018-04-16 15:47:32 +01:00
parent 6ca61f000f
commit b2aa390ae1
4 changed files with 19 additions and 22 deletions

View File

@ -332,7 +332,8 @@ public class BlockCable extends BlockPeripheralBase
item = PeripheralItemFactory.create( PeripheralType.Cable, null, 1 );
}
cable.networkChanged();
cable.modemChanged();
cable.connectionsChanged();
if( !world.isRemote && !player.capabilities.isCreativeMode ) dropItem( world, pos, item );
return false;
@ -382,7 +383,7 @@ public class BlockCable extends BlockPeripheralBase
TileCable cable = (TileCable) tile;
if( cable.getPeripheralType() != PeripheralType.WiredModem )
{
cable.networkChanged();
cable.connectionsChanged();
}
}

View File

@ -98,8 +98,8 @@ public class ItemCable extends ItemPeripheralBase
TileEntity tile = world.getTileEntity( pos );
if( tile != null && tile instanceof TileCable )
{
TileCable cable = (TileCable)tile;
cable.networkChanged();
TileCable cable = (TileCable) tile;
cable.connectionsChanged();
}
return EnumActionResult.SUCCESS;
}
@ -131,7 +131,8 @@ public class ItemCable extends ItemPeripheralBase
if( tile != null && tile instanceof TileCable )
{
TileCable cable = (TileCable)tile;
cable.networkChanged();
cable.modemChanged();
cable.connectionsChanged();
}
return EnumActionResult.SUCCESS;
}
@ -153,7 +154,8 @@ public class ItemCable extends ItemPeripheralBase
if( tile != null && tile instanceof TileCable )
{
TileCable cable = (TileCable)tile;
cable.networkChanged();
cable.modemChanged();
cable.connectionsChanged();
}
return EnumActionResult.SUCCESS;
}

View File

@ -291,7 +291,8 @@ public class TileCable extends TileModemBase
((BlockGeneric) getBlockType()).dropItem( getWorld(), getPos(), PeripheralItemFactory.create( PeripheralType.WiredModem, getLabel(), 1 ) );
setLabel( null );
setBlockState( getBlockState().withProperty( BlockCable.Properties.MODEM, BlockCableModemVariant.None ) );
networkChanged();
modemChanged();
connectionsChanged();
break;
}
@ -474,19 +475,17 @@ public class TileCable extends TileModemBase
{
if( !m_connectionsFormed )
{
networkChanged();
connectionsChanged();
if( m_peripheralAccessAllowed ) m_node.invalidate();
m_connectionsFormed = true;
}
}
}
public void networkChanged()
public void connectionsChanged()
{
if( getWorld().isRemote ) return;
if( modemChanged() ) m_node.invalidate();
IBlockState state = getBlockState();
World world = getWorld();
BlockPos current = getPos();
@ -511,11 +510,9 @@ public class TileCable extends TileModemBase
}
}
private boolean modemChanged()
public void modemChanged()
{
if( getWorld().isRemote ) return false;
boolean requiresUpdate = false;
if( getWorld().isRemote ) return;
PeripheralType type = getPeripheralType();
if( type == PeripheralType.Cable )
@ -526,12 +523,10 @@ public class TileCable extends TileModemBase
if( type != PeripheralType.WiredModemWithCable && m_peripheralAccessAllowed )
{
m_peripheralAccessAllowed = false;
requiresUpdate = true;
m_node.invalidate();
markDirty();
updateAnim();
}
return requiresUpdate;
}
// private stuff

View File

@ -293,7 +293,8 @@ public class TileWiredModemFull extends TilePeripheralBase
if( !m_connectionsFormed )
{
networkChanged();
connectionsChanged();
if( m_peripheralAccessAllowed ) node.invalidate();
m_connectionsFormed = true;
}
}
@ -301,7 +302,7 @@ public class TileWiredModemFull extends TilePeripheralBase
super.update();
}
private void networkChanged()
private void connectionsChanged()
{
if( getWorld().isRemote ) return;
@ -318,8 +319,6 @@ public class TileWiredModemFull extends TilePeripheralBase
// If we can connect to it then do so
node.connectTo( element.getNode() );
}
node.invalidate();
}
// private stuff