1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-22 08:04:49 +00:00
This commit is contained in:
Devan-Kerman
2020-08-29 18:01:01 -05:00
parent 605e1f6b9b
commit 621bc526be
757 changed files with 23755 additions and 74210 deletions

View File

@@ -1,86 +0,0 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.shared.computer.blocks;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import javax.annotation.Nonnull;
public class ComputerPeripheral implements IPeripheral
{
private final String m_type;
private final ComputerProxy m_computer;
public ComputerPeripheral( String type, ComputerProxy computer )
{
m_type = type;
m_computer = computer;
}
// IPeripheral implementation
@Nonnull
@Override
public String getType()
{
return m_type;
}
@Nonnull
@Override
public String[] getMethodNames()
{
return new String[] {
"turnOn",
"shutdown",
"reboot",
"getID",
"isOn",
"getLabel",
};
}
@Override
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments )
{
switch( method )
{
case 0: // turnOn
m_computer.turnOn();
return null;
case 1: // shutdown
m_computer.shutdown();
return null;
case 2: // reboot
m_computer.reboot();
return null;
case 3: // getID
return new Object[] { m_computer.assignID() };
case 4: // isOn
return new Object[] { m_computer.isOn() };
case 5: // getLabel
return new Object[] { m_computer.getLabel() };
default:
return null;
}
}
@Override
public boolean equals( IPeripheral other )
{
return other != null && other.getClass() == getClass();
}
@Nonnull
@Override
public Object getTarget()
{
return m_computer.getTile();
}
}