mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-23 21:39:40 +00:00
Added (configurable) Configurator mode sneak-scroll toggle
This commit is contained in:
1 parent
4d12018779
commit
5c956f47de
30 files changed
+97
-26
No files matched your search
@@ -0,0 +1,85 @@
|
||||
package mekanism.common.integration.computer;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.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;
|
||||
import dan200.computercraft.api.peripheral.IPeripheralProvider;
|
||||
|
||||
/**
|
||||
* Created by aidancbrady on 7/20/15.
|
||||
*/
|
||||
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
||||
public class CCPeripheral implements IPeripheral
|
||||
{
|
||||
public IComputerIntegration computerTile;
|
||||
|
||||
public CCPeripheral(IComputerIntegration tile)
|
||||
{
|
||||
computerTile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
public String getType()
|
||||
{
|
||||
return computerTile.getName();
|
||||
}
|
||||
|
||||
@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."};
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
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;
|
||||
}
|
||||
|
||||
public static class CCPeripheralProvider implements IPeripheralProvider
|
||||
{
|
||||
@Override
|
||||
public IPeripheral getPeripheral(World world, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
|
||||
if(te != null && te instanceof IComputerIntegration)
|
||||
{
|
||||
return new CCPeripheral((IComputerIntegration)te);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user