Minecraft 1.19.2 Forge模组开发 07.拼图建筑(jigsaw)

如果你看过之前的Minecraft 1.19.2建筑生成的话,想必会更好理解这篇教程。

cr0.gif
效果演示 效果演示 效果演示

1.我们本期准备生成的建筑分为4块,所以首先需要用4个结构方块将整个建筑包括起来:

ccr.jpg

2.之后我们需要用指令拿出拼图方块:

give @p minecraft:jigsaw
我们需要对拼图顺序做一个大致的设计:

cr1.png

来到1、2的衔接点,将我们的结构方块摆放如下:

2022-05-30_13.48.05.png

右键建筑1的结构方块,在该方块中输入如下信息:

建筑1要找到建筑2拼图,所以它的Target PoolTarget Name中要是建筑2的名称。
crk.jpg

右键建筑2的结构方块,在该方块中输入如下信息:

建筑2只需要被建筑1找到,不需要找别的建筑。所以它没有Target,只有自己的名字,和建筑1的Target Name一样。
crl.jpg

同理,我们把另外两个衔接点都给完成。
我们将所有的衔接工作搞完后,将所有的建筑保存为.nbt文件:

crm.jpg

3.在你的地图存档中的generated\minecraft\structures下找到所有的.nbt文件,存放到resources\data\re8joymod\structures路径下:

cr5.png

4.之后来到数据包制作:

cro.jpg
项目结构 项目结构 项目结构

和之前一样,在data\你的modid\tags\worldgen\biome\has_structure中新建文件说明我们的建筑在哪些生态群系生成:

bene_house.json

{
  "replace": false,

  "_comment": " This biome tag can specify the biome directly. Or specify another biome tag by starting with # ",
  "values": [
    "minecraft:plains",
    "re8joymod:re8_ehills_biome"
  ]
}
data\你的modid\worldgen\structure中新建文件,说明你的建筑内生成什么生物

bene_house.json

{
  "type": "minecraft:jigsaw",
  //起始生成建筑
  "start_pool": "re8joymod:bene_house/start_pool",
  //这个是指从我们中心处可以往外延伸几个建筑
  "size": 2,
  "max_distance_from_center": 100,
  //建筑在什么群系生成,对应上面的has_structure中的文件名称
  "biomes": "#re8joymod:has_structure/bene_house",
  "step": "surface_structures",

  "start_height": {
    "absolute": 0
  },

  "project_start_to_heightmap": "WORLD_SURFACE_WG",
  "use_expansion_hack": false,
  //建筑物内生成的生物
  "spawn_overrides": {
    "creature": {
      "bounding_box": "piece",
      "spawns": [
        {
          "type": "minecraft:bat",
          "weight": 1,
          "minCount": 1,
          "maxCount": 4
        }
      ]
    }
  }
}
注:上面的size可以用3维宽度优先搜索来解释:

crn.jpg

你的建筑会从中心结构朝着上下左右前后共6个方向延伸,延伸的次数就是这个size
data\你的modid\worldgen\structure_set中新建文件,说明你的建筑生成间距、建筑生成id等内容:

bene_house.json

{
  // What structures to pick to try and spawn if a spot passes the placement check.
  // If two or more structures in this list can spawn in a biome at a spot, a random one based on weight is chosen to spawn
  "structures": [
    {
      "structure": "re8joymod:bene_house",
      "weight": 1
    }
  ],
  "placement": {
    // Make sure this is unique and does not match any other structure set's salt
    //找一个介于int间的数,不要和其他的建筑一样
    "salt": 36694,

    // The average distance apart in chunks for spawn attempts
    //平均几个区块的距离生成一个这种建筑
    "spacing": 24,

    // Minimum distance apart in chunks for spawn attempts
    // MUST ALWAYS BE SMALLER THAN spacing ABOVE
    "separation": 20,

    // The kind of placement to use. The other kind is ring based like strongholds use.
    "type": "minecraft:random_spread"
  }
}
resources\data\re8joymod\worldgen\template_pool中新建我们的建筑文件夹bene_house,将我们第2步中定义的建筑新建出来:

cr6.png
我们的建筑1作为整个大型建筑的开头,需要命名为start_pool
start_pool.json

{
  //作为建筑的start_pool
  "name": "re8joymod:bene_house/start_pool",

  "fallback": "minecraft:empty",

  "elements": [
    {

      "weight": 1,
      "element": {

        //第3步中我们第一个建筑保存的名称
        "location": "re8joymod:bene_house",

        "processors": "minecraft:empty",


        "projection": "rigid",


        "element_type": "minecraft:single_pool_element"
      }
    }
  ]
}
第二个建筑作为拼图,命名为side_pool2

side_pool2.json

{
  //建筑2作为拼图,命名为side_pool2
  "name": "re8joymod:bene_house/side_pool2",
  "fallback": "minecraft:empty",
  "elements": [
    {
      "weight": 1,
      "element": {

        //第3步中我们第2个建筑的名称
        "location": "re8joymod:bene_house2",
        "processors": "minecraft:empty",
        "projection": "rigid",
        "element_type": "minecraft:single_pool_element"
      }
    }
  ]
}
第三个、第四个同理:

side_pool3.json

{
  "name": "re8joymod:bene_house/side_pool3",
  "fallback": "minecraft:empty",
  "elements": [
    {
      "weight": 1,
      "element": {


        "location": "re8joymod:bene_house3",
        "processors": "minecraft:empty",
        "projection": "rigid",
        "element_type": "minecraft:single_pool_element"
      }
    }
  ]
}

side_pool4.json

{
  "name": "re8joymod:bene_house/side_pool4",
  "fallback": "minecraft:empty",
  "elements": [
    {
      "weight": 1,
      "element": {


        "location": "re8joymod:bene_house4",
        "processors": "minecraft:empty",
        "projection": "rigid",
        "element_type": "minecraft:single_pool_element"
      }
    }
  ]
}

5.保存所有文件 -> 运行游戏

如果你能在你第4步中定义的生态群系里找到你的建筑,就说明你成功了!!!

在这里插入图片描述

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jay_fearless

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值