mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-03 12:23:53 +00:00
Split up modem and connection invalidation
This commit is contained in:
parent
6ca61f000f
commit
b2aa390ae1
@ -332,7 +332,8 @@ public class BlockCable extends BlockPeripheralBase
|
|||||||
item = PeripheralItemFactory.create( PeripheralType.Cable, null, 1 );
|
item = PeripheralItemFactory.create( PeripheralType.Cable, null, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
cable.networkChanged();
|
cable.modemChanged();
|
||||||
|
cable.connectionsChanged();
|
||||||
if( !world.isRemote && !player.capabilities.isCreativeMode ) dropItem( world, pos, item );
|
if( !world.isRemote && !player.capabilities.isCreativeMode ) dropItem( world, pos, item );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -382,7 +383,7 @@ public class BlockCable extends BlockPeripheralBase
|
|||||||
TileCable cable = (TileCable) tile;
|
TileCable cable = (TileCable) tile;
|
||||||
if( cable.getPeripheralType() != PeripheralType.WiredModem )
|
if( cable.getPeripheralType() != PeripheralType.WiredModem )
|
||||||
{
|
{
|
||||||
cable.networkChanged();
|
cable.connectionsChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,8 +98,8 @@ public class ItemCable extends ItemPeripheralBase
|
|||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getTileEntity( pos );
|
||||||
if( tile != null && tile instanceof TileCable )
|
if( tile != null && tile instanceof TileCable )
|
||||||
{
|
{
|
||||||
TileCable cable = (TileCable)tile;
|
TileCable cable = (TileCable) tile;
|
||||||
cable.networkChanged();
|
cable.connectionsChanged();
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,8 @@ public class ItemCable extends ItemPeripheralBase
|
|||||||
if( tile != null && tile instanceof TileCable )
|
if( tile != null && tile instanceof TileCable )
|
||||||
{
|
{
|
||||||
TileCable cable = (TileCable)tile;
|
TileCable cable = (TileCable)tile;
|
||||||
cable.networkChanged();
|
cable.modemChanged();
|
||||||
|
cable.connectionsChanged();
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
@ -153,7 +154,8 @@ public class ItemCable extends ItemPeripheralBase
|
|||||||
if( tile != null && tile instanceof TileCable )
|
if( tile != null && tile instanceof TileCable )
|
||||||
{
|
{
|
||||||
TileCable cable = (TileCable)tile;
|
TileCable cable = (TileCable)tile;
|
||||||
cable.networkChanged();
|
cable.modemChanged();
|
||||||
|
cable.connectionsChanged();
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,8 @@ public class TileCable extends TileModemBase
|
|||||||
((BlockGeneric) getBlockType()).dropItem( getWorld(), getPos(), PeripheralItemFactory.create( PeripheralType.WiredModem, getLabel(), 1 ) );
|
((BlockGeneric) getBlockType()).dropItem( getWorld(), getPos(), PeripheralItemFactory.create( PeripheralType.WiredModem, getLabel(), 1 ) );
|
||||||
setLabel( null );
|
setLabel( null );
|
||||||
setBlockState( getBlockState().withProperty( BlockCable.Properties.MODEM, BlockCableModemVariant.None ) );
|
setBlockState( getBlockState().withProperty( BlockCable.Properties.MODEM, BlockCableModemVariant.None ) );
|
||||||
networkChanged();
|
modemChanged();
|
||||||
|
connectionsChanged();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -474,19 +475,17 @@ public class TileCable extends TileModemBase
|
|||||||
{
|
{
|
||||||
if( !m_connectionsFormed )
|
if( !m_connectionsFormed )
|
||||||
{
|
{
|
||||||
networkChanged();
|
connectionsChanged();
|
||||||
if( m_peripheralAccessAllowed ) m_node.invalidate();
|
if( m_peripheralAccessAllowed ) m_node.invalidate();
|
||||||
m_connectionsFormed = true;
|
m_connectionsFormed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void networkChanged()
|
public void connectionsChanged()
|
||||||
{
|
{
|
||||||
if( getWorld().isRemote ) return;
|
if( getWorld().isRemote ) return;
|
||||||
|
|
||||||
if( modemChanged() ) m_node.invalidate();
|
|
||||||
|
|
||||||
IBlockState state = getBlockState();
|
IBlockState state = getBlockState();
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
BlockPos current = getPos();
|
BlockPos current = getPos();
|
||||||
@ -511,11 +510,9 @@ public class TileCable extends TileModemBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean modemChanged()
|
public void modemChanged()
|
||||||
{
|
{
|
||||||
if( getWorld().isRemote ) return false;
|
if( getWorld().isRemote ) return;
|
||||||
|
|
||||||
boolean requiresUpdate = false;
|
|
||||||
|
|
||||||
PeripheralType type = getPeripheralType();
|
PeripheralType type = getPeripheralType();
|
||||||
if( type == PeripheralType.Cable )
|
if( type == PeripheralType.Cable )
|
||||||
@ -526,12 +523,10 @@ public class TileCable extends TileModemBase
|
|||||||
if( type != PeripheralType.WiredModemWithCable && m_peripheralAccessAllowed )
|
if( type != PeripheralType.WiredModemWithCable && m_peripheralAccessAllowed )
|
||||||
{
|
{
|
||||||
m_peripheralAccessAllowed = false;
|
m_peripheralAccessAllowed = false;
|
||||||
requiresUpdate = true;
|
m_node.invalidate();
|
||||||
markDirty();
|
markDirty();
|
||||||
updateAnim();
|
updateAnim();
|
||||||
}
|
}
|
||||||
|
|
||||||
return requiresUpdate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private stuff
|
// private stuff
|
||||||
|
@ -293,7 +293,8 @@ public class TileWiredModemFull extends TilePeripheralBase
|
|||||||
|
|
||||||
if( !m_connectionsFormed )
|
if( !m_connectionsFormed )
|
||||||
{
|
{
|
||||||
networkChanged();
|
connectionsChanged();
|
||||||
|
if( m_peripheralAccessAllowed ) node.invalidate();
|
||||||
m_connectionsFormed = true;
|
m_connectionsFormed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,7 +302,7 @@ public class TileWiredModemFull extends TilePeripheralBase
|
|||||||
super.update();
|
super.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void networkChanged()
|
private void connectionsChanged()
|
||||||
{
|
{
|
||||||
if( getWorld().isRemote ) return;
|
if( getWorld().isRemote ) return;
|
||||||
|
|
||||||
@ -318,8 +319,6 @@ public class TileWiredModemFull extends TilePeripheralBase
|
|||||||
// If we can connect to it then do so
|
// If we can connect to it then do so
|
||||||
node.connectTo( element.getNode() );
|
node.connectTo( element.getNode() );
|
||||||
}
|
}
|
||||||
|
|
||||||
node.invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private stuff
|
// private stuff
|
||||||
|
Loading…
x
Reference in New Issue
Block a user