内置数据映射

内置数据映射

NeoForge 为常见用途提供多种内置数据映射,以替代原版硬编码字段。原版值由 NeoForge 的数据映射文件提供,因此玩家体验上没有功能差异。

neoforge:compostables

用于配置堆肥桶数值,替代 ComposterBlock.COMPOSTABLES(该字段现已被忽略)。文件位于 neoforge/data_maps/item/compostables.json,其中对象结构如下:

{
    // A 0 to 1 (inclusive) float representing the chance that the item will update the level of the composter
    "chance": 1,
    // Optional, defaults to false - whether farmer villagers can compost this item
    "can_villager_compost": false
}

示例:

{
    "values": {
        // Give acacia logs a 50% chance that they will fill a composter
        "minecraft:acacia_log": {
            "chance": 0.5
        }
    }
}

neoforge:furnace_fuels

用于配置物品燃烧时间。文件位于 neoforge/data_maps/item/furnace_fuels.json,对象结构如下:

{
    // A positive integer representing the item's burn time in ticks
    "burn_time": 1000
}

示例:

{
    "values": {
        // Give anvils a 2 seconds burn time
        "minecraft:anvil": {
            "burn_time": 40
        }
    }
}

说明 NeoForge 还添加了 IItemExtension#getBurnTime 方法,自定义物品可以重写它,并覆盖此数据映射。只有数据映射无法满足需求时才应使用该方法,例如燃烧时间取决于数据组件的情况。

警告 原版为 #minecraft:logs 与 #minecraft:planks 隐式添加 300 刻(15 秒)的燃烧时间,然后硬编码移除绯红和诡异木制品。因此,添加其他不可燃木材时,应从映射中移除其物品,例如:

{
    "replace": false,
    "values": [
        // values here
    ],
    "remove": [
        "examplemod:example_nether_wood_planks",
        "#examplemod:example_nether_wood_stems",
        "examplemod:example_nether_wood_door",
        // etc.
        // other removals here
    ]
}

neoforge:monster_room_mobs

用于配置怪物房刷怪笼可能生成的生物,替代 MonsterRoomFeature#MOBS(该字段现已被忽略)。文件位于 neoforge/data_maps/entity_type/monster_room_mobs.json,对象结构如下:

{
    // The weight of this mob, relative to other mobs in the datamap
    "weight": 100
}

示例:

{
    "values": {
        // Make squids appear in monster room spawners with a weight of 100
        "minecraft:squid": {
            "weight": 100
        }
    }
}

neoforge:oxidizables

用于配置氧化阶段,替代 WeatheringCopper#NEXT_BY_BLOCK(原文注明该字段从 1.21.2 起会被忽略)。此数据映射还用于构建反向的去氧化映射,供斧头刮除氧化层时使用。文件位于 neoforge/data_maps/block/oxidizables.json,对象结构如下:

{
    // The block this block will turn into once oxidized
    "next_oxidation_stage": "examplemod:oxidized_block"
}

提示 自定义方块必须实现 WeatheringCopperFullBlock 或 WeatheringCopper,并在 randomTick 中调用 changeOverTime,才能自然氧化。

示例:

{
    "values": {
        "mymod:custom_copper": {
            // Make a custom copper block oxidize into custom oxidized copper
            "next_oxidation_stage": "mymod:custom_oxidized_copper"
        }
    }
}

neoforge:parrot_imitations

用于配置鹦鹉模仿某种生物时发出的声音,替代 Parrot#MOB_SOUND_MAP(该字段现已被忽略)。文件位于 neoforge/data_maps/entity_type/parrot_imitations.json,对象结构如下:

{
    // The ID of the sound that parrots will produce when imitating the mob
    "sound": "minecraft:entity.parrot.imitate.creeper"
}

示例:

{
    "values": {
        // Make parrots produce the ambient cave sound when imitating allays
        "minecraft:allay": {
            "sound": "minecraft:ambient.cave"
        }
    }
}

neoforge:raid_hero_gifts

用于配置击退袭击后,特定 VillagerProfession 的村民可能赠送的礼物,替代 GiveGiftToHero#GIFTS(该字段现已被忽略)。文件位于 neoforge/data_maps/villager_profession/raid_hero_gifts.json,对象结构如下:

{
    // The ID of the loot table that a villager profession will hand out after a raid
    "loot_table": "minecraft:gameplay/hero_of_the_village/armorer_gift"
}

示例:

{
    "values": {
        "minecraft:armorer": {
            // Make armorers give the raid hero the armorer gift loot table
            "loot_table": "minecraft:gameplay/hero_of_the_village/armorer_gift"
        }
    }
}

neoforge:vibration_frequencies

用于配置游戏事件发出的幽匿振动频率,替代 VibrationSystem#VIBRATION_FREQUENCY_FOR_EVENT(该字段现已被忽略)。文件位于 neoforge/data_maps/game_event/vibration_frequencies.json,对象结构如下:

{
    // An integer between 1 and 15 (inclusive) that indicates the vibration frequency of the event
    "frequency": 2
}

示例:

{
    "values": {
        // Make the splash in water game event vibrate on the second frequency
        "minecraft:splash": {
            "frequency": 2
        }
    }
}

neoforge:villager_types

用于根据生物群系配置生成的村民类型,替代 VillagerType#BY_BIOME(此快照原文注明该字段从 26.2 起会被忽略)。文件位于 neoforge/data_maps/worldgen/biome/villager_types.json,对象结构如下:

{
    // The villager type that will spawn in this biome
    // If no villager type is specified for a biome, then `minecraft:plains` will be used
    "villager_type": "minecraft:desert"
    
}

示例:

{
    "values": {
        // Make villagers in the jungle biome be of the desert type
        "minecraft:jungle": {
            "villager_type": "minecraft:desert"
        }
    }
}

neoforge:waxables

用于配置方块涂蜡后(手持蜜脾右击)转变成的方块,替代 HoneycombItem#WAXABLES(原文注明该字段从 1.21.2 起会被忽略)。此数据映射还用于构建反向的去蜡映射,供斧头刮蜡使用。文件位于 neoforge/data_maps/block/waxables.json,对象结构如下:

{
    // The waxed variant of this block
    "waxed": "minecraft:iron_block"
}

示例:

{
    "values": {
        // Make gold blocks turn into iron blocks once waxed
        "minecraft:gold_block": {
            "waxed": "minecraft:iron_block"
        }
    }
}

来源: NeoForged/Documentation(1.21.1)。中文翻译依据提交 4a680cdd4d15。