• 周年纪念勋章活动已圆满结束,如有已购买但仍未申请的用户,可以通过对应勋章的下载链接申请~
BlocklyNukkit——缔造基岩版新生态 | 图形化插件制作器 & 多语言插件开发平台

插件 BlocklyNukkit——缔造基岩版新生态 | 图形化插件制作器 & 多语言插件开发平台 1.2.11

修复1.18.0以上版本兼容
## 1.2.9.10

- 修复了与1.7.30以上版本的兼容性
- 修复了自定义物品不显示贴图问题
  • 喜欢
反馈: Mcayear
## 1.2.9.6

Bug Fixed

- 修复了窗口回调接受窗口关闭无效的bug

Event

- AddMoneyEvent
- ReduceMoneyEvent
- SetMoneyEvent

New

- 小幅优化js加载性能
- 在核心同级文件夹创建新文件debug.inf即可启动js加载计时

manager

- void customEventListener(
String fullEventName, --要监听的事件的java类名
String callbackFunction, --事件回调函数
String priority --事件优先级,可选NORMAL MONITOR LOWEST LOW HIGH HIGHEST
) --动态监听事件
- WsClient createWsClient(
String serverUrl, --远程ws服务器链接
String newWsConnectCallback, --ws成功连接回调
String closeWsConnectCallback, --ws客户端断开连接回调
String receiveStringCallback, --接收到字符串数据回调
String receiveDataCallback --接收到非字符串数据回调
) --创建Ws客户端
- WsServer createWsServer(
int port, --端口
String newWsConnectCallback, --有新的ws客户端连接回调
String closeWsConnectCallback, --ws客户端断开连接回调
String receiveStringCallback, --接收到字符串数据回调
String receiveDataCallback --接收到非字符串数据回调
) --创建WebSocket服务器
- long timing.start() --启动计时,返回计时器id,对性能无影响
- long timing.end(long id) --结束计时,返回经过的纳秒
- long timing.finish(long id) --结束计时并将结果输出到控制台
- long timing.finish(String info) --结束最近一次启动的计时器并将经过的时间输出到控制台,info将作为输出的前缀

blockitem

- @Comment(value = "注册新的简易物品, 允许任意自定义物品")
public void registerSimpleItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "新物品的最大堆叠上限") int stackSize
,@Comment(value = "新物品的类别,可选construction nature equipment items") String type
,@Comment(value = "是否展示为工具(竖着拿在手里)") boolean isDisplayAsTool
,@Comment(value = "是否可装备在副手") boolean canOnOffhand
,@Comment(value = "物品初始化函数") @CallbackFunction(classes = {"cn.nukkit.item.Item"}, parameters = {"self"}, comments = {"新创建的物品自身"}) String initFunction)

- @Comment(value = "注册新的工具物品")
public void registerToolItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "工具种类,可为sword shovel pickaxe axe hoe") String toolType
,@Comment(value = "工具挖掘等级 0-空手,1-木,2-金,3-石,4-铁,5-钻石,6-下界合金") int toolTier
,@Comment(value = "工具耐久值") int durability
,@Comment(value = "攻击伤害") int attackDamage
,@Comment(value = "是否可装备在副手") boolean canOnOffhand
,@Comment(value = "物品初始化函数") @CallbackFunction(classes = {"cn.nukkit.item.Item"}, parameters = {"self"}, comments = {"新创建的物品自身"}) String initFunction)

- @Comment(value = "注册新的食物物品")
public void registerFoodItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "新物品的最大堆叠上限") int stackSize
,@Comment(value = "提供的饥饿度") int nutrition
,@Comment(value = "食用持续时间(刻)") int eatTime
,@Comment(value = "是否可装备在副手") boolean canOnOffhand
,@Comment(value = "物品初始化函数") @CallbackFunction(classes = {"cn.nukkit.item.Item"}, parameters = {"self"}, comments = {"新创建的物品自身"}) String initFunction)

- @Comment(value = "注册新的饮品物品")
public void registerDrinkItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "新物品的最大堆叠上限") int stackSize
,@Comment(value = "提供的饥饿度") int nutrition
,@Comment(value = "饮用持续时间(刻)") int drinkTime
,@Comment(value = "是否可装备在副手") boolean canOnOffhand
,@Comment(value = "物品初始化函数") @CallbackFunction(classes = {"cn.nukkit.item.Item"}, parameters = {"self"}, comments = {"新创建的物品自身"}) String initFunction)

- @Comment(value = "注册新的盔甲物品")
public void registerArmorItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "盔甲种类,可为helmet chest leggings boots") String armorType
,@Comment(value = "盔甲等级 0-无,1-皮革,2-铁,3-锁链,4-金,5-钻石,6-下界合金") int armorTier
,@Comment(value = "工具耐久值") int durability
,@Comment(value = "提供的盔甲值") int armorPoint
,@Comment(value = "是否可装备在副手") boolean canOnOffhand
,@Comment(value = "物品初始化函数") @CallbackFunction(classes = {"cn.nukkit.item.Item"}, parameters = {"self"}, comments = {"新创建的物品自身"}) String initFunction)
  • 喜欢
反馈: Mcayear
Bug Fixed

- 修复了自定义工具伤害问题
- 修复js中java包重导入报错
- 修复胡椒商店兼容性问题
- 修复不同模块同名函数调用混乱问题

New

- 注册自定义物品速度加快
- NPC寻路不再显示路径粒子

blockitem

- boolean isBlockWaterLogged(Block block) --检测方块是否为含水方块
- void addSoundFile(String soundName, String fileName) --向材质包添加新的声音文件
- void addArmorTexture(@Comment(value = "物品id") int id
,@Comment(value = "盔甲物品栏材质图片路径") String inventoryPicturePath
,@Comment(value = "盔甲穿着时材质图片路径") String modelPicturePath
,@Comment(value = "4d盔甲模型文件(.json),可不填") String modelJSONPath)
--为自定义盔甲添加4d模型

BNNPC

- void start(Player player) --只对某一个玩家启动显示

entity

- RouteFinder buildRouteFinder(Entity entity) --为实体构建寻路器

manager

- void concurrentRun(String functionName, <E+>... args) --并行运行函数
- void jvm.close(int returnCode / void) --强制关闭jvm并返回返回值,可不填,默认为0
- JMemory jvm.getMemory() --获取jvm内存管理器
- Class jvm.getJVMClass(String className) --根据类名获取jvm类对象
- JClass jvm.newJVMClass(@Comment(value = "java类名") String className
,@Comment("继承自的父类类名,可不填") String extendFromClass / void
,@Comment("实现的接口类名,可不填") String... interfaceClasses / void)
- 创建新的java类构造器

JClass

- JClass addConstructor(String modifier, String proxyFunction, String... argumentClasses)
- 为新java类添加构造函数
- modifier是构造函数修饰符,如public final等等
- proxyFunction是对应处理的bn插件函数名,调用时传入构造函数的所有参数,第一个参数永远是类自身,其余为自定义参数
- argumentClasses是构造函数自定义参数的类名
- 返回自身,便于链式调用
- JClass addField(String modifier, String fieldClass, String fieldName, Object defaultValue / void)
- 为新java类添加字段(又称属性或成员变量)
- modifier是字段修饰符,如public final等等
- fieldClass是字段类名
- fieldName是字段名称,需遵守java规范
- defaultValue是字段的默认值,可以不填,默认没有默认值而非默认值为null
- 返回自身,便于链式调用
- JClass addMethod(String modifier, String returnClass, String methodName, String proxyFunction, String... argumentClasses)
- 为新java类添加方法(又称成员函数)
- modifier是方法修饰符,如public final等等
- returnClass是方法返回值,无返回值填入void即可
- methodName是方法名称
- proxyFunction是对应处理的bn插件函数名,调用时传入方法的所有参数,第一个参数永远是类自身,其余为自定义参数
- argumentClasses是构造函数自定义参数的类名
- 返回自身,便于链式调用
- JClass finish()
- 完成java类构造,此时java类才可以使用,且不可再次更改
- 返回自身,便于链式调用
- Object newInstance(Object... args)
- 实例化自身,即对自身构建的java类进行new
- 必须在finish之后才能使用!

JMemory

- long getMax() --获取JVM最大可用内存大小
- long getFree() --获取JVM剩余内存大小
- long getTotal() --获取JVM总内存大小
- void gc() --进行内存清理

RouteFinder

- Entity getEntity()
- void setSearchLimit(int searchLimit)
- int getSearchLimit()
- void setStart(Vector3 start)
- Vector3 getStart()
- void setDestination(Vector3 destination)
- Vector3 getDestination()
- void setLevel(Level level)
- Level getLevel()
- void setBoundingBox(AxisAlignedBB bb)
- AxisAlignedBB getBoundingBox()
- boolean hasNext()
- Node next()
- boolean hasReachedNode(Vector3 vec)
- Node get()
- void forceStop()
- void arrived()
- boolean hasRoute()
- boolean search()
- boolean research()
- boolean isSearching()
- boolean isSuccess()
## 1.2.9.4

New

- Js已经支持for of循环
- Js中修复了错误的=>实现
- Js中新增宏注释://pragma optimistic,添加后bn将会为此代码在载入期间激进地进行类型推导以优化运行时性能
- bnp支持.phpfile后缀名
- bnp和bnpx可以直接放入plugins文件夹加载
- 小幅优化性能
- js中可以直接使用类的全名使用java类,无需进行Java.type或require引入
- 材质包不会无谓地重复生成

HttpHandler

- 回调参数中新增getRequestRawUrl函数

BNNPC

- 优化ai算法,避免npc消失bug

manager

- addCommandCompleter新增@sub规则,表示一个子命令补全选项
- @Comment(value = "是否运行在PowerNukkit上")
public boolean isPowerNukkit()

inventory

- @Comment(value = "新建一个漏斗物品栏")
public HopperFakeInventory addHopperInv(@Comment(value = "包含的物品,需要使用`Java.to`函数转换") Item[] item
,@Comment(value = "物品栏标题") String name)

blockitem

- @Comment(value = "注册新的简易物品, 允许任意自定义物品")
public void registerSimpleItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "新物品的最大堆叠上限") int stackSize
,@Comment(value = "新物品的类别,可选construction nature equipment items") String type
,@Comment(value = "是否展示为工具(竖着拿在手里)") boolean isDisplayAsTool
,@Comment(value = "是否可装备在副手") boolean canOnOffhand)

- @Comment(value = "注册新的工具物品")
public void registerToolItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "工具种类,可为sword shovel pickaxe axe hoe") String toolType
,@Comment(value = "工具挖掘等级 0-空手,1-木,2-金,3-石,4-铁,5-钻石,6-下界合金") int toolTier
,@Comment(value = "工具耐久值") int durability
,@Comment(value = "攻击伤害") int attackDamage
,@Comment(value = "是否可装备在副手") boolean canOnOffhand)

- @Comment(value = "注册新的食物物品")
public void registerFoodItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "新物品的最大堆叠上限") int stackSize
,@Comment(value = "提供的饥饿度") int nutrition
,@Comment(value = "食用持续时间(刻)") int eatTime
,@Comment(value = "是否可装备在副手") boolean canOnOffhand)

- @Comment(value = "注册新的饮品物品")
public void registerDrinkItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "新物品的最大堆叠上限") int stackSize
,@Comment(value = "提供的饥饿度") int nutrition
,@Comment(value = "饮用持续时间(刻)") int drinkTime
,@Comment(value = "是否可装备在副手") boolean canOnOffhand)

- @Comment(value = "注册新的盔甲物品")
public void registerArmorItem(@Comment(value = "新物品的id") int id
,@Comment(value = "新物品的名称") String name
,@Comment(value = "盔甲种类,可为helmet chest leggings boots") String armorType
,@Comment(value = "盔甲等级 0-无,1-皮革,2-铁,3-锁链,4-金,5-钻石,6-下界合金") int armorTier
,@Comment(value = "工具耐久值") int durability
,@Comment(value = "提供的盔甲值") int armorPoint
,@Comment(value = "是否可装备在副手") boolean canOnOffhand)

- @Comment(value = "添加新的盔甲材质")
public void addArmorTexture(@Comment(value = "物品id") int id
,@Comment(value = "盔甲物品栏材质图片路径") String inventoryPath
,@Comment(value = "盔甲穿着时材质图片路径") String modelPath)

- @Comment(value = "添加新的物品材质")
public void addItemTexture(@Comment(value = "物品id") int id
,@Comment(value = "物品材质图片路径") String path)

- @Comment(value = "为指定id物品添加中文翻译名")
public void addItemChineseTranslation(@Comment(value = "物品id") int id
,@Comment(value = "中文名") String name)

- @Comment(value = "为指定id物品添加英文翻译名")
public void addItemEnglishTranslation(@Comment(value = "物品id") int id
,@Comment(value = "英文名") String name)

- @Comment(value = "向材质包中指定位置添加json文件")
public void addResourcePackJsonEntry(@Comment(value = "材质包内相对位置,包含路径和文件全名") String entryPath
,@Comment(value = "json文件内容") String json)

- @Comment(value = "向材质包中指定位置添加图片文件")
public void addResourcePackPictureEntry(@Comment(value = "材质包内相对位置,包含路径和文件全名") String entryPath
,@Comment(value = "要复制到材质包中的硬盘上的图片路径") String path)

world

- void defineChunkRenderAll(String callback,int priority / void)
- 为所有世界添加地形渲染器
- callback是渲染器回调函数
- priority是优先级,优先级越大先调用,不填默认为0

entity

- @Comment(value = "构建4d展示模型")
public BNModel buildModel(@Comment(value = "生成模型的位置") Position pos
,@Comment(value = "模型4d皮肤id") String modelSkinID
,@Comment(value = "模型长") double length
,@Comment(value = "模型宽") double width
,@Comment(value = "模型高") double height
,@Comment(value = "模型缩放比例") double scale
,@Comment(value = "定时回调函数") @CallbackFunction(classes = {"com.blocklynukkit.loader.other.Entities.BNModel","int"}, parameters = {"model", "tick"}, comments = {"执行此函数的模型实体", "当前实体运行刻"}) String tickCallback
,@Comment(value = "定时回调函数回调间隔(刻)") int callTick
,@Comment(value = "被攻击回调函数") @CallbackFunction(classes = {"com.blocklynukkit.loader.other.Entities.BNModel","cn.nukkit.event.entity.EntityDamageEvent"}, parameters = {"model", "damageEvent"}, comments = {"执行此函数的模型实体", "实体受到的伤害事件"}) String attackCallback
,@Comment(value = "实体交互回调函数") @CallbackFunction(classes = {"com.blocklynukkit.loader.other.Entities.BNModel","cn.nukkit.Player","cn.nukkit.item.Item","cn.nukkit.math.Vector3"}, parameters = {"model","player","item","clickPos"}, comments = {"执行此函数的模型实体", "发起交互的玩家", "交互使用的物品", "交互点击的位置"}) String interactCallback)
Bug Fixed

- 修复了bnp无法加载自定义模块名问题
- 修复了BN浮空字能被打的问题
- 去掉了陈旧的bnmiscbuild命令
Bug Fixed

- 修复了异步JSON与YAML互转的问题,大幅提升转换速度
- js中可以使用箭头函数
- js中可以通过require(java类名/文件名)来调用java类或其他插件
- 修复了js解析器错误解析字符串中的正则表达式的问题
- 修复了manager.doPathCreate无法创建文件夹问题
- 修复了BlackBE合作API错误的问题
- 修复了PowerNukkit1.4.0.x生物兼容问题
- NPC有默认皮肤了

Module

- 通过注释宏:pragma module 模块名定义模块
- 定义模块后,可以通过模块名来引入其他模块中的导出函数

manager

- void appendFile(String path,String text)
- 追加写入文件内容

entity

- BNNPC buildNPC(Position pos,String name)
- void displayHurt(Entity e)
- void displayDie(Entity e)

blockitem

- void addFishingResult(String type,Item item,double chance)
- 添加钓鱼产物,type为新增产物种类,item是产物物品,changce是概率权重
- type可以取TREASURES;宝藏;JUNKS;垃圾;FISHES;鱼类,中英文皆可

algorithm

- Position buildPosition(double x,double y,double z,Level level)

New Event

- BNInitializedEvent
- 在所有bn插件都初始化后发出
- 无成员函数,无法被取消
- BNClosedEvent
- 在bn被nk要求关闭的时候发出
- 无成员函数,无法被取消
- StartFishingEvent
- 在玩家开始钓鱼的时候发出
- Player getPlayer() -返回钓鱼的玩家
- EntityFishingHook getFishingHook() -返回钓鱼钩实体
- void setCancelled(boolean cancel/void) -设置取消事件
- boolean isCancelled() -事件是否被取消

BNPM

- 新增了BNPM插件管理器,用于一键安装、更新,快速分发插件
- 命令:
- bnpm install 插件名 -安装或更新指定插件
- bnpm delete 插件名 -卸载指定插件
- 相关链接:
- bnpm插件中心:https://wiki.blocklynukkit.com/bnpm/viewPlugin
Bug Fixed

- 修复射箭函数中参数依赖问题
- 修复方块实体无法不坠落
- 重构BNNPC的AI架构,修复bnnpc两格高出不去问题
- 修复bn插件包资源文件解压错误问题
- PHP更友善的debug
- 修复PHP超时bug
- 修复world.clearChunk
- 修复localstroage缓存出错问题
- 修复切换雷暴天气不下雨的问题
- 清理部分无用的代码
- js中可以使用pragma es6
- 修复获取在线玩家报错问题

particle

- void drawDot(Position pos,int pid)
- void drawDot(Position pos,int pid,Player toPlayer)
- void drawDot(Position pos,int pid,int data)
- void drawDot(Position pos,int pid,int r,int g,int b)
- void drawDot(Position pos,int pid,int data,Player toPlayer)
- void drawDot(Position pos,int pid,int r,int g,int b,Player toPlayer)
- void drawEmitter(Position pos) --随机粒子发生器
- void drawEmitter(Position pos,String id)
- void drawEmitter(Position pos,String id,Player toPlayer)
- 粒子发生器id列表:
- minecraft:arrow_spell_emitter, minecraft:balloon_gas_particle, minecraft:basic_bubble_particle,
minecraft:basic_bubble_particle_manual, minecraft:basic_crit_particle, minecraft:basic_flame_particle,
minecraft:basic_portal_particle, minecraft:basic_smoke_particle, minecraft:bleach,
minecraft:block_destruct, minecraft:block_slide, minecraft:blue_flame_particle, minecraft:breaking_item_icon,
minecraft:breaking_item_terrain, minecraft:bubble_column_bubble, minecraft:bubble_column_down_particle,
minecraft:bubble_column_up_particle, minecraft:camera_shoot_explosion, minecraft:campfire_smoke_particle,
minecraft:campfire_tall_smoke_particle, minecraft:cauldron_spell_emitter, minecraft:cauldron_bubble_particle,
minecraft:cauldron_splash_particle, minecraft:colored_flame_particle, minecraft:conduit_particle,
minecraft:conduit_absorb_particle, minecraft:conduit_attack_emitter, minecraft:critical_hit_emitter,
minecraft:crop_growth_emitter, minecraft:dolphin_move_particle, minecraft:dragon_breath_fire, minecraft:dragon_breath_lingering,
minecraft:dragon_breath_trail, minecraft:dragon_death_explosion_emitter, minecraft:dragon_destroy_block,
minecraft:dragon_dying_explosion, minecraft:enchanting_table_particle, minecraft:endrod, minecraft:end_chest,
minecraft:elephant_tooth_paste_vapor_particle, minecraft:evocation_fang_particle, minecraft:evoker_spell,
minecraft:cauldron_explosion_emitter, minecraft:death_explosion_emitter, minecraft:egg_destroy_emitter,
minecraft:eyeofender_death_explode_particle, minecraft:misc_fire_vapor_particle, minecraft:explosion_particle,
minecraft:explosion_manual, minecraft:eye_of_ender_bubble_particle, minecraft:falling_border_dust_particle,
minecraft:falling_dust, minecraft:falling_dust_concrete_powder_particle, minecraft:falling_dust_dragon_egg_particle,
minecraft:falling_dust_gravel_particle, minecraft:falling_dust_red_sand_particle, minecraft:falling_dust_sand_particle,
minecraft:falling_dust_scaffolding_particle, minecraft:falling_dust_top_snow_particle, minecraft:fish_hook_particle,
minecraft:fish_pos_particle, minecraft:guardian_attack_particle, minecraft:guardian_water_move_particle,
minecraft:heart_particle, minecraft:honey_drip_particle, minecraft:huge_explosion_lab_misc_emitter,
minecraft:huge_explosion_emitter, minecraft:ice_evaporation_emitter, minecraft:ink_emitter, minecraft:knockback_roar_particle,
minecraft:lab_table_heatblock_dust_particle, minecraft:lab_table_misc_mystical_particle, minecraft:large_explosion,
minecraft:lava_drip_particle, minecraft:lava_particle, minecraft:llama_spit_smoke, minecraft:magnesium_salts_emitter,
minecraft:mobflame_emitter, minecraft:mobflame_single, minecraft:mobspell_emitter, minecraft:mob_block_spawn_emitter,
minecraft:mob_portal, minecraft:mycelium_dust_particle, minecraft:nectar_drip_particle, minecraft:note_particle,
minecraft:obsidian_glow_dust_particle, minecraft:obsidian_tear_particle, minecraft:phantom_trail_particle,
minecraft:portal_directional, minecraft:portal_east_west, minecraft:portal_north_south, minecraft:portal_reverse_particle,
minecraft:rain_splash_particle, minecraft:redstone_ore_dust_particle, minecraft:redstone_repeater_dust_particle,
minecraft:redstone_torch_dust_particle, minecraft:redstone_wire_dust_particle, minecraft:rising_border_dust_particle,
minecraft:shulker_bullet, minecraft:silverfish_grief_emitter, minecraft:soul_particle, minecraft:sparkler_emitter,
minecraft:splash_spell_emitter, minecraft:sponge_absorb_water_particle, minecraft:squid_flee_particle,
minecraft:squid_ink_bubble, minecraft:squid_move_particle, minecraft:stunned_emitter, minecraft:totem_particle,
minecraft:totem_manual, minecraft:underwater_torch_particle, minecraft:villager_angry, minecraft:villager_happy,
minecraft:water_drip_particle, minecraft:water_evaporation_actor_emitter, minecraft:water_evaporation_bucket_emitter,
minecraft:water_evaporation_manual, minecraft:water_splash_particle_manual, minecraft:water_splash_particle,
minecraft:water_wake_particle, minecraft:wither_boss_invulnerable

entity

- Entity spawnFallingBlock(Position pos, Block block, boolean enableGravity,boolean canBePlaced)
- EntityArrow shootArrow(Position from,Position to,Entity shooter,boolean canPickUp,double multiply)
- EntityArrow shootArrow(Position from,Position to,boolean canPickUp,double multiply)
- EntityArrow shootArrow(Position from,Position to,double multiply)
- EntityArrow shootArrow(Position from,Position to,boolean canPickUp)
- EntityArrow shootArrow(Position from,Position to)
- EntitySnowball shootSnowball(Position from,Position to,Entity shooter,boolean canPickUp,double multiply)
- EntitySnowball shootSnowball(Position from,Position to,boolean canPickUp,double multiply)
- EntitySnowball shootSnowball(Position from,Position to,double multiply)
- EntitySnowball shootSnowball(Position from,Position to,boolean canPickUp)
- EntitySnowball shootSnowball(Position from,Position to)

manager

- void removeCommand(String name) --移除名为name的命令
- void sendMail(String smtpMailServer,String from,String to,String cc,String bcc,String subject,String content)
- 发送电子邮件,默认为utf-8编码
- \<E> syncCallFunction(String functionName,Object... args) --同步执行函数
- void jvmGC() --垃圾回收,释放无用内存
- String getPlayerDeviceOS(Player player) --获取玩家设备操作系统
- boolean createHttpServer(int port)
- void startHttpServer(int port)
- boolean attachHandlerToHttpServer(int port,String path,String functionName)
- boolean attachHandlerToHttpServer(int port,String path,F function)
- 在指定端口的http服务器上绑定请求处理器,当请求path路径时该处理器被调用
- 路径指去掉域名和端口后面,?的前面的部分,以/开头

http服务器回调函数

- 参数(HttpRequestEntry request);
- request成员函数:
- String getRequestUrl()
- String getPath()
- String getHeader()
- String getMethod()
- String getParameter()
- String getProtocol()
- String getFromAddress()
- void addResponseHeaderEntry(String name,String value)
- void addResponseHeader(String header)
- void addDefaultResponseHeader()
- void addDefaultResponseHeader(String charSet)
- boolean response(int statusCode,String content)
- boolean response(int statusCode,String content,String charSet)
- boolean response(int statusCode,byte[] content)

blockitem

- void addShapedCraft(String shape,Item output,(String key,Item value)...)
- 这是更舒服的添加有序合成API,shape是合成形状字符串,
- 用一个字母或数字代表合成原材料的摆放方式,用"|"来连接三行,用空格来占格,如果最后的一行或列没有东西,请不要保留
- output是合成产物,后面的参数是映射表,key是你之前的shape中的字符,value是这个key代表的物品
- shape中有多少种字符串就得有多少个这也的映射参数
- 例如 石镐:addShapedCraft("SSS| I | I ",石镐物品,"S",圆石物品,"I",木棍物品)
- 工作台: addShapedCraft("MM|MM",工作台物品,"M",橡木木板物品)
- void registerSimpleItem(int id,String name,int stackSize/void)
- 注册简单的物品堆,只能覆写教育版物品,stackSize指定最大堆叠数量,不填为64
- void makeDropItem(Position position, Item item, boolean fly) --fly指定生成物品时物品是否具有随机初速度
- void blockUpdate(Position position)

BNNPC

- void reFresh() --强制客户端刷新bnnpc以防止隐身
  • 喜欢
反馈: Mcayear
new

重构代码加载器代码,重构了bnqqbot代码,增强稳定性,精简解释器
添加bn插件包功能,.bnp(bn插件集合包)和.bnpx(bn插件复合压缩包)可以放到blocklynukkit文件夹里面直接运行
使用bnp命令可以操作包,bnp build <makefile路径>即可构建一个bn插件包
makefile是一个json格式的包配置文件,由name,compress,plugins三个字段组成
name为打包的插件包的名字(字符串),compress为是否打出压缩插件包(boolean),
plugins是一个字符串数组,里面标注要打进包中的bn插件的路径,加载时从上到下加载,
也可以打进去json yml xml txt格式的资源文件,资源文件将会被按顺序解压到打包时与nk核心的相对位置解压。
js中可以使用console了
现在js插件报错会显示正确的文件名了
F(Closure function)函数用于包装闭包
bnAPI中的;换行现在支持使用\\;来转义
修复了php中F(闭包)函数返回类型错误的问题
修复了logger(console)输出null或nil报错的问题
修复了无法监听修改version命令的问题
新增预处理语句pragma autoload false/true,是否让bn解释器自动加载此插件,默认true
修复了射箭不会触发EntityDamageByEntityEvent问题
修复了http处理时url无法自动编码问题

PHP

更新了基于quercusPHP6引擎的php插件编写支持
quercus提供的运行环境请看http://quercus.caucho.com/quercus-3.1/doc/quercus.xtp
兼容全部的java类、nukkit的api和bn的基对象,调用bn的api记得前面加$

C/C++

更新了基于webassembly技术栈的C/C++插件编写支持
可以直接调用java并于java进行交互,一次编译,处处运行,支持windows linux macos

export

可以通过导出标记将bn插件中的函数导出到全局环境中,然后即可使用java类
命令exportdevjar <BN插件名>将可以导出bn插件中的函数头到一个jar包里面便于开发

javascript:
```javascript
export function MyFun(arg1,arg2,arg3){}
```

python:
```python
@export
def MyFun(arg1,arg2,arg3):
pass
```

lua:
```lua
function BlockPlaceEvent(ent)-->export

end
```

php:
```php
static function PlayerJoinEvent($event){

}
```

logger

- 强化了logger的功能,现在可以将对象以json格式输出

database

- localStorage: 本地存储管理器
- void localStorage.cacheAll() --从本地读取数据并缓存,增加运行时获取数据速度
- String localStorage.cache(String key) --从本地读取指定数据并缓存
- void localStorage.setItem(String key,String item) --设置指定key对应的数据为item
- String localStorage.getItem(String key) --获取指定key对应的数据
- void localStorage.removeItem(String key) --移除指定key对应的数据
- String[] localStorage.getKeys() --获取所有的key
- void localStorage.save() --强制立即保存数据,bn会每3秒检查并保存一次数据
- memoryStorage: 内存共享存储管理器
- void memoryStorage.setItem(Object key,Object item) --设置指定key对应的数据为item
- String memoryStorage.getItem(Object key) --获取指定key对应的数据
- void memoryStorage.removeItem(Object key) --移除指定key对应的数据
- Object[] localStorage.getKeys() --获取所有的key

manager

- Player[] getOnlinePlayers()
- String getResource(String name) -- 读取资源
- void runCMD(String cmd) --执行命令行程序
- boolean isPathExists(String path)
- String[] getFolderFiles(String path)
- int getFileSize(String path)
- void deleteFile(String path)
- void doPathCreate(String path)
- boolean isPathReadable(String path)
- boolean isPathWritable(String path)
- void copyFile(String fromPath,String toPath)
- void qq.stopBot()
- void interrupt(String info) --强制中断当前函数运行
- void downloadFromURL(String url,String saveDir,String saveName)
- Thread runThread(String functionName,Object... args) --在新线程中执行函数并同步返回这个线程
- void requireMinVersion(String minVersion,String failMessage) --检查bn解释器版本,如果太低停止运行并发出failMessage

entity

- void shootArrow(Position from,Position to,boolean canPickUp,double multiply)
- void shootArrow(Position from,Position to,double multiply)
- void shootArrow(Position from,Position to,boolean canPickUp)
- void shootArrow(Position from,Position to)
- void lookAt(Entity e,Position pos)

window

- int[] setPlayerBossBar的第二个text参数中若以#XXXXXX或者rgb(x,x,x)开头将会为boss血条设置自定义颜色
- int[] setPlayerBossBar现在可以在text参数中使用;来添加多个bossbar
- int[] setPlayerBossBar(Player player,String text,float len) --现在返回数组,包含每个创建的bossbar的id
- void removePlayerBossBar(Player player,long id) --相关api现在支持指定bossbar的id操作
- double getLengthOfPlayerBossBar(Player player,long id)
- String getTextOfPlayerBossBar(Player player,long id)
- void sendPlayerXboxInfo(Player from,Player to) --向to玩家展示from玩家的xbox信息
- void startEndPoem(Player player) --让玩家屏幕上开始展示终末之诗
- void setSwingStyle(String style) --设置swing的样式
- 目前有:Darcula Intellij Metal Motif Multi Nimbus OS(系统样式)
- JFrame getStyledSwingWindow(String title,int width,int height,String iconPath)
- 根据之前设置的样式获取Swing窗口对象,iconPath为null或""将使用bnLOGO替代

WindowBuilders

- void showToPlayer(Player p,String callback,boolean acceptClose)
- acceptClose用于指定是否在窗口关闭的时候调用一次回调函数

SimpleWindowBuilder

- buildButton(String text,String img)
- button(String text,String img)
- button(String text)
- setAction(String actionFunctionName/F function)
- action(String actionFunctionName/F function)
- setTitle(String title)
- title(String title)
- setContext(String context)
- context(String context)
- showToPlayer(Player p)
- showToPlayer(Player p,boolean acceptClose)
- showToPlayer(Player p,String callbackFunctionName/F function)
- showToPlayer(Player p,String callbackFunctionName/F function,boolean acceptClose)
- show(Player p)
- show(Player p,boolean accpetClose)
- show(Player p,String callbackFunctionName/F function)
- show(Player p,String callbackFunctionName/F function,boolean acceptClose)

ModalWindowBuilder

- setTitle(String title)
- title(String title)
- setContext(String context)
- context(String context)
- setButton1(String text)
- setButton2(String text)
- button1(String text)
- button2(String text)
- setAction(String callbackFunctionName/F function)
- action(String callbackFunctionName/F function)
- showToPlayer(Player p)
- showToPlayer(Player p,boolean acceptClose)
- showToPlayer(Player p,String callbackFunctionName/F function)
- showToPlayer(Player p,String callbackFunctionName/F function,boolean acceptClose)
- show(Player p)
- show(Player p,boolean accpetClose)
- show(Player p,String callbackFunctionName/F function)
- show(Player p,String callbackFunctionName/F function,boolean acceptClose)

CustomWindowBuilder

- setTitle(String title)
- showToPlayer(Player p)
- showToPlayer(Player p,boolean acceptClose)
- showToPlayer(Player p,String callbackFunctionName/F function)
- show(Player p)
- show(Player p,boolean accpetClose)
- show(Player p,String callbackFunctionName/F function)
- show(Player p,String callbackFunctionName/F function,boolean acceptClose)
- showToPlayer(Player p,String callbackFunctionName/F function,boolean acceptClose)
- showAsSetting(Player p, String callbackFunctionName/F function)
- showAsSetting(Player p, String imageURL, String callbackFunctionName/F function)
- buildLabel(String text)
- label(String text)
- buildInput(String title,String placeholder)
- input(String title,String placeholder)
- buildInput(String title,String placeholder,String defaulttext)
- input(String title,String placeholder,String defaulttext)
- buildToggle(String title)
- toggle(String title)
- buildToggle(String title,boolean open)
- toggle(String title,boolean open)
- buildDropdown(String title,String inner)
- dropdown(String title,String inner)
- buildDropdown(String title,String inner,int index)
- dropdown(String title,String inner,int index)
- buildSlider(String title,double min,double max,int step,double defaultvalue)
- slider(String title,double min,double max,int step,double defaultvalue)
- buildSlider(String title,double min,double max,int step)
- slider(String title,double min,double max,int step)
- buildSlider(String title,double min,double max)
- slider(String title,double min,double max)
- buildStepSlider(String title,String options)
- stepSlider(String title,String options)
- stepslider(String title,String options)
- buildStepSlider(String title,String options,int index)
- stepSlider(String title,String options,int index)
- stepslider(String title,String options,int index)
- setAction(String callbackFunctionName/F function)
- action(String callbackFunctionName/F function)



BNNPC

- void addExtraDropItem(Item item)
- boolean hasDropItem(Item item)
- void removeExtraDropItem(Item item)
- Item[] getExtraDropItems()
- Item[] getDropItems()
- void setDropHand(boolean drop/void) --参数不填时默认为true
- void setDropOffhand(boolean drop/void) --参数不填时默认为true
- void addDropSlot(int slot) --指定背包槽位死亡掉落
- int[] getDropSlots()
- void removeDropSlot(int slot)
- void doEmote(String action/void) --让npc执行指定的表情动作
- action可以是 Wave Punch Clap OverThere Hammer Fall Diamond Pickaxe
- 也可以填写对应的中文 挥手 拳击 鼓掌 在那 锤子 摔倒 钻石
- 不填的话将上面的五个动作中任选一个
- 至于为什么只有8个: 因为剩下的要氪金购买之后才能获取uuid,冰凉没钱
- 欢迎大家贡献uuid
- boolean directMove(Position to) --直线移动到某处

world

- void regenerateChunk(Position pos)
- void defineChunkRenderByName(String forLevel,String callback,int priority / void)
- forLevel是渲染器能够渲染的指定世界名称
- callback是渲染器回调函数
- priority是优先级,优先级越大先调用,不填默认为0
- void drawPic(Position pos1,Position pos2,String img,int faceData)
- 从pos1到pos2绘制img路径上的图片,faceData指定物品展示框的朝向,pos1和pos2必须在同一垂直面上

blockitem

- void registerSolidBlock(int id,String name,double hardness,double resistance,int toolType,boolean isSilkTouchable,int dropMinExp,int dropMaxExp,int mineTier)
- 注册固体方块,参数分别为方块id(只能覆写教育版方块),方块名称,方块硬度,方块抗爆炸度,挖掘工具,是否受精准采集影响,最小掉落经验,最大掉落经验,挖掘等级
- 方块硬度越大挖掘时间越长,抗爆炸度越高越不容易被炸
- 挖掘工具0-无,1-剑,2-铲,3-镐,4-斧,5-剪刀
- 挖掘等级0-空手,1-木,2-金,3-石,4-铁,5-钻石
- void registerSimpleItem(int id,String name)
- 注册简单的物品堆,只能覆写教育版物品
new

更新了qq机器人对接模块,使用小栗子qq机器人框架(因为这是唯一一个没跑路的免费机器人了),配好的包在bn群内下载
您也可以从官网下载框架并自行安装tcpapi.dll插件到机器人框架中,bn通过tcpapi来与其交互
添加了com.blocklynukkit.JavaAPI类来提供bn对java的api
添加了调试工具,使用命令bndebug打开调试工具,可以查看变量和监控命令情况

Lua

添加了lua语言支持,版本为luaj5.2,可以通过lua来制作bn插件,接口与js和py完全相同
您需要使用:来访问基对象函数,此外还提供了用于和java交互的luajava对象和asTable asList asMap三个全局函数
详见bn开发文档

Bug Fixed

- 修复了熔炉配方nbt丢失问题
- 修复了设置箱子和漏斗物品栏不好使的问题
- 修复了py插件不可用问题
- 修复了BNNPC在路径移动时被击退遁地问题
- 修复了BNNPC导致的区块报错问题

BNNPC

- Array<Player> getPlayersIn(double distance)
- Array<Entity> getEntitiesIn(double distance)
- Player getNearestPlayer(double far)
- Player getNearestPlayer()
- void setEntityRideOn(Entity entity)
- void isEntityRideOn(Entity entity)
- void setEntityRideOff(Entity entity)
- Player getRidingPlayer()

window

- setPauseScreenList(String list) --设置暂停界面右侧显示在线玩家区域的文字,用;分割多行

CustoWindowBuilder

- this showAsSetting(Player p, String imageURL, String callback) --支持图标,和按钮图标书写方式相同

manager

- void qq.startBot() 启动qq机器人进程
- void qq.reDirectBot(String ip)
- 将机器人重定向到指定ip地址,并使用那台电脑的小栗子qq机器人框架
- 要求目标电脑开放8404-TCP端口,并且在小栗子的tcpapi插件中允许远程控制
- void qq.sendFriendMessage(String fromQQ,String toQQ,String message) 发送好友信息
- void qq.sendGroupMessage(String fromQQ,String toGroup,String message) 发送群信息
- void qq.sendGroupPicMessage(String fromQQ,String toGroup,String picturePaths,String message)
- 发送qq图文消息
- picturePaths用;分割多个本地图片路径
- 消息中使用图片只需用%picture数字%即可,数字指代第几个路径的图片,从0开始算起
- void qq.kickGroupMember(String fromQQ,String toGroup,String toQQ) --踢了指定群员,fromQQ是机器人账号
- void qq.banSpeakGroupMember(String fromQQ,String toGroup,String toQQ,int second) --禁言指定群员
- String getPlayerDeviceID(Player player) --获取玩家的手机或电脑设备标识码
- String getPlayerDeviceModal(Player player) --获取玩家的设备型号
- int getPlayerDeviceOS(Player player) -- 获取玩家的操作系统id
- double getMoney(String player)
- void reduceMoney(String player,double money)
- void addMoney(String player,double money)
- void setMoney(String player,double money)
- void setNukkitCodeVersion(String string) -- 修改version命令显示的nk版本
- void nodejs.eval(String str,boolean isPath) -- 使用nodejs运行str
- 运行nodejs代码是隔离在nodejs环境运行的,而非java环境
- 若isPath为true,则执行该路径的文件
- 否则将str作为nodejs代码执行
- 其中可以使用callFunction(String BNFunctionName,String args...)来调用bn插件的函数
- void nodejs.newDocker(String dockerName,String str,boolean isPath) --开启一个常驻nodejs容器
- dockerName是创建的nodejs容器的名字,容器一旦创建就会立即开始执行其中的代码
- 重启创建后执行完代码不会被销毁,而是可以继续通过callDockerFunction调用其中方法
- 如果需要在其他bn插件调用其中的nodejs函数,需要使用registerFunction(String 函数名,Function 函数)注册
- 其余同nodejs.eval函数
- void nodejs.closeDocker(String dockerName) --关闭指定的nodejs容器并释放占用资源
- String callDockerFunction(String function,String... args)
- 调用指定容器中的指定函数并向其传参,调用的函数必须先注册再使用,否则bn无法获取此函数内存地址进行调用
- 返回值将自动被转为字符串,如果被调函数无返回值则返回字符串"null"
- function指定调用的函数,格式为 容器名::函数名(同其他地方的调用格式)
- 若直接输入函数名,则将在所有未关闭容器中随机寻找一个有此名称函数的容器调用,若找不到,返回NO FUNCTION
- args参数只接受字符串,数量不限,也可没有
- TaskHandler createTask(String functionName, int delay ,\<E+\>... args)
- TaskHandler createLoopTask(String functionName, int delay,\<E+\>... args)
- 支持2-128个任意数量的参数,第一个参数为回调函数名,第二个为回调间隔tick,其余的是在调用函数时向函数传递的参数
- void newPlugin(String path) --加载指定路径上的bn插件
- void newJSPlugin(String name,String code) --根据代码字符串创建一个新的bn插件
- void newPYPlugin(String name,String code)
- void newLUAPlugin(String name,String code)
- void addCommandCompleter(String cmd,String id,String completer)
- 创建命令补全器,将被发送给玩家用作命令提示和tab补全
- cmd为要添加给的命令的名称,id为补全器标识符,随意只要不重复即可
- completer是补全器内容,由\<必选单元>和\[可选单元]由空格连缀组成
- 每个单元的内部格式为 名称:@类型=参数1;参数2;... 等于号及其后面的部分不是必须的
- 类型有:@target @blockpos @pos @int @float @string @TEXT
- 类型有:@message @Command @json @filepath @operator
- 例如:\<player:@target\> \<sentence:@message=BNNB!;blocklynukkit\> \[color:@text=red;green\]

EventLoader

- QQGroupMessageEvent --机器人收到qq群消息事件
- String getSelfQQ() --获取收到消息的qq账号
- String getFromQQ() --获取发送消息的qq账号
- String getFromGroup() --获取消息事件的qq群号
- String getMessage() -获取消息
- QQFriendMessageEvent --机器人收到qq好友消息事件
- String getEventId() --获取事件id
- String getEventSeed() --获取事件中的群消息标识码
- String getFromQQ() --获取发送消息的qq
- String getSelfQQ() --获取接受到群消息的qq账号
- String getMessage() --获取事件的消息
- QQOtherEvent
- String getFromGroup() --获取触发事件的qq群号
- String getFromQQ() --获取触发事件的qq账号
- String getSelfQQ() --获取收到事件的qq账号
- String getSeq() --获取收到事件的标识id
- int getType() --获取事件类型码

Entity

- void setPlayerExp(Player player,int exp)
- int getPlayerExp(Player player)
- void setPlayerExpLevel(Player player,int lel)
- int getPlayerExpLevel(Player player)
- void setPlayerHunger(Player player,int hunger)
- int getPlayerHunger(Player player)
- void makeSoundToPlayer(Player player,String sound)
- Entity spawnEntity(String name,Position pos) --返回值更改
  • 喜欢
反馈: Mcayear
后退
顶部 底部