1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-11 19:03:03 +00:00

Provide a more direct way to get the related computer

Effectively shift extracting the computer away from Plethora into CC:T.
Ideally we wouldn't need this at all, but Plethora does some funky
things with tick timings.

See SquidDev-CC/plethora#125
This commit is contained in:
SquidDev
2018-07-08 22:48:50 +01:00
parent 45a189e834
commit 0bf13562b9
4 changed files with 34 additions and 4 deletions

View File

@@ -10,6 +10,8 @@ import dan200.computercraft.api.network.wired.IWiredNode;
import dan200.computercraft.api.network.wired.IWiredSender;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.core.computer.Computer;
import dan200.computercraft.core.computer.IComputerOwned;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -273,7 +275,7 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
throw new LuaException( "No peripheral: " + remoteName );
}
private static class RemotePeripheralWrapper implements IComputerAccess
private static class RemotePeripheralWrapper implements IComputerAccess, IComputerOwned
{
private final WiredModemElement m_element;
private final IPeripheral m_peripheral;
@@ -408,5 +410,12 @@ public abstract class WiredModemPeripheral extends ModemPeripheral implements IW
return m_element.getRemotePeripherals().get( name );
}
}
@Nullable
@Override
public Computer getComputer()
{
return m_computer instanceof IComputerOwned ? ((IComputerOwned) m_computer).getComputer() : null;
}
}
}