Advancement JS

Forge Fabric Advancement JS 2024-08-12

模组加载器
  1. Forge
  2. Fabric
版权类型
转载
版权链接
https://www.mcmod.cn/class/13137.html
前置组件
https://link.mcmod.cn/target/aHR0cHM6Ly93d3cuY3Vyc2Vmb3JnZS5jb20vbWluZWNyYWZ0L21jLW1vZHMva3ViZWpz
资源语言
  1. 英语
适配版本
  1. 1.18
  2. 1.19
  3. 1.20
通过 KubeJS 配置的不仅仅是进步

快速示例(适用于最新版本)2.9.3)​

启动脚本​

JavaScript:
// Create a custom trigger
AdvJSEvents.trigger(event => {
event.create("advjs:get_adv")
// How many matches you defined, how many tests you should put in
// In this example, we defined 2 matches
.match(advancement => advancement.getId() == "minecraft:story/smelt_iron")
.match(playerName => playerName == "Dev")
})

服务器脚本​

JavaScript:
AdvJSEvents.advancement(event => {
const { PREDICATE, TRIGGER } = event;

// Define trigger
const jump5times = TRIGGER.tick(triggerBuilder =>
triggerBuilder.addStat(Stats.JUMP, Stats.CUSTOM, { min: 5 }));
const bred_in_nether = TRIGGER.bredAnimals(triggerBuilder => {
triggerBuilder.setChildByPredicate(PREDICATE.entityFromJson({
 stepping_on: {
dimension: "the_nether"
            }
        }))
    });
// AdvJS custom trigger
const destroy_dirt = TRIGGER.blockDestroyed(triggerBuilder => triggerBuilder.setBlock("dirt"));
// Your custom trigger
const get_adv = TRIGGER.custom("advjs:get_adv");

// Create root advancement
const root = event.create("advjs:hell")
.display(displayBuilder => {
displayBuilder.setTitle("AdvancementJS")
displayBuilder.setDescription("Quick example")
displayBuilder.setIcon("diamond")
        })
.criteria(criteriaBuilder => criteriaBuilder.add("dirt", destroy_dirt))
.rewards(rewardsBuilder => {
rewardsBuilder.setExperience(100)
// AdvJS custom reward
rewardsBuilder.addEffect("absorption", 200)
        })
// Make it repeatable
.repeatable();

// Add child for root
root.addChild("child1", childBuilder => {
        childBuilder
.display(displayBuilder => {
displayBuilder.setTitle(Text.red("Holy"))
displayBuilder.setDescription(Text.red("Hell starts"))
            })
.criteria(criteriaBuilder => {
// 'OR' means that if you want to achieve this advancement,
// you just need one of two triggers matched below
criteriaBuilder.setStrategy(RequirementsStrategy.OR)
criteriaBuilder.add("bred", bred_in_nether)
criteriaBuilder.add("jump", jump5times)
criteriaBuilder.add("get_adv", get_adv)
            })
.rewards(rewardsBuilder => {
rewardsBuilder.setRecipes("minecraft:lodestone", "minecraft:brewing_stand")
rewardsBuilder.setExperience(100)
            })
    });

// Remove an exist advancement by AdvancementFilter, available filter was writen in doc.
// you can also remove by id: 'event.remove("minecraft:story/lava_bucket");'
event.remove({
mod: "minecraft",
icon: "minecraft:lava_bucket",
frame: "task"
    });

// Modify an exist advancement
event.get("minecraft:story/smelt_iron")
// Apply offset to display
.displayOffset(1, 1, true)
.modifyDisplay(displayBuilder => displayBuilder.setIcon("diamond_pickaxe"))
.addChild("child2", childBuilder => {
            childBuilder
.display(displayBuilder => {
displayBuilder.setIcon("recovery_compass")
displayBuilder.setTitle('I will come back!')
displayBuilder.setDescription(Text.green("Good luck"))
// You can also apply display in DisplayBuilder
displayBuilder.offset(-1, 0)
                })
// The trigger could also be created from json
.criteria(criteriaBuilder => criteriaBuilder.add("go_back_to_home", TRIGGER.fromJson({
"trigger": "minecraft:changed_dimension",
 "conditions": {
"from": "minecraft:the_end",
"to": "minecraft:overworld"
                    }
                })))
// Check if parent done, else it will not be done
                .requireParentDone()
        });
})

AdvJSEvents.lock(event => {
event.result("stone_slab", "minecraft:story/smelt_iron");
event.itemUse("spyglass", "minecraft:story/smelt_iron");
event.blockInteract("chest", "minecraft:story/smelt_iron");
event.entityInteract("villager", "minecraft:story/smelt_iron");
})

// Compat with 'Better Advancements'
AdvJSEvents.betterAdv(event => {
event.modify("advjs:hell/child1").posX(0).posY(32).hideLines()
})

PlayerEvents.advancement(event => {
const player = event.getPlayer();
// The first argument is use for match player predicate, the other two is the matches you defined
CustomTriggers.of("advjs:get_adv").trigger(player, event.getAdvancement(), player.username)
})

如何重新加载​

只需使用/reload

特征​

  • 用于生成内置示例的命令/advjs
  • 您可以在 Startup 事件中创建自定义触发器。AdvJSEvents.trigger
  • AdvJS 自定义触发器
    • blockDestroyed:当玩家打破一个方块时触发。
    • playerTouch:当玩家触摸实体时触发。
    • bossEvent:当游戏加入 Boss 战时触发。
    • increaseKillScore:当玩家杀死一个实体时触发。
  • AdvJS 自定义奖励
    • addEffect:生效。
  • AdvJS 自定义方法
    • displayOffset(offsetX: number, offsetY: number, modifyChildren?: 布尔值)
      • 将偏移应用于 Advancement Display 及其子项
    • requireParentDone()
      • 检查父项是否完成,否则将不会完成。
    • requireOthersDone(requires[]: ...ResourceLocation)
      • 检查您投入的进步是否已经完成。
    • requireAnyDone(requires[]: ...ResourceLocation)
  • 兼容性
    • Better Advancements,新服务器事件:AdvJSEvents.betterAdv

链接​

报告问题查看源代码访问 wiki

特色版本​

查看全部
高级 JS 2001forge-2.9.4
锻造 1.20.1
释放
高级 JS 2001fabric-2.9.4
结构 1.20.1
释放
高级 JS 1902fabric-2.6.0
织物 1.19.2
释放
高级 JS 1902forge-2.6.0
锻造 1.19.2
释放
高级 JS 1802forge-1.9.0
锻造 1.18.2
释放
高级 JS 1802fabric-1.6.1
结构 1.18.2
释放

项目成员​


韦斯特纳特233
所有者
https://modrinth.com/user/westernat233
https://modrinth.com/user/westernat233
此为转载请勿商用,详见https://modrinth.com/mod/advancementjs
作者
dadada
下载
70
查看
99
首次发布
最后更新

评论

0.00 星 0 星

来自dadada的更多资源

  • Budget Fire Aspect
    Forge Budget Fire Aspect
    这个模式非常简单:当你着火时,你能在自己着火持续时间内点燃其他敌人。击中已经着火的敌人将会使他们自己的持续时间延长半秒。
  • The Banished
    Forge The Banished
    还记得古代文明蓬勃发展的时代吗?还记得猪灵英勇的的王国吗?......当众神统治 Minecraft 大陆时。众神被熟知和崇拜。
  • Omnis Backpacks
    Forge Omnis Backpacks
    Omnis Backpacks 这是一款添加了背包的模组!
  • DiscordSuite
    Forge DiscordSuite
    与Discord有关的mod
  • Project Osud
    Forge Project Osud
    从两把枪开始,创建一个你的国度来对抗死者。小心,因为亡灵们会在夜幕降临时来抓你。
后退
顶部 底部