最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

【中英對(duì)譯】MCEdit 2 Documentation(2)

2019-06-23 17:27 作者:Flinx_方凌旭  | 我要投稿

文檔源地址:https://mcedit2.readthedocs.io/en/latest/

基于百度翻譯的翻譯結(jié)果逐句核對(duì)修改。


MCEdit 2 Plugin Development

MCEdit 2插件開發(fā)

A plugin for MCEdit 2 is a Python module that defines one or more Plugin classes and then registers them with MCEdit. These classes are instantiated once for each Editor Session and called on by MCEdit in response to various user actions.

mcedit 2的插件是一個(gè)python模塊,它定義一個(gè)或多個(gè)插件類,然后將它們注冊(cè)到mcedit。這些類為每個(gè)編輯器會(huì)話實(shí)例化一次,并由mcedit響應(yīng)各種用戶操作調(diào)用。

·Plugin basics?插件基礎(chǔ)

··Plugin Structure?插件結(jié)構(gòu)

··Undo History?撤消歷史記錄

··Registering Plugin Classes?正在注冊(cè)插件類

·Plugin Tasks?插件任務(wù)

··World Dimensions?世界維度

··Editing Blocks?編輯塊

··Editing Entities?編輯實(shí)體

··Creating entities?創(chuàng)建實(shí)體

·Types of plugins?插件類型

··Command Plugins?命令插件

··Simple Commands?簡(jiǎn)單命令

···Simple Command Inputs?簡(jiǎn)單命令輸入

····Input Types?輸入類型

··Tool Plugins?工具插件

···Mouse Handlers?鼠標(biāo)處理程序

··Brush Shape Plugins?畫筆形狀插件

···As a boolean array?作為布爾數(shù)組

···As a Selection object?作為選擇對(duì)象

·Plugin Examples?插件示例

··Simple Options?簡(jiǎn)單選項(xiàng)

··World Editing?世界編輯



Types of plugins?插件類型

Command Plugins?are the simplest kind of plugin and the most similar to MCEdit 1 “filter” plugins. A command plugin adds a new menu item to the “Plugins” menu which calls the plugin’s code when selected. Command plugins are free to edit the world and to display windows, dialog boxes, and other UI elements.

命令插件是最簡(jiǎn)單的插件類型,與MCEdit?1“filter”插件最相似。一個(gè)命令插件將一個(gè)新的菜單項(xiàng)添加到“插件”菜單中,該菜單在選中時(shí)調(diào)用插件的代碼。命令插件可以自由編輯世界并顯示窗口、對(duì)話框和其他UI元素。

Tool Plugins?are a way to add new editor tools. Each editor tool will display a panel of options while it is selected, and will respond to mouse actions within the world view such as clicking and dragging. Tool plugins are free to edit the world and to display windows, dialog boxes, and other UI elements. Before creating a Tool plugin, consider if what you want to accomplish can be done using a?Brush Mode Plugins?instead.

工具插件是添加新編輯器工具的一種方法。每個(gè)編輯器工具在被選中時(shí)將顯示一個(gè)選項(xiàng)面板,并響應(yīng)世界視圖中的鼠標(biāo)操作,如單擊和拖動(dòng)。工具插件可以自由編輯世界并顯示窗口、對(duì)話框和其他UI元素。在創(chuàng)建工具插件之前,請(qǐng)考慮您想要完成的工作是否可以使用畫筆模式插件來完成。

Brush Shape Plugins?are used to provide new shapes for use with the Brush and Selection tool (and any other tools that may ask the user to choose a shape). Shape plugins may not edit the world and may only return a SelectionBox object that defines the shape.

畫筆形狀插件用于提供新的形狀,以便與畫筆選擇工具(以及任何其他可能要求用戶選擇形狀的工具)一起使用。形狀插件不能編輯世界,只能返回定義形狀的SelectionBox對(duì)象。

Brush Mode Plugins?are used to provide new actions for use with the Brush tool. For instance, you could make a Brush Mode that sets the name of any entity within the affected area to “Dinnerbone”. Brush modes are expected to edit the world, and since the?undo-history?is managed by the Brush tool, you do not need to manage it yourself.

畫筆模式插件用于為畫筆工具提供新的操作。例如,可以創(chuàng)建一個(gè)畫筆模式,將受影響區(qū)域內(nèi)的任何實(shí)體的名稱設(shè)置為“Dinnerbone”。畫筆模式可以編輯世界,由于撤消歷史由畫筆工具管理,因此您不需要自己管理它。

Inspector Plugins?are used to create user interfaces for editing entities and tile entities. Since inspectors for all of the base Minecraft entities are included with MCEdit, this plugin type is intended for adding support for Minecraft mods. For instance, a plugin for inspecting chests from the IronChests mod would inherit from the base Chest inspector and change the number of slots in the chest.

檢查器插件用于創(chuàng)建用于編輯實(shí)體和Tile實(shí)體的用戶界面。由于所有基礎(chǔ)Minecraft實(shí)體的檢查器都包含在MCEdit中,因此此插件類型旨在添加對(duì)Minecraft mods的支持。例如,一個(gè)用于檢查來自鐵箱mod的箱子的插件將繼承自基本的箱子檢查器,并更改箱子中的槽數(shù)。

Tile Entity Plugins?are a low-level plugin that does not directly interact with the user. These plugins provide TileEntityRef classes that wrap the underlying NBT structures for tile entities and may add meaning to numerical constants, validate tag types, or expose ItemStacks that are stored in a nonstandard manner. These plugins are expected to accompany the Inspector plugins for mod-added tile entities.

Tile實(shí)體插件是一個(gè)低級(jí)插件,不直接與用戶交互。這些插件提供TileEntityRef類,這些類包裝Tile實(shí)體的基礎(chǔ)NBT結(jié)構(gòu),并可能為以非標(biāo)準(zhǔn)方式存儲(chǔ)的數(shù)字常量、驗(yàn)證標(biāo)記類型或公開物品堆棧添加含義。這些插件將與Inspector插件一起用于mod添加的?Tile實(shí)體。

?The future of?Generate Plugins?is uncertain.

生成插件的未來是不確定的。

·Command Plugins?命令插件

·Simple Commands?簡(jiǎn)單命令

··Simple Command Inputs?簡(jiǎn)單命令輸入

···Input Types?輸入類型

·Tool Plugins?工具插件

··Mouse Handlers?鼠標(biāo)處理程序

·Brush Shape Plugins?畫筆形狀插件

··As a boolean array?作為布爾數(shù)組

··As a Selection object?作為選擇對(duì)象

Command Plugins?命令插件

A command plugin will add a new menu command to the application’s Plugins menu, and call a specified function when the menu command is selected. This is the simplest and most straightforward type of plugin, and is the most similar to MCEdit 1.0’s “filter” plugins.

命令插件將向應(yīng)用程序的插件菜單添加新的菜單命令,并在菜單命令選擇時(shí)調(diào)用指定的函數(shù)。這是最簡(jiǎn)單和最直接的插件類型,MCEdit1.0的“過濾器”插件最相似。

To define a command plugin, create a class that inherits from CommandPlugin. Implement the?__init__?function to call?self.addMenuItem?for each user-selectable command, and also implement the functions that correspond to each menu item.

要定義一個(gè)命令插件,請(qǐng)創(chuàng)建從CommandPlugin繼承的類。實(shí)現(xiàn)__init__函數(shù),為每個(gè)用戶可選擇的命令調(diào)用self.addMenuItem,并實(shí)現(xiàn)與每個(gè)菜單項(xiàng)對(duì)應(yīng)的功能。

A basic command plugin:

一個(gè)基本命令插件:

from?mcedit2.plugins?import?registerPluginCommand, CommandPluginfrom?PySide?import?QtGui

@registerPluginCommandclass?ExampleCommand(CommandPlugin):

????def?__init__(self, editorSession):

????????super(ExampleCommand, self).__init__(editorSession)

????????self.addMenuItem("Example Command", self.perform)

?

????def?perform():

????????dimension =?self.editorSession.currentDimension

????????chunkCount =?dimension.chunkCount()

?

????????QtGui.QMessageBox.information(None, ????????# messagebox parent (None for app-modal)

????????????"Example Command", ?????????????????????# messagebox title

????????????"The Example Command was successful. "??# messagebox text

????????????"The current dimension contains "

????????????"%d?chunks") %?chunkCount)

You can do nearly anything you want in the?perform()?function. The currently edited dimension can be accessed as?self.editorSession.currentDimension. See?plugin_tasks?for an overview of the dimension object. If you need to modify the world, be sure to read?undo-history?first.

perform()函數(shù)中,幾乎可以執(zhí)行任何操作。當(dāng)前編輯的維度可以作為self.editorSession.currentDimension訪問。有關(guān)維度對(duì)象的概述,請(qǐng)參見plugin_tasks。如果您需要修改世界,請(qǐng)務(wù)必先閱讀undo-history撤消歷史記錄。

Simple Commands?簡(jiǎn)單命令

MCEdit 1.0’s “filter” plugins all follow the same pattern: They prompt the user for some inputs, and then call a?perform()?function which is given the current world, the current selection, and the inputs provided by the user.?SimpleCommandPlugin?fills the same role in MCEdit 2.0.

MCEdit 1.0的“filter”插件都遵循相同的模式:它們提示用戶輸入一些信息,然后調(diào)用一個(gè)perform()函數(shù),該函數(shù)給出當(dāng)前世界、當(dāng)前選擇以及用戶提供的輸入。SimpleCommandPlugin在MCEdit 2.0中扮演相同的角色。

This class automatically adds a menu item to the Plugins menu. When the item is chosen, it opens a dialog box with a list of options defined by the class; when the user presses “OK”, it calls a?perform()?function with those same arguments. The options to present are defined by a Python data structure, making it possible to create a simple UI for your plugin without having to learn any of Qt’s UI widgets.

此類會(huì)自動(dòng)將菜單項(xiàng)添加到插件菜單中。當(dāng)該項(xiàng)選擇時(shí),它將打開一個(gè)對(duì)話框,其中包含由類定義的選項(xiàng)列表;當(dāng)用戶按“確定”時(shí),它將使用這些相同的參數(shù)調(diào)用perform()函數(shù)。要顯示的選項(xiàng)是由一個(gè)Python數(shù)據(jù)結(jié)構(gòu)定義的,這樣就可以為您的插件創(chuàng)建一個(gè)簡(jiǎn)單的UI,而無需學(xué)習(xí)Qt的任何UI部件。

SimpleCommandPlugin?also manages the undo history automatically. There is no need to call?beginCommand()?here, and to do so is an error.

SimpleCommandPlugin還自動(dòng)管理撤消歷史記錄。這里不需要調(diào)用beginCommand(),這樣做是一個(gè)錯(cuò)誤。

A minimal SimpleCommandPlugin:

一個(gè)最小SimpleCommandPlugin:

from?mcedit2.plugins?import?registerPluginCommand, SimpleCommandPlugin

@registerPluginCommandclass?SimpleOptionsDemo(SimpleCommandPlugin):

????displayName =?"Simple Options Demo"

?

????options =?[

????????{

????????????'type': 'int',

????????????'value': 0,

????????????'min': 0,

????????????'max': 100,

????????????'name': 'myIntOption',

????????????'text': 'Integer Option: ',

????????},

????]

?

????def?perform(self, dimension, selection, options):

????????print("Option value: %d"?%?options['myIntOption'])

????????print("Selection volume: %s"?%?selection.volume)

????????print("Chunks in dimension: %d"?%?dimension.chunkCount())

This plugin will display a dialog with a single integer input, and print the value from that input to the console along with info about the current selection and dimension.

這個(gè)插件將顯示一個(gè)帶有單個(gè)整數(shù)輸入的對(duì)話框,并將該輸入以及當(dāng)前選擇和維度的信息打印到控制臺(tái)。

Simple Command Inputs?簡(jiǎn)單命令輸入

Each element in the plugin’s?options?list is a?dict?that defines a single input. All

option elements must have at least these keys:

插件options選項(xiàng)列表中的每個(gè)元素都是定義單個(gè)輸入的dict。所有選項(xiàng)元素必須至少具有以下鍵:

·type: Defines which kind of input to create.

·類型:定義要?jiǎng)?chuàng)建的輸入類型。

·name: The internal name for this input. You will use this to access the input’s value,?and MCEdit will use it to automatically save the last used value.

·名稱:此輸入的內(nèi)部名稱。您將使用它來訪問輸入的值,MCEdit會(huì)使用它自動(dòng)保存上次使用的值。

·text: The caption to display alongside this input. Should describe what the input does.

·文本:顯示在此輸入旁邊的標(biāo)題。應(yīng)該描述輸入的作用。

·value: An initial value to show in the input. Optional.

·值:要在輸入中顯示的初始值??蛇x。

Further keys are available depending on the type of input.

根據(jù)輸入類型,還可以使用其他鍵。

Input Types?輸入類型

·type="int": A numeric input for integer values, within the range +/- two billion or so. If?both the?min?and?max?keys are given, also creates a slider for selecting a value from within this range

·type="int": 整數(shù)值的數(shù)值輸入,在+/-20億左右的范圍內(nèi)。如果同時(shí)給出了“最小”和“最大”鍵,還會(huì)創(chuàng)建一個(gè)用于從該范圍內(nèi)選擇一個(gè)值的滑塊。

··min: Minimum allowed value. Optional.

··min:最小允許值??蛇x。

··max: Maximum allowed value. Optional.

··max:最大允許值??蛇x。

·type="float": Identical to the?int?input, but provides a floating point value (within the?range allowed by double-precision floating point). If both the?min?and?max?keys are given, also creates a slider for selecting a value from within this range

·type="float":與int輸入相同,但提供一個(gè)浮點(diǎn)值(在雙精度浮點(diǎn)允許的范圍內(nèi))。如果同時(shí)給出了“最小”和“最大”鍵,也會(huì)創(chuàng)建一個(gè)用于從該范圍內(nèi)選擇一個(gè)值的滑塊。

··min: Minimum allowed value. Optional.

··min:最小允許值??蛇x。

··max: Maximum allowed value. Optional.

··max:最大允許值??蛇x。

·type="bool": A checkbox that can be either on or off.

·type=“bool”:可打開或關(guān)閉的復(fù)選框。

·type="text": A text field that can input a single line of text.

·type=“text”:可以輸入一行文本的文本。

··placeholder: Displays this text in a light grey color if the text field is empty. Optional.

··placeholder:如果文本為空,則以淺灰色顯示此文本。可選。

·type="choice": A pop-up menu that offers multiple choices for the user to select from.?Each choice is associated with a value that you define in the element’s?choices?list. This is the value you will receive as this option’s value in the?perform()?function.

·type="choice":一個(gè)彈出菜單,為用戶提供多種選擇。每個(gè)選項(xiàng)都與您在元素的choices列表中定義的值關(guān)聯(lián)。這是您將在perform()?函數(shù)中作為該選項(xiàng)的值接收的值。

··choices: A list of tuples of the form?(text,?value).

··選項(xiàng):窗體的元組列表(文本、值)。

·type="blocktype": A button that allows the user to select a Minecraft block type.The option’s value will be a single BlockType instance that can be used with?dimension.setBlock.

·type="blocktype":一個(gè)允許用戶選擇一個(gè)Minecraft塊類型的按鈕。該選項(xiàng)的值將是一個(gè)可以與dimension.setBlock一起使用的單個(gè)BlockType實(shí)例。

··value: The block type that will initially be selected. This should be a block’s?internal name, such as?minecraft:grass.

··value: 最初選擇的塊類型。這應(yīng)該是一個(gè)方塊的內(nèi)部名稱,如minecraft:grass。

For examples of all possible simple command inputs, see the?simple_options.py?file in the?plugins?folder included with MCEdit.

有關(guān)所有可能的簡(jiǎn)單命令輸入的示例,請(qǐng)參閱MCEdit附帶的plugins文件夾中的simple_options.py文件。

Tool Plugins?工具插件

Tool Plugins allow the creation of new editor tools, which give the user new ways to interact with the world by clicking and dragging in the world viewport. Each tool plugin may provide an “options widget” which is shown in the tool options panel while the tool is selected. A tool plugin may implement mouse event handlers, which will recieve 3D coordinates in world space cooresponding to the mouse position.

工具插件允許創(chuàng)建新的編輯器工具,為用戶提供了通過在“世界”視區(qū)中單擊和拖動(dòng)與世界交互的新方法。每個(gè)工具插件都可以提供一個(gè)“選項(xiàng)部件”,當(dāng)工具選擇時(shí),該部件顯示在工具選項(xiàng)面板中。一個(gè)工具插件可以實(shí)現(xiàn)鼠標(biāo)事件處理程序,它將在與鼠標(biāo)位置相對(duì)應(yīng)的世界空間中接收三維坐標(biāo)。

A tool plugin may also provide a 3D mouse cursor in the form of a SceneNode. Alternately, a 2D mouse cursor may be implemented by calling QCursor functions in your implementations of?toolActive?and?toolInactive

一個(gè)工具插件還可以提供SceneNode形式的3D鼠標(biāo)光標(biāo)?;蛘?,可以通過在toolactive和toolinactive實(shí)現(xiàn)中調(diào)用QCursor 函數(shù)來實(shí)現(xiàn)2D鼠標(biāo)光標(biāo)。

Mouse Handlers?鼠標(biāo)處理程序

These mouse handlers are called in response to user actions. A simple tool may only

implement?mousePress?or?mouseRelease, while a tool that also allows dragging or changes its cursor according to world position may also implement?mouseDrag?or?mouseMove.

調(diào)用這些鼠標(biāo)處理程序以響應(yīng)用戶操作。一個(gè)簡(jiǎn)單的工具可能只實(shí)現(xiàn)mousePressmouseRelease,而一個(gè)允許根據(jù)世界位置拖動(dòng)或更改其光標(biāo)的工具也可能實(shí)現(xiàn)mouseDragmouseMove。

EditorTool.mousePress(event)[source]

Parameters:

event?(QMouseEvent) – event has been augmented with these attributes: point, ray, blockPosition, blockFace

EditorTool.mouseMove(event)[source]

Parameters:

event?(QMouseEvent) – event has been augmented

EditorTool.mouseDrag(event)[source]

Parameters:

event?(QMouseEvent) – event has been augmented

EditorTool.mouseRelease(event)[source]

Parameters:

event?(QMouseEvent) – event has been augmented

Brush Shape Plugins?畫筆形狀插件

A Brush Shape plugin adds a new option to the Brush and Select tools for choosing the shape of the tool. A shape plugin must return a Selection object that defines the range of blocks in the shape, and may provide a Widget object to present shape-specific options in the tool’s options panel.

畫筆形狀插件向畫筆選擇”工具添加了一個(gè)新選項(xiàng)用于選擇工具形狀。形狀插件必須返回定義形狀中塊范圍的Selection對(duì)象,并且可以提供Widget對(duì)象以在工具的“選項(xiàng)”面板中顯示形狀特定的選項(xiàng)。

Shape plugins must inherit from?mcedit2.editortools.brush.shapes.BrushShape. There are two ways to implement the shape: as a function that returns a boolean array, or as a function that returns a new Selection object.

形狀插件必須繼承自mcedit2.editortools.brush.shapes.BrushShape。實(shí)現(xiàn)形狀有兩種方法:作為返回布爾數(shù)組的函數(shù),或作為返回新Selection對(duì)象的函數(shù)。

The?BrushShape?instance must also have an?ID?member which is a string that uniquely identifies this brush shape, and must have a?displayName?member which is the shape’s human-readable name. It may also have an?icon?member which is an absolute path to an image file to display as the shape’s icon.

BrushShape實(shí)例還必須具有一個(gè)ID成員,該成員是唯一標(biāo)識(shí)此畫筆形狀的字符串,并且必須具有一個(gè)displayName成員,該成員是此形狀的人類可讀名稱。它也可能有一個(gè)icon成員,它是作為形狀圖標(biāo)顯示的圖像文件的絕對(duì)路徑。

As a boolean array?作為布爾數(shù)組

BrushShape.shapeFunc(blockPositions,?selectionSize)[source]

Return a 3D boolean array for the blocks selected by this shape in a requested area.

返回請(qǐng)求區(qū)域中此形狀所選塊的三維布爾數(shù)組。

(Note that numpy arrays have a ‘shape’ attribute which gives the length of the array along each dimension. Sorry for the confusion.)

(請(qǐng)注意,numpy數(shù)組有一個(gè)“shape”屬性,它給出了數(shù)組沿每個(gè)維度的長(zhǎng)度。不好意思弄混了。)

The coordinates of the blocks are given by?blockPositions, which is a 4D array where the first axis has size 3 and represents the Y, Z, and X coordinates. The coordinates given are relative to the bounding box for this shape. The remaining 3 axes have the shape of the requested area.

塊的坐標(biāo)由blockPositions給出,它是一個(gè)4d數(shù)組,其中第一個(gè)軸的大小為3,代表Y、Z和X坐標(biāo)。給定的坐標(biāo)此形狀的邊界框有關(guān)。其余3個(gè)軸具有所請(qǐng)求區(qū)域的形狀。

blockPositions?may be separated into coordinate arrays by writing?y,?z,?x?=?blockPositions.

blockPositions可以通過寫y,?z,?x?=blockPositions來分隔成坐標(biāo)數(shù)組。

The size and shape of the array to return is given by the shapes of the arrays in?blockPositions.

要返回的數(shù)組的大小和形狀由位于blockPositions的數(shù)組的形狀給出。

The size of the shape’s bounding box is given by selectionSize.

形狀邊界框的大小由selectionSize給出。

Parameters:

·blockPositions?(numpy.ndarray[ndims=4,dtype=float32]) – Coordinates of requested blocks relative to Shape’s bounding box.

·selectionSize?((int,?int,?int)) – Size of the Shape’s bounding box.

Returns:

mask?– Boolean array of the same shape as blockPositions[0] where selected blocks are True

Return type:

numpy.ndarray[ndims=3,dtype=bool]

This is the simpler way of implementing a brush shape. When the shape is used,?shapeFunc?will be called repeatedly for each section of the selection. It will be passed the coordinates of each block in the selection, relative to the selection’s origin point, along with the full size of the selection. Using these values, you will compute and return a boolean array (of the same shape as the coordinate array) that indicates whether each block in the section should be selected.

這是實(shí)現(xiàn)畫筆形狀的簡(jiǎn)單方法。該形狀使用時(shí),將對(duì)所選的每個(gè)部分重復(fù)調(diào)用shapeFunc。它將傳遞所選部分中每個(gè)塊相對(duì)于所選部分原點(diǎn)的坐標(biāo)以及所選部分的完整大小。使用這些值,您將計(jì)算并返回一個(gè)布爾數(shù)組(形狀與坐標(biāo)數(shù)組相同),該數(shù)組指示是否應(yīng)選擇部分中的每個(gè)塊。

blockPositions?is a multi-dimensional array where the first axis selects the?x,?y, or?z?coordinates; e.g. to access the?x?coordinate array, write?blockPositions[0].

blockPositions是一個(gè)多維數(shù)組,其中第一個(gè)軸選擇X、Y或Z坐標(biāo);例如,要訪問X坐標(biāo)數(shù)組,請(qǐng)寫blockPositions[0]

selectionSize?is a simple tuple of three positive integers.

selectionSize是由三個(gè)正整數(shù)組成的簡(jiǎn)單元組。

For example, this brush shape selects all blocks whose relative Y coordinate is more than 5 - in other words, it is a rectangular selection that excludes the bottom five layers of its bounding box:

例如,此畫筆形狀選擇相對(duì)Y坐標(biāo)大于5的所有塊-換句話說,它是一個(gè)矩形選擇,不包括其邊界框的底部五層:

class?Example(BrushShape):

????ID =?"example"

????displayName =?"Example Brush Shape"

?

????def?shapeFunc(self, blockPositions, size):

????????y =?blockPositions[1]

????????mask =?y >?5

????????return?mask

Note that?shapeFunc?does not have access to the world dimension where the selection is made, and cannot inspect the world and react to its contents.?shapeFunc?is meant for shapes that are purely mathematical in nature and can be made using simple computations on the coordinates and the selection’s size.

請(qǐng)注意,shapeFunc無法訪問進(jìn)行選擇的世界維度,并且無法檢查世界并對(duì)其內(nèi)容作出反應(yīng)。shapeFunc用于本質(zhì)上純數(shù)學(xué)的、可以使用坐標(biāo)和選擇大小的簡(jiǎn)單計(jì)算而生成的形狀。

As a Selection object?作為選擇對(duì)象

BrushShape.createShapedSelection(box,?dimension)[source]

Return a SelectionBox that selects the blocks inside this shape.

返回選擇此形狀內(nèi)的塊的SelectionBox。

The default implementation returns a ShapeFuncSelection using self.shapeFunc. Subclasses may override this to return different types of SelectionBox.

默認(rèn)實(shí)現(xiàn)使用self.shapeFunc返回一個(gè)ShapeFuncSelection。子類可以重寫此項(xiàng)以返回不同類型的SelectionBox。

TODO: BitmapSelectionBox

TODO:位圖選擇框

Parameters:

·box?(BoundingBox) – Bounding box of the selection

·dimension?(WorldEditorDimension) – Dimension to create the shaped selection for.

Returns:

box?– SelectionBox object that selects all blocks inside this shape

Return type:

SelectionBox

This is the more advanced way of implementing a brush shape.?createShapedSelection?is given the rectangular bounding box that encloses the shape, and the world dimension where the shape is being used. It must return a?SelectionBox?instance, which may be one of the existing selection classes or a class of your own design. For details about?SelectionBox?subclasses, see?selection

這是實(shí)現(xiàn)畫筆形狀的更高級(jí)的方法。createShapedSelection給出了包圍形狀的矩形邊界框以及使用形狀的世界維度。它必須返回一個(gè)SelectionBox實(shí)例,該實(shí)例可能是現(xiàn)有的選擇類之一,也可能是您自己設(shè)計(jì)的類。有關(guān)SelectionBox子類的詳細(xì)信息,請(qǐng)參見Selection。



Plugin Examples插件示例

Simple Options?簡(jiǎn)單選項(xiàng)

This plugin demonstrates the use of the?SimpleCommandPlugin?class and its?options?list.

這個(gè)插件演示了SimpleCommandPlugin類及其options列表的使用。

simple_options.py source code

"""

????simple_options

"""

from __future__ import absolute_import, division, print_function, unicode_literals

?

from PySide import QtGui

?

from mcedit2.plugins import registerPluginCommand, SimpleCommandPlugin

import logging

?

log = logging.getLogger(__name__)

?

?

@registerPluginCommand

class SimpleOptionsDemo(SimpleCommandPlugin):

????displayName = "Simple Options Demo"

?

????options = [

????????{

????????????'type': 'label',

????????????'text': 'A label containing some descriptive text. This text is automatically word-wrapped.'

????????},

????????{

????????????'type': 'label',

????????????'text': '''A multi-line label

????????????with several lines

????????????of text.'''

????????},

????????{

????????????'type': 'int',

????????????'value': 50,

????????????'min': 0,

????????????'max': 75,

????????????'name': 'myIntOption',

????????????'text': 'Integer Option: ',

????????},

????????{

????????????'type': 'int',

????????????'value': 75,

????????????'name': 'myIntOption2',

????????????'text': 'Integer Option (No Min/Max): ',

????????},

????????{

????????????'type': 'float',

????????????'value': 1.5,

????????????'min': 0,

????????????'max': 7.5,

????????????'name': 'myFloatOption',

????????????'text': 'Float Option: ',

????????},

????????{

????????????'type': 'float',

????????????'value': 2.5,

????????????'name': 'myFloatOption2',

????????????'text': 'Float Option (No Min/Max): ',

????????},

????????{

????????????'type': 'bool',

????????????'name': 'myBoolOption',

????????????'text': 'Boolean Option: ',

????????},

????????{

????????????'type': 'text',

????????????'name': 'myTextOption',

????????????'text': 'Text Option (Placeholder): ',

????????????'placeholder': 'Placeholder Text',

????????},

????????{

????????????'type': 'text',

????????????'name': 'myTextOption2',

????????????'text': 'Text Option (Default Value): ',

????????????'value': 'Default Text Value',

????????},

????????{

????????????'type': 'choice',

????????????'name': 'myChoiceOption',

????????????'text': 'Choice Option: ',

????????????'choices': [

????????????????('Choice With Text Data', 'choice1'),

????????????????('Choice With Integer Data', 50),

????????????????('Choice With Float Data', 4.5),

?

????????????]

????????},

????????{

????????????'type': 'blocktype',

????????????'name': 'myBlocktypeOption',

????????????'text': 'Blocktype Option: ',

????????????'value': 'minecraft:glass',

????????}

????]

?

????def perform(self, dimension, selection, options):

????????lines = []

????????for key in [

????????????'myIntOption',

????????????'myIntOption2',

????????????'myFloatOption',

????????????'myFloatOption2',

????????????'myBoolOption',

????????????'myTextOption',

????????????'myTextOption2',

????????????'myChoiceOption',

????????????'myBlocktypeOption',

????????]:

????????????lines.append('%s: %s' % (key, options[key]))

?

????????QtGui.QMessageBox.information(None, "Simple Options Demo Result",

??????????????????????????????????????"Selected Options:\n\n" + '\n'.join(lines))

World Editing?世界編輯

This plugin demonstrates how to read and change blocks, and how to find entities and modify entity attributes.

這個(gè)插件演示了如何讀取和更改塊,以及如何查找實(shí)體和修改實(shí)體屬性。

world_editing_demo.py source code

"""

????world_editing_demo

"""

from __future__ import absolute_import, division, print_function, unicode_literals

?

from PySide import QtGui

?

from mcedit2.plugins import registerPluginCommand, SimpleCommandPlugin

import logging

?

log = logging.getLogger(__name__)

?

?

@registerPluginCommand

class WorldEditingDemo(SimpleCommandPlugin):

????displayName = "World Editing Demo"

?

????options = [

????????{

????????????'type': 'blocktype',

????????????'name': 'replaceWith',

????????????'text': 'Replace all Stone blocks with this: ',

????????????'value': 'minecraft:glass',

????????},

????????

????????{

????????????'type': 'float',

????????????'value': 10,

????????????'min': 0,

????????????'max': 200,

????????????'name': 'pigHealth',

????????????'text': 'Change the health of all Pigs to this: ',

????????},

????????{

????????????'type': 'text',

????????????'name': 'zombieName',

????????????'text': 'Change the name of all Zombies to this: ',

????????????'placeholder': 'Dinnerbone',

????????},

????]

?

????def perform(self, dimension, selection, options):

????????stone = dimension.blocktypes['minecraft:stone']

????????replaceWith = options['replaceWith']

????????

????????for x, y, z in selection.positions:

????????????if dimension.getBlock(x, y, z) == stone:

????????????????dimension.setBlock(x, y, z, replaceWith)

????????????????

????????for entity in dimension.getEntities(selection, id='Pig'):

????????????entity.Health = options['pigHealth']

????????????

????????for entity in dimension.getEntities(selection, id='Zombie'):

????????????entity.Name = options['zombieName']

【中英對(duì)譯】MCEdit 2 Documentation(2)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
宁波市| 郸城县| 锦州市| 遂昌县| 阜平县| 行唐县| 洪泽县| 城步| 远安县| 定陶县| 西平县| 林西县| 阜南县| 合肥市| 汽车| 金寨县| 鄢陵县| 英山县| 醴陵市| 民权县| 陕西省| 东明县| 瑞丽市| 新竹县| 苏州市| 司法| 潞城市| 新竹县| 广平县| 望江县| 丹东市| 唐河县| 布拖县| 佛坪县| 同仁县| 普格县| 班戈县| 博罗县| 武川县| 花莲市| 申扎县|