User Tools

Site Tools


zh_cn:tutorial:jigsaw

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
zh_cn:tutorial:jigsaw [2020/02/05 04:52] – created lightcolourzh_cn:tutorial:jigsaw [2020/02/24 02:59] (current) – [创建一个StructureStart类] lightcolour
Line 17: Line 17:
 </code> </code>
  
-//shouldStartAt// answers the question "should I start generating at the given Chunk?" ''AbstractTempleFeature'' is a class offered by vanilla that offers an answer to this question: it guarantees each structure is spaced out from others of the same type. The standard village feature uses the same logic but isn't a child of the class. By returning true, every chunk will have your feature. This is good for testing, so we'll use that route for now.  +//shouldStartAt//回答问题"我应该在给定的块中开始生成吗?" ''VanillaTempleFeature''vanilla提供的一个类,它为这个问题提供了答案:它可以确保每个结构与其他相同类型的结构隔开。 标准乡村功能使用相同的逻辑,但不是该类别的子级。 通过返回true,每个块都将具有您的功能。 这对于测试非常有用,因此我们现在将使用该路由。
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 @Override @Override
Line 26: Line 25:
 </code> </code>
  
-//getName// is the name of your structure. It's used for a few things, including: +//getName// 是您的结构的名称。 它用于几件事,包括: 
-  Serializing and Deserializing your structure from a chunk +   *序列化,并从一大块反序列化的结构 
-  Locating your structure +   *找到您的结构 
-  Labeling your structure +   *标记您的结构 
-Vanilla convention is a properly capitalized title. "Igloo," "Village," and "Fortress," are all valid.((Do not use a ''TranslatableText'' for this: while the intent is valiant, things will break.))+原版约定是适当大写的标题。''Igloo'',''Village''和''Fortress''都是有效的。((请勿使用''TranslatableText'':意图很强的时候,事情会崩溃的。))
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 @Override @Override
Line 38: Line 37:
 </code> </code>
  
-The exact usage for //getRadius// is still under discussion, but my guess (as the writer) is that it's related to translation within a chunk. A structure with a radius of may be moved around within the chunk bounds, while a structure with a radius of will always be centered. This may be wrong. For now, the radius should be half the size of your structure; if your structure will take up more than a single chunk (or fill it entirely), return 8.+//getRadius//的确切用法仍在讨论中,但是(作为作者)我的猜测是它与块内的翻译有关。 半径为4的结构可以在块边界内移动,而半径为8的结构将始终居中。 这可能是错误的。 目前,半径应为结构的一半; 如果您的结构将占用多个块(或全部填充),则返回8
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 @Override @Override
Line 45: Line 44:
 } }
 </code> </code>
- +最后,//getStructureStartFactory//是您的StructureFeature的生成部分。 您必须返回一个工厂方法来创建新的StructureStarts -我们可以简单地通过方法引用构造函数。 我们的实现将如下所示,''ExampleStructureStart''是本教程的下一步:
-Finally, //getStructureStartFactory// is the generation portion of your StructureFeature. You'll have to return a factory method to create new StructureStarts-- we can simply method reference the constructor. Our implementation will look like this, with ''ExampleStructureStart'' being the next step in this tutorial:+
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 @Override @Override
Line 53: Line 51:
 } }
 </code> </code>
- +我们完成的''ExampleFeature''类:
-Our finalized ''ExampleFeature'' class:+
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 import com.mojang.datafixers.Dynamic; import com.mojang.datafixers.Dynamic;
Line 92: Line 89:
 </code> </code>
  
-==== Creating a StructureStart class ===== +==== 创建一个StructureStart类 ===== 
-''StructureStart'' is like the initialization stage of generating our structure in the world. For now, create a simple child class with a constructor that also overrides initialize:+''StructureStart''就像在世界上生成我们的结构的初始化阶段。 现在,使用构造函数创建一个简单的子类,该构造函数还将覆盖initialize
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 public class ExampleStructureStart extends StructureStart { public class ExampleStructureStart extends StructureStart {
Line 108: Line 105:
 </code> </code>
  
-To understand what happens here, we'll have to dive into jigsaws (https://minecraft.gamepedia.com/Jigsaw_Block) and structure blocks (https://minecraft.gamepedia.com/Structure_Block).+要了解这里发生的情况,我们必须深入研究拼图 (https://minecraft.gamepedia.com/Jigsaw_Block) and 结构方块(https://minecraft.gamepedia.com/Structure_Block).
  
-Structure Blocks are a simple way of saving a structure to a .nbt file for future use. Jigsaws are a component of structure blocks that assemble multiple structures into a single one; similar to normal jigsaws, each piece of the structure connects at a jigsaw block, which is like a connection wedge in a puzzle piece. We'll assume you're familiar with saving structures-- if you aren't, read up on the structure block page before going any further. +结构放块是一种将结构保存到.nbt文件以供将来使用的简单方法。 拼图是结构块的组成部分,将多个结构组装成一个结构。 与普通的拼图游戏类似,结构的每一块都在拼图块处连接,就像拼图块中的连接楔子一样。 我们假设您熟悉保存结构-如果不熟悉,请先阅读结构块页面,然后再进行任何操作。
- +
-The jigsaw menu consists of 3 fields: +
- * target pool +
- * attachment type +
- * turns into+
  
 +拼图菜单包含3个:
 +  *目标池
 +  *附件类型
 +  *转成
 {{https://i.imgur.com/owaJ0k2.png|Blank Jigsaw}} {{https://i.imgur.com/owaJ0k2.png|Blank Jigsaw}}
  
-When thinking about this as a puzzlethe target pool is the group of puzzle pieces you can search throughIf you have a total of 10 pieces, one target pool may have of the total piecesThis field is how a jigsaw specifies, "Hi, I'd like a piece from group to connect to me!" In the case of a village, this may be a road saying, "Give me a house!" The target pools of jigsaws do not have to match: the requestor gets to decide who they select from. It is **not** defining what type //the given// jigsaw block is, but rather what type should be on the //other side//. +将其视为难题时,目标池就是您可以搜索的一组难题如果您共有10件,那么一个目标池可能有7拼图是如何在此字段中指定的:"嗨,我希望B组的一块可以和我联系!" 就一个村庄而言,这可能是一条路,说:“给我房子!” 2个拼图的目标池不必匹配:请求者可以决定从中选择谁。 **不是**定义给定的//拼图块是什么类型,而是应该定义另一种类型///.
- +
-The attachment type can be seen as a more specific filter within target pools-- a jigsaw can only connect to other jigsaws with the same attachment type. This is like the type of connector on a puzzle piece. The usages for this are a little bit more specific.+
  
-Finally, the "turns into" field is simply what the jigsaw is replaced with after it finds a match. If the jigsaw is inside your cobblestone floor, it should probably turn into cobblestone.+附件类型可以看作是目标池中更具体的过滤器-拼图只能连接到具有相同附件类型的其他拼图。 这就像拼图块上的连接器类型。 用法更加具体.
  
-Here's an example implementation: the given jigsaw will draw from the //tutorial:my_pool// structure pool, looks for any jigsaws with the //tutorial:any// type, and turns into cobblestone when it's done.+最后,“turns into”字段只是拼图找到匹配项后所替换的内容。 如果拼图位于您的鹅卵石地板内,它可能会变成原石. 
 +这是一个示例实现:给定的拼图将从// tutorial:my_pool //结构池中绘制,查找具有// tutorial:any //类型的所有拼图,并在完成后变成原石。
  
 {{https://i.imgur.com/f9tP2sv.png|Example Finished Jigsaw}} {{https://i.imgur.com/f9tP2sv.png|Example Finished Jigsaw}}
Line 193: Line 188:
 </code> </code>
  
-Here, we're registering pools (base & color) and then adding their respective children to them. The StructurePool constructor is as follows+在这里,我们要注册2个池(基础和颜色),然后将它们各自的子级添加到它们中。 StructurePool构造函数如下
- registry name of the pool, same as target pool at top of a jigsaw +*池的注册表名称,与竖锯顶部的目标池相同 
- * @Draylar if you know what this one does +  *@Draylar,如果您知道这是做什么的 
- a list of pool elements +  *池元素列表 
- the projection type of the pool +  *池的投影类型 
- +对于元素列表,我们添加池元素和整数的Pairs((com.mojang.datafixers.util))。 传递到元素的字符串是结构在数据目录中的位置,而int是元素在整个目标池中的权重。 对每个元素使用1可以确保每个元素被均匀地拾取.
-For the list of elements, we add Pairs((com.mojang.datafixers.util)) of pool elements and integers. The string passed into the element is the location of the structure in the data directory, and the int is the weight of the element within the entire target pool. Using for each element ensures each one will be picked evenly.+
  
-The projection is how the pool is placed in the world. Rigid means it will be placed directly as is, and terrain matching means it will be bent to sit on top of the terrain. The latter may be good for a wheat field structure that moves with the terrain shape, whereas the first would be better for houses with solid floors.+投影是如何将池放置在世界上的。 刚性表示将直接按原样放置,而地形匹配则表示将其弯曲以位于地形顶部。 后者可能适合随地形变化的麦田结构,而前者则适合具有坚固地板的房屋。
    
-Now all we have to do is add our starting piece in our ''initialize'' method:+现在,我们要做的就是在''initialize''方法中添加起始片段:
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 @Override @Override
Line 211: Line 205:
 } }
 </code> </code>
-The Identifier is the starting pool to select from, the int is the size of the entire structure (with being "7 squares out"), and the 3rd argument is a factory for the piece we'll register in a second.+Identifier是可供选择的起始池,int是整个结构的大小(其中7为“7 squares out”),第3个参数是我们将在第二秒注册的零件的工厂.
  
-==== Creating a Piece ==== +==== 创作作品 ==== 
-This portion is very simple. A piece represents one section or element in your full structure. You'll need to create a basic piece class, and we'll register it later:+这部分非常简单。 一块代表整个结构中的一个部分或元素。 您需要创建一个基本的计件类,稍后我们将进行注册:
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 public class ExamplePiece extends PoolStructurePiece { public class ExamplePiece extends PoolStructurePiece {
Line 228: Line 222:
 </code> </code>
  
-Where ''ExampleMod.EXAMPLE_PIECE'' is a reference to our registered piece.+其中''ExampleMod.EXAMPLE_PIECE''是对我们注册件的引用。
  
-==== Registering Everything ==== +==== 注册所有 ==== 
-We'll need to register our structure as both a feature //and// a structure feature, and also register our piece. Registering your structure as a StructureFeature is optional, and is used for saving it to the chunk. If the world is stopped half-way through your structure loading, having this registered will allow it to continue after the world is re-opened. If it is not registered to a structure feature and this happens, the structure will stop half-way through (which would mostly only occur in larger, multiple chunk wide structures).+我们需要将结构既注册为特征////还是结构特征,并注册我们的作品。 将结构注册为StructureFeature是可选的,并且用于将其保存到块中。 如果世界在您的结构加载过程中途中止,则在重新打开世界后对其进行注册将使其继续存在。 如果未将其注册到结构特征中,并且发生了这种情况,则该结构将中途停止(大多数情况下只会发生在较大的,多块宽的结构中)。
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
 public static final StructureFeature<DefaultFeatureConfig> EXAMPLE_FEATURE = Registry.register( public static final StructureFeature<DefaultFeatureConfig> EXAMPLE_FEATURE = Registry.register(
Line 252: Line 246:
 </code> </code>
  
-==== Spawning Our Structure ==== +==== 生成我们的结构 ==== 
-Finally, we'll have to spawn our structure. A basic example which adds it to every biome is:+最后,我们必须生成我们的结构。 将其添加到每个生物群系的一个基本示例是:
 <code java [enable_line_numbers="false"]> <code java [enable_line_numbers="false"]>
 Registry.BIOME.forEach(biome -> { Registry.BIOME.forEach(biome -> {
Line 261: Line 255:
 </code> </code>
  
-=== Finished! === +=== 完成! === 
-As you can see, we have a single white square in the center, with boxes going off the edges. Note that the radius in this screenshot was increased to 14 instead of the used in the tutorial. +如您所见,我们在中心有一个白色正方形,框在边缘之外。 请注意,此屏幕截图中的半径已增加到14,而不是本教程中使用的7 
-{{https://i.imgur.com/qndZzZu.png|Finalized}}+{{https://i.imgur.com/qndZzZu.png|搞定}}
zh_cn/tutorial/jigsaw.1580878337.txt.gz · Last modified: 2020/02/05 04:52 by lightcolour