风清弊绝

By MCSugar_cane    2018/02/03

嗯?你说原版服务器里出现了熊孩子?还有作弊端?的确挺让人烦恼吼,不过这在"风清弊绝"面前都不是问题嘛~

代码适用版本为1.11.2-1.12,逻辑支持1.8.x以上版本

如果你是管理员,请输入/scoreboard players tag @p add op为自己开启权限


我的世界风清弊绝防熊模组0我的世界风清弊绝防熊模组1

图片就介绍到这里,下面是思路以及代码部分~


整体思路:

TNT放置清除与防爆十分简单,唯一值得注意的是TNT矿车的爆炸数据标签为{TNTFuse:},矿车被激活后便从80->0,在这里检测{TNTFuse:79}即可。TNT的爆炸数据标签为{Fuse:},爆炸与矿车相同。

其次就是如何检测玩家飞行,在计分板中有一条准则是统计飞行距离的,也就是"stat.flyOneCm"。当玩家飞行时,此计分板便会不断加分,似乎现在只要玩家该记分板被加分即可判定为飞行。

其实不然,除飞行外,当玩家从摔落,疾跑+跳跃...时,都会被"stat.flyOneCm"统计下来,在鞘翅飞行状态中不会算入"stat.flyOneCm"。

为了解决当前的问题,我做了个测试,玩家在同一高度上摔落下来与飞行上去,且路径一致,看其计分板的变化。发现飞行上去计分板增长的总值为摔落下来的3倍之多。并在2s也就是40gt(gametick,1s=20gametick)内,摔落增长的值为860+,飞行增长的值为2500+。

解决了检测飞行的问题,再来看疾跑+跳跃,按照之前的方法,在2s内,测试结果为疾跑+跳跃所增长的分数约为1900+,一直没有达到2000。所以便可以得出,在2s内,玩家飞行距离增长的值超过2000,则为飞行状态。另外,检测速移与此方法一致。


代码:

基础部分:

  1. /scoreboard objectives add tntHI dummy 爆炸危险次数
  2. /scoreboard objectives add puttnt stat.useItem.minecraft.tnt
  3. /scoreboard objectives add infly stat.flyOneCm
  4. /scoreboard objectives add walkspeed stat.walkOneCm
  5. /scoreboard objectives add runspeed stat.sprintOneCm
  6. /scoreboard objectives add btimer dummy

防止TNT放置:[高频循环]

  1. /execute @a[tag=!op,score_puttnt_min=1] ~ ~ ~ tellraw @a [{"text":"[风清弊绝] ","color":"gold","bold":true,"clickEvent":{"action":"open_url","value":"http://www.ganxiaozhe.com/mc/mlxt/201802030.html"}},"\u00a7e\u00a7l非管理员玩家",{"selector":"@p[r=0]","color":"red","bold":"true"},"\u00a7e\u00a7l尝试放置TNT"]
  2. /execute @a[tag=!op,score_puttnt_min=1] ~ ~ ~ fill ~-6 ~-6 ~-6 ~6 ~6 ~6 air 0 replace tnt
  3. /scoreboard players set @a[score_puttnt_min=1] puttnt 0

防止爆炸物:[高频循环]

  1. /scoreboard players tag @e[type=tnt_minecart] add gwrong {TNTFuse:79}
  2. /scoreboard players tag @e[type=tnt] add gwrong {Fuse:79s}
  3. /execute @e[type=!player,tag=gwrong] ~ ~ ~ tellraw @a [{"text":"[风清弊绝] ","color":"gold","bold":true,"clickEvent":{"action":"open_url","value":"http://www.ganxiaozhe.com/mc/mlxt/201802030.html"}},"\u00a7c\u00a7l探测到爆炸物,已清除。玩家",{"selector":"@a[r=7]","color":"dark_red","bold":"true"},"\u00a7c\u00a7l在爆炸物附近"]
  4. /execute @e[type=!player,tag=gwrong] ~ ~ ~ execute @a[r=7,score_tntHI_min=3] ~ ~ ~ tellraw @a [{"text":"[风清弊绝] ","color":"gold","bold":true,"clickEvent":{"action":"open_url","value":"http://www.ganxiaozhe.com/mc/mlxt/201802030.html"}},"\u00a77\u00a7l其中玩家",{"selector":"@p[r=0]","color":"dark_red","bold":"true"},"\u00a77\u00a7l是第",{"score":{"name":"@p[r=0]","objective":"tntHI"},"color":"yellow","bold":"true"},"\u00a77\u00a7l次被发现"]
  5. /execute @e[type=!player,tag=gwrong] ~ ~ ~ scoreboard players add @a[r=7] tntHI 1
  6. /kill @e[type=!player,tag=gwrong]

防止飞行与速移:[高频循环]

  1. /scoreboard players add @a[tag=!op] btimer 1
  2. /execute @a[score_btimer_min=40,score_btimer=40,score_infly_min=2000] ~ ~ ~ tellraw @a [{"text":"[风清弊绝] ","color":"gold","bold":true,"clickEvent":{"action":"open_url","value":"http://www.ganxiaozhe.com/mc/mlxt/201802030.html"}},"\u00a7e\u00a7l非管理员玩家",{"selector":"@p[r=0]","color":"red","bold":"true"},"\u00a7e\u00a7l正在飞行,现已被禁锢"]
  3. /execute @a[score_btimer_min=40,score_btimer=40,score_walkspeed_min=1600] ~ ~ ~ tellraw @a [{"text":"[风清弊绝] ","color":"gold","bold":true,"clickEvent":{"action":"open_url","value":"http://www.ganxiaozhe.com/mc/mlxt/201802030.html"}},"\u00a7e\u00a7l非管理员玩家",{"selector":"@p[r=0]","color":"red","bold":"true"},"\u00a7e\u00a7l正在速移,现已被禁锢"]
  4. /execute @a[score_btimer_min=40,score_btimer=40,score_runspeed_min=2000] ~ ~ ~ tellraw @a [{"text":"[风清弊绝] ","color":"gold","bold":true,"clickEvent":{"action":"open_url","value":"http://www.ganxiaozhe.com/mc/mlxt/201802030.html"}},"\u00a7e\u00a7l非管理员玩家",{"selector":"@p[r=0]","color":"red","bold":"true"},"\u00a7e\u00a7l正在速移,现已被禁锢"]
  5. /scoreboard players tag @a[score_btimer_min=40,score_btimer=40,score_infly_min=2000] add ban
  6. /scoreboard players tag @a[score_btimer_min=40,score_btimer=40,score_walkspeed_min=1600] add ban
  7. /scoreboard players tag @a[score_btimer_min=40,score_btimer=40,score_runspeed_min=2000] add ban
  8. /scoreboard players reset @a[score_btimer_min=41] infly
  9. /scoreboard players reset @a[score_btimer_min=41] walkspeed
  10. /scoreboard players reset @a[score_btimer_min=41] runspeed
  11. /scoreboard players set @a[score_btimer_min=41] btimer 1

处理被禁玩家:[高频循环]

  1. /execute @a[tag=ban] ~ ~ ~ tp @p[r=0,tag=ban] @p[r=0,tag=ban]
  2. /effect @a[tag=ban] blindness 10 255 true


OOC:

v1.11.2-v1.12
展开


欢迎加群交流划水:481528679