前提说明本教程基于0.0.2模组版本的KubeJS示例
本示例是当玩家首次进入女巫小屋时在玩家身后生成一个倒计时剩余一半的闪电苦力怕
const customRaidModule = new BaseRaidModule("creeper")
.readyTime(0)
.rewardTime(0)
.addWave([
new EntityInfoWithPredicateModule("minecraft:creeper")
.add(new NBTPredicate().add("Fuse", 15).add("powered", 1).build())
.amountModule(new IntegerAmountModule(1).build())
.build(),
])
.rewards(new ItemWeightedModule().build())
.build();
PlayerEvents.tick((event) => {
const { level, player } = event;
StructureUtils.handleProcessor(level, player.pos, "minecraft:swamp_hut", (serverLevel, boundingBox, blockPos, piece) => {
const worldPos = StructureUtils.getWorldPos(4, 2, 2, piece.getOrientation(), boundingBox);
if (!worldPos.equals(player.blockPosition()) || AftermathStageCap.hasStage(player, "creeper")) return;
const CreeperPos = StructureUtils.getWorldPos(4, 2, 1, piece.getOrientation(), boundingBox);
const baseRaid = new BaseRaid(customRaidModule, serverLevel, CreeperPos);
baseRaid.setProgressVisible(false);
const instance = AftermathManager.getInstance();
if (instance.create(baseRaid, serverLevel, worldPos, player)) {
AftermathStageCap.addStage(player, "creeper");
}
});
});