mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-28 16:22:18 +00:00
Provide .getNameLocal on modems
This provides the local modem's name on the remote network. Let's be honest, I'll probably end up renaming this soon.
This commit is contained in:
parent
a95893b823
commit
984d358930
@ -108,10 +108,11 @@ public class TileCable extends TileModemBase
|
|||||||
m_node = m_cable.getNode();
|
m_node = m_cable.getNode();
|
||||||
return new WiredModemPeripheral( m_cable )
|
return new WiredModemPeripheral( m_cable )
|
||||||
{
|
{
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected boolean canSeePeripheral( @Nonnull String peripheralName )
|
protected WiredModemLocalPeripheral getLocalPeripheral()
|
||||||
{
|
{
|
||||||
return !peripheralName.equals( m_peripheral.getConnectedName() );
|
return m_peripheral;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -401,12 +401,14 @@ public class TileWiredModemFull extends TilePeripheralBase
|
|||||||
WiredModemPeripheral peripheral = m_modems[side.ordinal()];
|
WiredModemPeripheral peripheral = m_modems[side.ordinal()];
|
||||||
if( peripheral == null )
|
if( peripheral == null )
|
||||||
{
|
{
|
||||||
|
WiredModemLocalPeripheral localPeripheral = m_peripherals[side.ordinal()];
|
||||||
peripheral = m_modems[side.ordinal()] = new WiredModemPeripheral( m_element )
|
peripheral = m_modems[side.ordinal()] = new WiredModemPeripheral( m_element )
|
||||||
{
|
{
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected boolean canSeePeripheral( @Nonnull String peripheralName )
|
protected WiredModemLocalPeripheral getLocalPeripheral()
|
||||||
{
|
{
|
||||||
return !peripheralName.equals( m_peripherals[side.ordinal()].getConnectedName() );
|
return localPeripheral;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -56,7 +56,8 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
|||||||
return modem.getWorld();
|
return modem.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean canSeePeripheral( @Nonnull String peripheralName );
|
@Nonnull
|
||||||
|
protected abstract WiredModemLocalPeripheral getLocalPeripheral();
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region IPeripheral
|
//region IPeripheral
|
||||||
@ -65,13 +66,14 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
|||||||
public String[] getMethodNames()
|
public String[] getMethodNames()
|
||||||
{
|
{
|
||||||
String[] methods = super.getMethodNames();
|
String[] methods = super.getMethodNames();
|
||||||
String[] newMethods = new String[methods.length + 5];
|
String[] newMethods = new String[methods.length + 6];
|
||||||
System.arraycopy( methods, 0, newMethods, 0, methods.length );
|
System.arraycopy( methods, 0, newMethods, 0, methods.length );
|
||||||
newMethods[methods.length] = "getNamesRemote";
|
newMethods[methods.length] = "getNamesRemote";
|
||||||
newMethods[methods.length + 1] = "isPresentRemote";
|
newMethods[methods.length + 1] = "isPresentRemote";
|
||||||
newMethods[methods.length + 2] = "getTypeRemote";
|
newMethods[methods.length + 2] = "getTypeRemote";
|
||||||
newMethods[methods.length + 3] = "getMethodsRemote";
|
newMethods[methods.length + 3] = "getMethodsRemote";
|
||||||
newMethods[methods.length + 4] = "callRemote";
|
newMethods[methods.length + 4] = "callRemote";
|
||||||
|
newMethods[methods.length + 5] = "getNameLocal";
|
||||||
return newMethods;
|
return newMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +137,12 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
|||||||
System.arraycopy( arguments, 2, methodArgs, 0, arguments.length - 2 );
|
System.arraycopy( arguments, 2, methodArgs, 0, arguments.length - 2 );
|
||||||
return callMethodRemote( remoteName, context, methodName, methodArgs );
|
return callMethodRemote( remoteName, context, methodName, methodArgs );
|
||||||
}
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
// getNameLocal
|
||||||
|
String local = getLocalPeripheral().getConnectedName();
|
||||||
|
return local == null ? null : new Object[]{ local };
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// The regular modem methods
|
// The regular modem methods
|
||||||
@ -217,7 +225,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
|
|||||||
|
|
||||||
private void attachPeripheralImpl( String periphName, IPeripheral peripheral )
|
private void attachPeripheralImpl( String periphName, IPeripheral peripheral )
|
||||||
{
|
{
|
||||||
if( !peripheralWrappers.containsKey( periphName ) && canSeePeripheral( periphName ) )
|
if( !peripheralWrappers.containsKey( periphName ) && !periphName.equals( getLocalPeripheral().getConnectedName() ) )
|
||||||
{
|
{
|
||||||
RemotePeripheralWrapper wrapper = new RemotePeripheralWrapper( modem, peripheral, getComputer(), periphName );
|
RemotePeripheralWrapper wrapper = new RemotePeripheralWrapper( modem, peripheral, getComputer(), periphName );
|
||||||
peripheralWrappers.put( periphName, wrapper );
|
peripheralWrappers.put( periphName, wrapper );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user