Minecraft 1.18.1、1.18.2模组开发 18.自定义维度(dimension)

往期教程:1.16.5空间维度

我们今天在1.18的世界中实现一个自定义维度。

1.在init包中新建一个DimensionInit类

DimensionInit .java

public class DimensionInit {
	//将我们的维度在这里声明我们的维度名称
    public static final ResourceKey<Level> RE8_KEY = ResourceKey.create(Registry.DIMENSION_REGISTRY,
            new ResourceLocation(Main.MOD_ID, "re8_dimension"));
    public static final ResourceKey<DimensionType> RE8_TYPE =
            ResourceKey.create(Registry.DIMENSION_TYPE_REGISTRY, RE8_KEY.getRegistryName());

    public static void register() {
        System.out.println("Registering Resident Evil 8 Dimensions for " + Main.MOD_ID);
    }
}
在项目主类中的Main函数中对DimensionInit进行注册。
	public Main() {
		IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();

		ItemInit.ITEMS.register(bus);
		BlockInit.BLOCKS.register(bus);

		BlockEntityInit.register(bus);
        MenuInit.register(bus);
		RecipeInit.register(bus);
        
        ModStructures.register(bus);
        
        //添加这个
        DimensionInit.register();


		MinecraftForge.EVENT_BUS.register(this);
	}

2.之后是维度制作环节,我们可以使用维度空间在线制作网站(右上角有中文选项)进行制作:

info.png
制作完后保存右下角的脚本代码到一个.json文件,名称与第一步的名称一样,并放到这个resources\data\你的modid\dimension路径下:
re8_dimension.json

{
  "type": "re8joymod:re8_dimension",
  "generator": {
    "type": "minecraft:noise",
    "seed": -1703673680,
    "settings": "minecraft:overworld",
    "biome_source": {
      "type": "minecraft:fixed",
      "biome": "minecraft:plains"
    }
  }
}
点击Dimension Type Generator的按钮并进行维度类型的制作

ii.png

制作完后后保存到resources\data\你的modid\dimension_type路径下。

re8_dimension.json

{
  "ultrawarm": false,
  "natural": true,
  "piglin_safe": false,
  "respawn_anchor_works": false,
  "bed_works": false,
  "has_raids": true,
  "has_skylight": true,
  "has_ceiling": false,
  "coordinate_scale": 1,
  "ambient_light": 0,
  "logical_height": 256,
  "infiniburn": "#minecraft:infiniburn_overworld",
  "min_y": 0,
  "height": 256
}

3.保存所有文件,进入游戏测试

新建一个世界 -> 按’T’键之后在聊天栏中输入指令进行传送(in 后面跟的名称是你的模组名称:你的维度名称)
/execute in re8joymod:re8_dimension run tp @s ~ ~ ~

cr.png

bingo!
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Jay_fearless

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

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

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

打赏作者

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

抵扣说明:

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

余额充值