Misaka。
本帖最后由 Misaka。 于 2020-10-25 10:49 编辑

我想检测一个方块的id,然后右键该种方块的时候,执行某效果
我使用创世神插件的/info功能检测的方块id  (因为我是1.12.2的mod服,方块放置出来后,id会改变)
但是却说无法检测到这个id,提示没有这种材料
mod的方块都会出现这种问题,原版的方块就没问题
#这里35是羊毛方块的ID,写35或者wool,都可以正常检测到,脚本正常运行
on right click on 35:
  if player is sneaking:
    stop
    cancel event
    execute console command "/tell %player% hi"
#这里1351是mod方块的ID,写数字id或英文名都不行,提示没有该材料
on right click on 1351:
  if player is sneaking:
    stop
    cancel event
    execute console command "/tell %player% hi"

sk版本是:2.2dev37c
服务端核心:cat1.12.2

(我在1.7版本使用该方法,可以正常运行脚本,但是升级到1.12就不行了,换低版本1.7的sk,结果会无法加载sk插件)

研究好半天了,还是没办法,是高版本不支持了吗或者是需要什么附属支持?


已找到解决办法:
on right click:
  if "%id of event-block%" is "623":
    send "a"




592764254
你可能需要一个变量的替换,比如
on script load:
    set {石头} to "stone" parsed as item

on right click:
    if tool is {石头}:
        message "666!"

把mod物品转换一次试试

Misaka。
592764254 发表于 2020-10-24 14:10
你可能需要一个变量的替换,比如
on script load:
    set {石头} to "stone" parsed as item

不行
on load:
  set {a} to "623" parsed as material
on right click:
  if tool is {a}:
    send "1"
  if block is {a}:
    send "2"

没有报错,右键后也没有反应
因为我是检测地上的方块 所以用到是material
我试过用item,还是一样的

592764254
Misaka。 发表于 2020-10-24 14:20
不行

没有报错,右键后也没有反应

把623换成mod物品的英文名字试试

Misaka。
592764254 发表于 2020-10-24 14:23
把623换成mod物品的英文名字试试

不行,没效果
另,我用sk的代码去获取已经放置在地上的mod方块
查不到方块的种类(名字),只能查到ID
on right click holding a wooden_sword:
  send "%id of clicked block%" to player
  send "%type of clicked block%" to player

id可以查到为623
type查不到,一直为air

已测试原版物品可以正常查到

592764254
Misaka。 发表于 2020-10-24 14:29
不行,没效果
另,我用sk的代码去获取已经放置在地上的mod方块
查不到方块的种类(名字),只能查到ID

可是你要查的不就是方块ID吗= =

Misaka。
592764254 发表于 2020-10-24 18:57
可是你要查的不就是方块ID吗= =

可以要触发right click
得用方块type
我只能检测出id

Misaka。
592764254 发表于 2020-10-24 18:57
可是你要查的不就是方块ID吗= =

找到办法了
on right click:
  if "%id of event-block%" is "623":
    send "a"

直接用id就行