#loader crafttweaker reloadableevents//导包import crafttweaker.world.IWorld;import crafttweaker.block.IBlock;import crafttweaker.world.IBlockPos;import crafttweaker.player.IPlayer;import crafttweaker.data.IData;import mods.ctutils.utils.Math;import crafttweaker.events.IEventManager;import crafttweaker.event.BlockBreakEvent;import crafttweaker.event.BlockPlaceEvent;//方块破坏事件events.onBlockBreak(function(event as BlockBreakEvent){ var world as IWorld = event.world; var player as IPlayer = event.player; var pos as IBlockPos = event.position;//读取TE数据必须要通过IWorld.getBlock(pos)来获取 var block as IBlock = world.getBlock(pos); var worldData as IData = world.getCustomChunkData(pos);//判此处判断对应流程图 if(!world.remote && !player.creative && !isNull(block.data)){ if(block.data has "subTileName"){ if(block.data.subTileName.asString() == "endoflame"){//判断符合,data-1//因为创造模式是不会产生data数据,所以不需要非空判断 var upDate as IData = {endoflame : worldData.endoflame.asInt() - 1}; world.updateCustomChunkData(upDate, pos); } } }});//方块放置事件events.onBlockPlace(function(event as BlockPlaceEvent){ var world as IWorld = event.world; var player as IPlayer = event.player; var pos as IBlockPos = event.position;//读取TE数据必须要通过IWorld.getBlock(pos)来获取 var block as IBlock = world.getBlock(pos); var worldData as IData = world.getCustomChunkData(pos);//判此处判断对应流程图 if(!world.remote && !isNull(block.data) && !player.creative){ if(block.data has "subTileName"){ if(block.data.subTileName.asString() == "endoflame"){ if(!(worldData has "endoflame")){// 第一次 world.setCustomChunkData({endoflame : 0}, pos); var upDate as IData = {endoflame : 1}; world.updateCustomChunkData(upDate, pos); }else if(worldData.endoflame.asInt() > 3){// >3 player.sendChat("此区块火红莲已达上限"); event.cancel(); }else{// <3 var upDate as IData = {endoflame : worldData.endoflame.asInt() + 1}; world.updateCustomChunkData(upDate, pos); } } } }});