日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

typescript 使用_如何使用TypeScript轻松修改Minecraft

發(fā)布時(shí)間:2023/11/29 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 typescript 使用_如何使用TypeScript轻松修改Minecraft 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

typescript 使用

by Josh Wulf

通過喬什·沃爾夫(Josh Wulf)

如何使用TypeScript輕松修改Minecraft (How to modify Minecraft the easy way with TypeScript)

Usually, modifying Minecraft requires coding in Java, and a lot of scaffolding. Now you can write and share Minecraft mods using TypeScript/Javascript.

通常,修改Minecraft需要使用Java進(jìn)行編碼,并需要大量的腳手架。 現(xiàn)在,您可以使用TypeScript / Javascript編寫和共享Minecraft mod。

ScriptCraft is an open source JavaScript Minecraft modding library, and we’ve written support for TypeScript, and a bunch of tooling to create a familiar developer experience for those coming from JavaScript land (including Yeoman and NPM).

ScriptCraft是一個(gè)開放源代碼JavaScript Minecraft改裝庫,我們已經(jīng)編寫了對(duì)TypeScript的支持,以及許多工具,可為來自JavaScript領(lǐng)域(包括Yeoman和NPM)的開發(fā)人員創(chuàng)建熟悉的開發(fā)人員體驗(yàn)。

In this article I’ll walk you through getting set up and building your first TypeScript Minecraft mod in under an hour — as little as 20 minutes, depending on your internet connection.

在本文中,我將指導(dǎo)您在不到一個(gè)小時(shí)的時(shí)間內(nèi)完成設(shè)置并構(gòu)建您的第一個(gè)TypeScript Minecraft mod(取決于您的Internet連接,只需20分鐘)。

In this video (click here if the embed doesn’t work above) I show you how to write a basic Minecraft mod using TypeScript, and run it on your local computer with both a desktop and a mobile Minecraft server.

在此視頻中(如果無法正常使用, 請(qǐng)單擊此處 ),我將向您展示如何使用TypeScript編寫基本的Minecraft mod,并在具有臺(tái)式機(jī)和移動(dòng)Minecraft服務(wù)器的本地計(jì)算機(jī)上運(yùn)行它。

Below, I’ll walk you through the steps, with links to resources.

下面,我將引導(dǎo)您完成這些步驟,并提供指向資源的鏈接。

先決條件 (Prerequisites)

You’ll need some software installed on your computer, to run the Minecraft server and the tools for writing your plugin. Install all of the four following:

您需要在計(jì)算機(jī)上安裝一些軟件,才能運(yùn)行Minecraft服務(wù)器和用于編寫插件的工具。 安裝以下所有四個(gè):

  • Docker — a containerisation solution.

    Docker-一種容器化解決方案。

  • Node.js — a JavaScript execution engine and library.

    Node.js — JavaScript執(zhí)行引擎和庫。

  • Portainer — a web-based GUI for managing Docker containers.

    Portainer-用于管理Docker容器的基于Web的GUI。

  • Visual Studio Code — a code editor.

    Visual Studio代碼 -代碼編輯器。

我的世界客戶端 (Minecraft Client)

You need a Minecraft client to test your plugin.

您需要一個(gè)Minecraft 客戶端來測(cè)試您的插件。

Install at least one of the following:

安裝以下至少一項(xiàng):

  • Minecraft Java Edition — a desktop client, if you want to test against a Bukkit server.

    Minecraft Java Edition-如果要針對(duì)Bukkit服務(wù)器進(jìn)行測(cè)試,則為桌面客戶端。

  • Minecraft Pocket Edition — a mobile client, if you want to test against a Nukkit server (phone/tablet/Xbox). If you use this, you can use Minecraft Pocket Edition Bedrock Launcher to run the mobile client on your computer.

    Minecraft Pocket Edition-移動(dòng)客戶端,如果要在Nukkit服務(wù)器(電話/平板電腦/ Xbox)上進(jìn)行測(cè)試。 如果使用此功能,則可以使用Minecraft Pocket Edition Bedrock Launcher在計(jì)算機(jī)上運(yùn)行移動(dòng)客戶端。

安裝 (Installation)

Now that you have the prerequisites installed, it is time to install the tools for the server and for plugin development.

現(xiàn)在,您已經(jīng)安裝了先決條件,是時(shí)候安裝用于服務(wù)器和插件開發(fā)的工具了。

  • Run the following command:

    運(yùn)行以下命令:
  • npm i -g smac yo generator-sma-plugin typescript

    This will install four things on your computer:

    這將在您的計(jì)算機(jī)上安裝四件事:

    • smac— Scriptcraft Modular Architecture Controller, a program that runs Minecraft Servers for your plugins.

      smac — Scriptcraft模塊化體系結(jié)構(gòu)控制器,一個(gè)為您的插件運(yùn)行Minecraft服務(wù)器的程序。

    • yo — Yeoman, a scaffolding tool.

      yo — Yeoman ,腳手架工具。

    • generator-sma-plugin — a Yeoman plugin for generating a new Minecraft plugin using the Scriptcraft Modular Architecture.

      generator-sma-plugin —一個(gè)Yeoman插件,用于使用Scriptcraft模塊化體系結(jié)構(gòu)生成新的Minecraft插件。

    • typescript — the TypeScript transpiler, for converting TypeScript code into ES5 JavaScript that can run in Minecraft.

      typescript -打字稿transpiler,轉(zhuǎn)換打字稿代碼為ES5JavaScript可以在我的世界中運(yùn)行。

    創(chuàng)建一個(gè)新的插件 (Create a new plugin)

    Now that you have the toolset installed, create a new plugin by running this command:

    現(xiàn)在您已經(jīng)安裝了工具集,通過運(yùn)行以下命令來創(chuàng)建一個(gè)新插件:

    yo sma-plugin

    This starts the plugin wizard:

    這將啟動(dòng)插件向?qū)?#xff1a;

    ? yo sma-plugin_-----_ ╭──────────────────────────╮ | | │ Welcome to the │ |--(o)--| │ Scriptcraft SMA Plugin │ `---------′ │ generator by │ ( _′U`_ ) │ Magikcraft.io! │ /___A___\ /╰──────────────────────────╯ | ~ | __'.___.'__ ′ ` |° ′ Y `? Your package name (workspace)

    There is only one question you need to answer here — the name of your plugin. The wizard will create a new folder with the name of the plugin, and place the files for the new plugin in it.

    您只需在這里回答一個(gè)問題-插件的名稱。 該向?qū)⑹褂貌寮Q創(chuàng)建一個(gè)新文件夾,并將新插件的文件放入其中。

    This screencast shows you the process:

    該截屏視頻向您顯示了該過程:

    Scaffold a Minecraft plugin using MagikcraftMagikcraft.io allows you to write Minecraft plugins in TypeScript/JavaScript that will run on Desktop / Mobile.asciinema.org

    使用Magikcraft 搭建 Minecraft插件的腳手架 Magikcraft.io允許您以TypeScript / JavaScript編寫Minecraft插件,該插件將在臺(tái)式機(jī)/移動(dòng)設(shè)備上運(yùn)行。 asciinema.org

    Once the wizard completes, it emits a message similar to this (I chose the name my-sma-plugin in this example):

    向?qū)瓿珊?#xff0c;它會(huì)發(fā)出類似于以下的消息(在此示例中,我選擇名稱my-sma-plugin ):

    編輯您的新插件 (Edit your new plugin)

    Start Visual Studio Code and open the directory containing your new plugin.

    啟動(dòng)Visual Studio代碼,然后打開包含新插件的目錄。

    Here is a description of the files in your new plugin:

    這是新插件中文件的描述:

    • __tests__ — a directory containing unit tests for your plugin. These are run with Jasmine. Add more tests in here as you develop your plugin.

      __tests__ —包含插件的單元測(cè)試的目錄。 這些與茉莉一起運(yùn)行。 開發(fā)插件時(shí),請(qǐng)?jiān)诖颂幪砑痈鄿y(cè)試。

    • .vscode — settings for Visual Studio code.

      .vscode -Visual Studio代碼的設(shè)置。

    • autoload — any files in here are automatically executed when your plugin is enabled in the Minecraft server. Use this for initialisation tasks, registering event handlers, and so forth.

      autoload -在Minecraft服務(wù)器中啟用插件后,此處的所有文件都會(huì)自動(dòng)執(zhí)行。 將此用于初始化任務(wù),注冊(cè)事件處理程序等。

    • lib — A place for you to put files that should not be automatically loaded (or that are required from your autoloaded files). If your plugin provides functionality to other plugins, then you export that via lib/index.ts.

      lib —一個(gè)放置不應(yīng)自動(dòng)加載的文件(或自動(dòng)加載的文件所必需的文件)的地方。 如果您的插件提供了其他插件的功能,則可以通過lib/index.ts導(dǎo)出該插件。

    • node_modules — modules from npm are installed here. You cannot use modules from npm that use V8 APIs (like fs or http). Many of the features that you need are provided by the Scriptcraft API and by the @magikcraft/core package.

      node_modules -npm中的模塊已安裝在此處。 您不能使用npm中使用V8 API的模塊(例如fs或http)。 Scriptcraft API和@magikcraft/core 軟件包提供了您需要的許多功能。

    • .editorconfig — settings for the editor.

      .editorconfig編輯器的設(shè)置。

    • .gitattributes — settings for git.

      .gitattributes - git設(shè)置。

    • .gitignore — files to ignore for git.

      .gitignore忽略git文件。

    • .prettierrc — settings for code formatting.

      .prettierrc —代碼格式設(shè)置。

    • package-lock.json —versions of installed dependencies.

      package-lock.json已安裝依賴項(xiàng)的版本。

    • package.json —configuration for this plugin, including dependencies and scripts.

      package.json此插件的配置,包括依賴項(xiàng)和腳本。

    • README.md — instructions for developing and testing your plugin.

      README.md有關(guān)開發(fā)和測(cè)試插件的說明。

    • smac-nukkit.json — a configuration for running a Nukkit server with your plugin loaded.

      smac-nukkit.json —用于在加載插件的情況下運(yùn)行Nukkit服務(wù)器的配置。

    • smac.json — a configuration for running a Bukkit server with your plugin loaded.

      smac.json —用于在加載了插件的情況下運(yùn)行Bukkit服務(wù)器的配置。

    • tsconfig.json — the TypeScript configuration for transpiling your plugin to JavaScript.

      tsconfig.json —用于將插件轉(zhuǎn)換為JavaScript的TypeScript配置。

    Open autoload/index.ts:

    打開autoload/index.ts :

    This file is automatically executed when the plugin is loaded. Changes that you make here will be visible when you (re)load the plugin.

    加載插件后,將自動(dòng)執(zhí)行此文件。 (重新)加載插件時(shí),您在此處所做的更改將可見。

    啟動(dòng)開發(fā)服務(wù)器 (Start a development server)

    You can load your plugin in a development server. There are two servers that you can use — one for the desktop Java client, and the other for the mobile Pocket Edition client.

    您可以將插件加載到開發(fā)服務(wù)器中。 您可以使用兩臺(tái)服務(wù)器-一臺(tái)用于桌面Java客戶端,另一臺(tái)用于移動(dòng)Pocket Edition客戶端。

    啟動(dòng)桌面服務(wù)器 (Start the desktop server)

    Run this to start a desktop server:

    運(yùn)行此命令以啟動(dòng)桌面服務(wù)器:

    npm run start:bukkit

    This will:

    這將:

  • Pull the Bukkit server image from Docker Hub.

    從Docker Hub中提取Bukkit服務(wù)器映像。
  • Start the Bukkit server with your plugin loaded.

    在加載插件的情況下啟動(dòng)Bukkit服務(wù)器。
  • Start the TypeScript transpiler to transpile your code to ES5.

    啟動(dòng)TypeScript轉(zhuǎn)譯器,以將您的代碼轉(zhuǎn)譯到ES5。
  • You can now connect to the server with your desktop client. Click on Multiplayer then Direct Connect, then use the server address 127.0.0.1:

    現(xiàn)在,您可以使用桌面客戶??端連接到服務(wù)器。 單擊Multiplayer然后單擊Direct Connect ,然后使用服務(wù)器地址127.0.0.1 :

    啟動(dòng)移動(dòng)服務(wù)器 (Start the mobile server)

    Run this command to start a mobile server:

    運(yùn)行以下命令以啟動(dòng)移動(dòng)服務(wù)器:

    npm run start:nukkit

    This will:

    這將:

  • Pull the Nukkit server image from Docker Hub.

    從Docker Hub中提取Nukkit服務(wù)器映像。
  • Start the Nukkit server with your plugin loaded.

    在加載插件的情況下啟動(dòng)Nukkit服務(wù)器。
  • Start the TypeScript transpiler to transpile your code to ES5.

    啟動(dòng)TypeScript轉(zhuǎn)譯器,以將您的代碼轉(zhuǎn)譯到ES5。
  • You can now connect to the server with your pocket edition client. Click on Play then Servers, then add a server with the address 127.0.0.1:

    現(xiàn)在,您可以使用袖珍版客戶端連接到服務(wù)器。 單擊“ Play ,然后單擊Play Servers ,然后添加地址為127.0.0.1的服務(wù)器:

    重新加載對(duì)插件的更改 (Reload changes to your plugin)

    As you change your plugin and save the changed TypeScript, it will automatically be transpiled to JavaScript.

    在更改插件并保存更改的TypeScript時(shí),它將自動(dòng)轉(zhuǎn)換為JavaScript。

    To reload the changes in the development server, type the following in the server console:

    要在開發(fā)服務(wù)器中重新加載更改,請(qǐng)?jiān)诜?wù)器控制臺(tái)中鍵入以下內(nèi)容:

    ts onrefresh()

    See the screencast below to see what this looks like.

    請(qǐng)參見下面的截屏視頻,以了解其外觀。

    停止服務(wù)器 (Stop the server)

    To stop the server, type this command at the server console:

    要停止服務(wù)器,請(qǐng)?jiān)诜?wù)器控制臺(tái)上鍵入以下命令:

    smac stop

    See the screencast below to see what it looks like when you run this command.

    請(qǐng)參閱以下截屏視頻,以查看運(yùn)行此命令時(shí)的外觀。

    截屏視頻:開始,重新加載和停止 (Screencast: Start, Reload, and Stop)

    This screencast shows you starting the desktop server, reloading the plugin code, and also stopping the development server.

    該截屏視頻顯示啟動(dòng)桌面服務(wù)器,重新加載插件代碼以及停止開發(fā)服務(wù)器。

    Start a Magikcraft Development ServerStart a Magikcraft Development Server.asciinema.org

    啟動(dòng)Magikcraft開發(fā)服務(wù)器 啟動(dòng)Magikcraft開發(fā)服務(wù)器。 asciinema.org

    更多資源 (Further Resources)

    • Magikcraft on GitHub

      GitHub上的Magikcraft

    • Magikcraft on YouTube

      YouTube上的Magikcraft

    • MCT1 Source Code (Example Plugin)

      MCT1源代碼(示例插件)

    • ScriptCraft on GitHub

      GitHub上的ScriptCraft

    • Bukkit API Docs

      Bukkit API文件

    翻譯自: https://www.freecodecamp.org/news/how-to-mod-minecraft-without-java-f076ddaec01c/

    typescript 使用

    總結(jié)

    以上是生活随笔為你收集整理的typescript 使用_如何使用TypeScript轻松修改Minecraft的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 免费黄网站在线看 | 青青草国产在线 | 色综合啪啪 | 各种含道具高h调教1v1男男 | 日本四虎影院 | 久久久精品日本 | 欧美巨乳在线观看 | 夜夜躁狠狠躁日日躁av | 久久艹在线视频 | 国产精品字幕 | 国产第一页在线 | 国产丝袜在线播放 | 五十路在线观看 | 在线看污片 | 亚洲一级Av无码毛片久久精品 | 动漫涩涩免费网站在线看 | 青在线视频 | 色免费看 | 精品国产综合 | 三上悠亚中文字幕在线播放 | 在线观看小视频 | 亚洲激情自拍偷拍 | 欧美日韩99 | 中文字幕欧美另类精品亚洲 | 日韩成人免费 | 黑人巨大猛烈捣出白浆 | av黄色在线播放 | 青青草精品在线视频 | 美女又爽又黄 | 狠狠躁夜夜躁人人爽视频 | 99综合视频| 欧美成人a∨高清免费观看 国产精品999视频 | 日韩欧美视频在线免费观看 | 亚洲乱码国产乱码精品精剪 | 中文字幕免费高清 | 狠狠a| av在线小说 | 影音先锋人妻啪啪av资源网站 | 免费国产一区 | 中文区中文字幕免费看 | 麻豆成人久久精品一区二区三区 | 内射合集对白在线 | а中文在线天堂 | 97人人模人人爽人人少妇 | 女生脱裤子让男生捅 | 日韩亚洲欧美在线观看 | a级在线观看 | 亚洲国产日韩欧美一区二区三区 | 一本大道av伊人久久综合 | 丝袜av电影| 依人成人| 欧美日韩国产一区二区三区在线观看 | 国产一级黄色av | 久久精品香蕉 | 又骚又黄的视频 | 尤物在线观看视频 | 天堂视频在线免费观看 | 黄色三极片 | 国产精品一卡二卡在线观看 | 亚洲精品888| 青青草精品视频 | 国产美女三级无套内谢 | 人与禽性7777777 | 欧美大片黄 | 一级片特黄| 亚洲ⅴ国产v天堂a无码二区 | 精品黑人一区二区三区国语馆 | 三级a做爰全过程 | 涩涩在线观看 | 91老师片黄在线观看 | 日日操夜夜操天天操 | 182tv午夜福利在线观看 | 中国美女黄色一级片 | 不卡视频一区 | 91精品视频一区二区三区 | 免费看日批视频 | 国产亚洲性欧美日韩在线观看软件 | www.4hu95.com四虎 极品在线视频 | 欧美视频91| 日本一二三区在线视频 | eeuss鲁丝片一区二区三区 | 97干干| 国产青青草在线 | 天天综合久久综合 | 中文字幕xxx | 国产女人高潮毛片 | 台湾a级艳片潘金莲 | 九九九热精品 | 国产在线一二三 | 黄页网站免费观看 | 久久色视频 | 久久激情网站 | 日韩精品无码一区二区三区 | 影音先锋亚洲成aⅴ人在 | 精品国产区 | 亚洲精品一区二区在线 | 大香蕉精品一区 | 欧美一区二区三区四区视频 | 91九色国产|