Advertisement
Guest User

Untitled

a guest
Mar 24th, 2015
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.68 KB | None | 0 0
  1. package pl.asie.computronics.integration.enderio;
  2.  
  3. import dan200.computercraft.api.lua.ILuaContext;
  4. import dan200.computercraft.api.lua.LuaException;
  5. import dan200.computercraft.api.peripheral.IComputerAccess;
  6. import li.cil.oc.api.machine.Arguments;
  7. import li.cil.oc.api.machine.Callback;
  8. import li.cil.oc.api.machine.Context;
  9. import li.cil.oc.api.network.ManagedEnvironment;
  10. import li.cil.oc.api.prefab.DriverTileEntity;
  11. import net.minecraft.tileentity.TileEntity;
  12. import net.minecraft.world.World;
  13. import pl.asie.computronics.integration.CCMultiPeripheral;
  14. import pl.asie.computronics.integration.ManagedEnvironmentOCTile;
  15.  
  16. /**
  17.  * @author Vexatos
  18.  */
  19. public class DriverTest {
  20.  
  21.     public static class OCDriver extends DriverTileEntity {
  22.  
  23.         public class InternalManagedEnvironment extends ManagedEnvironmentOCTile<TileChatBox> {
  24.             public InternalManagedEnvironment(TileChatBox tile) {
  25.                 super(tile, "chat_box");
  26.             }
  27.  
  28.             @Override
  29.             public int priority() {
  30.                 return 1;
  31.             }
  32.  
  33.             @Callback(doc = "")
  34.             public Object[] say(Context c, Arguments a) {
  35.                 return new Object[] {};
  36.             }
  37.  
  38.             @Callback(doc = "")
  39.             public Object[] setDistance(Context c, Arguments a) {
  40.                 return new Object[] {};
  41.             }
  42.  
  43.             @Callback(doc = "")
  44.             public Object[] getDistance(Context c, Arguments a) {
  45.                 return new Object[] {};
  46.             }
  47.         }
  48.  
  49.         @Override
  50.         public Class<?> getTileEntityClass() {
  51.             return TileChatBox.class;
  52.         }
  53.  
  54.         @Override
  55.         public ManagedEnvironment createEnvironment(World world, int x, int y, int z) {
  56.             return new InternalManagedEnvironment(((TileChatBox) world.getTileEntity(x, y, z)));
  57.         }
  58.     }
  59.  
  60.     public static class CCDriver extends CCMultiPeripheral<TileChatBox> {
  61.  
  62.         public CCDriver() {
  63.         }
  64.  
  65.         public CCDriver(TileChatBox tile, World world, int x, int y, int z) {
  66.             super(tile, "chat_box", world, x, y, z);
  67.         }
  68.  
  69.         @Override
  70.         public int peripheralPriority() {
  71.             return 1;
  72.         }
  73.  
  74.         @Override
  75.         public CCMultiPeripheral getPeripheral(World world, int x, int y, int z, int side) {
  76.             TileEntity te = world.getTileEntity(x, y, z);
  77.             if(te != null && te instanceof TileChatBox) {
  78.                 return new CCDriver((TileChatBox) te, world, x, y, z);
  79.             }
  80.             return null;
  81.         }
  82.  
  83.         @Override
  84.         public String[] getMethodNames() {
  85.             return new String[] { "say", "setDistance", "getDistance" };
  86.         }
  87.  
  88.         @Override
  89.         public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
  90.             switch(method) {
  91.                 case 0: {
  92.                     return new Object[] {};
  93.                 }
  94.                 case 1: {
  95.                     return new Object[] {};
  96.                 }
  97.                 case 2: {
  98.                     return new Object[] {};
  99.                 }
  100.             }
  101.             return null;
  102.         }
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement