User Tools

Site Tools


tutorial:features

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
tutorial:features [2020/01/08 12:17]
lightcolour
tutorial:features [2020/01/08 12:18] (current)
lightcolour
Line 1: Line 1:
-===== 在您的世界中生成Feature ​===== +===== Generating Features in your World ===== 
-岩石,树木,矿石和池塘都是Feature的示例。 它们是对世界的简单补充,它们的生成取决于它们的配置方式。 在本教程中,我们将研究如何在我们的世界中随机生成一个简单的石螺旋Feature。 +Rocks, trees, ores, and ponds are all examples of Features. They are simple generation additions to the world which generate depending on how they are configured. In this tutorial, we'll look at generating a simple stone spiral feature in our world randomly. 
-==== 创建Feature类 ==== + 
-一个简单的Feature如下所示:+==== Creating a Feature ​class ==== 
 +A simple ​Feature ​looks like this:
 <code java [enable_line_numbers="​true"​]>​ <code java [enable_line_numbers="​true"​]>​
 public class StoneSpiralFeature extends Feature<​DefaultFeatureConfig>​ { public class StoneSpiralFeature extends Feature<​DefaultFeatureConfig>​ {
Line 25: Line 26:
 </​code>​ </​code>​
  
-构造函数采用''​Function<​Dynamic<?​ extends DefaultFeatureConfig>>''​,这是数据修复程序配置实例的工厂。 您可以直接在超级调用中或在实例化功能时为默认配置功能传递''​DefaultFeatureConfig :: deserialize''​+The constructor takes in a ''​Function<​Dynamic<?​ extends DefaultFeatureConfig>>''​, which is a factory for data fixer config instances. You can pass in ''​DefaultFeatureConfig::​deserialize'' ​for default config features, either directly in the super call or when you instantiate the feature.
  
-当块决定生成Feature时,将调用``generate``。 如果将功能配置为产生每个块,则也会为正在生成的每个块调用此功能。 在将功能配置为以每个生物群落以一定速率生成的情况下,仅在世界想要生成结构的情况下才调用``generate``。+`generateis called when the chunk decides to generate ​the feature. If the feature is configured to spawn every chunk, this would be called for each chunk being generated as well. In the case of the feature being configured to spawn at a certain rate per biome, ​`generate` ​would only be called in instances where the world wants to spawn the structure. ​
  
-在我们的实现中,我们将从世界的最高位置开始构建一个简单的16块高的石头螺旋:+In our implementation,​ we'll build a simple ​16-block tall spiral of stone starting at the top block in the world:
  
 <code java> <code java>
Line 46: Line 47:
 </​code>​ </​code>​
  
-==== 注册一个Feature ==== +==== Registering a Feature ==== 
-可以像注册游戏中的其他大多数内容一样注册Feature,而且您不必担心任何特殊的构建器或机制。+Features can be registered like most other content in the game, and there aren't any special builders or mechanics you'll have to worry about. ​
 <code java> <code java>
 private static final Feature<​DefaultFeatureConfig>​ LAVA_HOLE = Registry.register( private static final Feature<​DefaultFeatureConfig>​ LAVA_HOLE = Registry.register(
Line 56: Line 57:
 </​code>​ </​code>​
  
-==== 向生物群落添加Feature ==== +==== Adding a Feature ​to a Biome ==== 
-生物群系有一种称为''​addFeature''​的方法,用于将Feature添加到生物群落的生成过程中。 您可以在每个生物群落类(例如''​ForestBiome''​''​SavannaBiome''​)中查看此方法的更详细用法。+Biome has a method called ​''​addFeature''​, which is used to add Features to the biome'​s generation process. You can view more detailed usage of this method inside each Biome class (such as ''​ForestBiome'' ​or ''​SavannaBiome''​).
  
-我们可以遍历''​Registry.BIOME''​以将我们的Feature添加到每个生物群系中。+We can iterate over ''​Registry.BIOME'' ​to add our Feature ​to every Biome.
 <code java> <code java>
 Registry.BIOME.forEach(biome -> biome.addFeature( Registry.BIOME.forEach(biome -> biome.addFeature(
Line 72: Line 73:
 </​code>​ </​code>​
  
-''​addFeature''​的第一个参数有助于确定何时生成结构。 对于地上的房屋,您可以使用''​SURFACE_STRUCTURES''​,对于洞穴,您可以使用''​ RAW_GENERATION''​+The first argument of ''​addFeature'' ​helps determine when the structure is generated. For above-ground houses you may go with ''​SURFACE_STRUCTURES''​, and for caves, you might go with ''​RAW_GENERATION''​.
  
-''​addFeature''​的第二个参数是ConfiguredFeature,可以通过''​Biome.configureFeature''​创建。 后者接收功能的实例,功能的config类,装饰器和装饰器配置的实例。+The second argument of ''​addFeature'' ​is a ConfiguredFeature, which you can create through ​''​Biome.configureFeature''​. The latter takes in an instance of your feature, an instance of your feature'​s ​config ​class, a decorator, and a decorator config.
  
-装饰器代表世界如何选择放置要素。 ​''​CHANCE_HEIGHTMAP''​可通过查看高度图来工作,而''​NOISE_HEIGHTMAP_32''​可使用噪声来工作。 要选择正确的装饰器,请签出与您自己风格相似的香草功能。 装饰器配置将分支此分支; 对于''​CHANCE_HEIGHTMAP''​,您将传入''​ChanceHeightmapDecorator的实例。+The Decorator represents how the world chooses to place your Feature. ​''​CHANCE_HEIGHTMAP'' ​works by looking at a heightmap, whereas ​''​NOISE_HEIGHTMAP_32'' ​works with noise. To choose the correct Decorator, check out vanilla Features with a similar style to your own. The decorator config branches off this; in the case of ''​CHANCE_HEIGHTMAP''​, you would pass in an instance of ''​ChanceHeightmapDecorator''​. ​
  
-=== 结果 ​===+=== Results ​===
 {{https://​i.imgur.com/​Kr59o0B.png}} {{https://​i.imgur.com/​Kr59o0B.png}}
tutorial/features.txt · Last modified: 2020/01/08 12:18 by lightcolour