mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 15:46:01 +00:00
Cleaner CC support with a separate peripheral handler
This commit is contained in:
1 parent
728e497dd1
commit
c7fe1f86eb
18 files changed
+132
-654
No files matched your search
@@ -0,0 +1,62 @@
|
||||
package mekanism.common.integration;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
/**
|
||||
* Created by aidancbrady on 7/20/15.
|
||||
*/
|
||||
public class CCPeripheral implements IPeripheral
|
||||
{
|
||||
public IComputerIntegration computerTile;
|
||||
|
||||
public CCPeripheral(IComputerIntegration tile)
|
||||
{
|
||||
computerTile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public String getType()
|
||||
{
|
||||
return computerTile.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
return computerTile.getMethods();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
|
||||
{
|
||||
try {
|
||||
return computerTile.invoke(method, arguments);
|
||||
} catch(NoSuchMethodException e) {
|
||||
return new Object[] {"Unknown command."};
|
||||
} finally {
|
||||
return new Object[] {"Error."};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public void attach(IComputerAccess computer) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public void detach(IComputerAccess computer) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public boolean equals(IPeripheral other)
|
||||
{
|
||||
return this == other;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user