@Override @Method(modid = ComputerCraft.MOD_ID) public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { if (method == 0) return comp_Dial(arguments); else if (method == 1) getPortalController().deconstructConnection(); else if (method == 2) return comp_DialStored(arguments); else if (method == 3) return comp_GetStoredName(arguments); else if (method == 4) return comp_GetStoredGlyph(arguments); else if (method == 5) return new Object[] { glyphList.size() }; return null; }
@Override @Method(modid = "CoFHCore") public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { if(getConsumingSides().contains(from)) { double toAdd = (int)Math.min(getMaxEnergy()-getEnergy(), maxReceive* general.FROM_TE); if(!simulate) { setEnergy(getEnergy() + toAdd); } return (int)Math.round(toAdd* general.TO_TE); } return 0; }
@Method(modid = "IC2") public void register() { if(!worldObj.isRemote) { TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); if(registered != this) { if(registered instanceof IEnergyTile) { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); } else if(registered == null) { MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); ic2Registered = true; } } } }
@Override @Method(modid = "Waila") public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { TileEntity tile = accessor.getTileEntity(); if(tile instanceof TileEntityInductionCell) { currenttip.set(0, EnumColor.WHITE + ((TileEntityInductionCell)tile).getInventoryName()); } else if(tile instanceof TileEntityInductionProvider) { currenttip.set(0, EnumColor.WHITE + ((TileEntityInductionProvider)tile).getInventoryName()); } else if(tile instanceof TileEntityFactory) { currenttip.set(0, EnumColor.WHITE + ((TileEntityFactory)tile).getInventoryName()); } return currenttip; }
@Override @Method(modid = "ComputerCraft") public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException { switch(method) { case 0: return new Object[] {getEnergy()}; case 1: return new Object[] {operatingTicks}; case 2: return new Object[] {isActive}; case 3: return new Object[] {facing}; case 4: return new Object[] {canOperate(getRecipe())}; case 5: return new Object[] {getMaxEnergy()}; case 6: return new Object[] {getMaxEnergy()-getEnergy()}; default: Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID()); return new Object[] {"Unknown command."}; } }
@Override @Method(modid = "ComputerCraft") public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException { switch(method) { case 0: return new Object[] {electricityStored}; case 1: return new Object[] {output}; case 2: return new Object[] {BASE_MAX_ENERGY}; case 3: return new Object[] {(BASE_MAX_ENERGY -electricityStored)}; case 4: return new Object[] {bioFuelSlot.fluidStored}; case 5: return new Object[] {bioFuelSlot.MAX_FLUID-bioFuelSlot.fluidStored}; default: Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID()); return null; } }
@Override @Method(modid = "IC2") public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { if(getInv() == null) { return false; } return getInv().acceptsEnergyFrom(emitter, direction); }
@Override @Method(modid = "ComputerCraft") public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException { if(getInv() == null) { return new Object[] {}; } return getInv().callMethod(computer, context, method, arguments); }
@Override @Method(modid = "IC2") public int addEnergy(int amount) { setEnergy(getEnergy() + amount*general.FROM_IC2); return (int)Math.round(getEnergy()*general.TO_IC2); }
@Override @Method(modid = "IC2") public double injectEnergy(ForgeDirection direction, double amount, double voltage) { if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof ITransmitterTile) { return amount; } return amount-transferEnergyToAcceptor(direction, amount*general.FROM_IC2)*general.TO_IC2; }
@Override @Method(modid = ComputerCraft.MOD_ID) public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception { if (method == 0) return new Object[] { stack != null ? Item.getIdFromItem(stack.getItem()) : 0 }; else if (method == 1) return new Object[] { stack != null ? stack.stackSize : 0 }; else if (method == 2) return new Object[] { stack != null }; else if (method == 3) return new Object[] { isSending }; return null; }
@Override @Method(modid = "ComputerCraft") public String getType() { if(getInv() == null) { return null; } return getInv().getType(); }
@Override @Method(modid = "CoFHCore") public boolean canConnectEnergy(ForgeDirection from) { if(getInv() == null) { return false; } return getInv().canConnectEnergy(from); }
@Override @Method(modid = "ComputerCraft") public IPeripheral getPeripheral(World world, int x, int y, int z, int side) { TileEntity te = world.getTileEntity(x, y, z); if(te != null && te instanceof IPeripheral) { return (IPeripheral)te; } return null; }
@Override @Method(modid = "ComputerCraft") public void detach(IComputerAccess computer) { if(getInv() == null) { return; } getInv().detach(computer); }
@Override @Method(modid = "IC2") public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { if(getInv() == null) { return amount; } return getInv().injectEnergy(directionFrom, amount, voltage); }
@Override @Method(modid = ComputerCraft.MOD_ID) public IPeripheral getPeripheral(World world, int x, int y, int z, int side) { TileEntity t = world.getTileEntity(x, y, z); if (t != null && (t instanceof TileController || t instanceof TileNetworkInterface || t instanceof TileDialingDevice || t instanceof TileTransferEnergy || t instanceof TileTransferFluid || t instanceof TileTransferItem)) return (IPeripheral) t; return null; }
@Method(modid = "IC2") public static void addIC2BronzeRecipe() { try { Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, StackUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); } catch(Exception e) {} }
@Method(modid = "ComputerCraft") public void loadCCPeripheralProviders() { try { ComputerCraftAPI.registerPeripheralProvider((BlockMachine) MekanismBlocks.MachineBlock); } catch(Exception ex) {} }
@Override @Method(modid = "ComputerCraft") public void detach(IComputerAccess computer) {}
@Override @Method(modid = "IC2") public double getDemandedEnergy() { return (getMaxEnergy() - getEnergy())*general.TO_IC2; }
@Override @Method(modid = "Waila") public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { return currenttip; }
@Override @Method(modid = "IC2") public double getOfferedEnergy() { return Math.min(getEnergy(), getMaxOutput())*general.TO_IC2; }
@Override @Method(modid = "ComputerCraft") public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException { if(getReactor() == null || !getReactor().isFormed()) { return new Object[] {"Unformed."}; } switch(method) { case 0: return new Object[] {getReactor().isBurning()}; case 1: return new Object[] {getReactor().getPlasmaTemp() >= getReactor().getIgnitionTemperature(activeCooled)}; case 2: return new Object[] {getReactor().getPlasmaTemp()}; case 3: return new Object[] {getReactor().getMaxPlasmaTemperature(activeCooled)}; case 4: return new Object[] {getReactor().getCaseTemp()}; case 5: return new Object[] {getReactor().getMaxCasingTemperature(activeCooled)}; case 6: return new Object[] {getReactor().getInjectionRate()}; case 7: if(arguments[0] instanceof Integer) { getReactor().setInjectionRate((Integer)arguments[0]); return new Object[] {"Injection rate set."}; } else { return new Object[] {"Invalid parameters."}; } case 8: return new Object[] {(getReactor().getDeuteriumTank().getStored() >= getReactor().getInjectionRate()/2) && (getReactor().getTritiumTank().getStored() >= getReactor().getInjectionRate()/2)}; default: Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID()); return new Object[] {"Unknown command."}; } }
@Method(modid=REFERENCE.EAPIMODID) @Override public void registerRecipeHandler(IRecipeHandler handler) { FeatureRecipe.handlers.add(handler); LogHelper.info("Registered a new recipe handler: " + handler.getRecipeName()); }
@Override @Method(modid = "CoFHCore") public int getEnergyStored(ForgeDirection from) { return (int)Math.round(getEnergy()* general.TO_TE); }
@Override @Method(modid = ComputerCraft.MOD_ID) public void attach(IComputerAccess computer) { }
@Override @Method(modid = ComputerCraft.MOD_ID) public void detach(IComputerAccess computer) { }
@Override @Method(modid = "IC2") public double getMaxCharge(ItemStack itemStack) { return 0; }
@Override @Method(modid = "IC2") public boolean isTeleporterCompatible(ForgeDirection side) { return getOutputtingSides().contains(side); }
@Override @Method(modid = ComputerCraft.MOD_ID) public boolean equals(IPeripheral other) { return other == this; }
@Override @Method(modid = "ComputerCraft") public void attach(IComputerAccess computer) {}
@Override @Method(modid = "IC2") public boolean wrenchCanRemove(EntityPlayer entityPlayer) { return true; }
@Override @Method(modid = "Botania") public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer player, ItemStack item) { return BotaniaCompatibility.stargate; }
@Override @Method(modid = "IC2") public IElectricItemManager getManager(ItemStack itemStack) { return IC2ItemManager.getManager(this); }
@Override @Method(modid = ComputerCraft.MOD_ID) public String getType() { return "ep_dialling_device"; }
@Callback(doc = "function():boolean -- Terminates any active connection.") @Method(modid = OpenComputers.MOD_ID) public Object[] terminate(Context context, Arguments args) { getPortalController().deconstructConnection(); return new Object[] { true }; }