用户:
迷失冷光查看:0 回复:6 评论:0 创建时间:2020-08-10T14:41:05
话不多说,直接进入主题:
world.onPlayerLeave(({entity})=>{//当玩家离开
if(!entity.boatEntity){return}//还原船只
entity.boatEntity.meshInvisible = false;
entity.boatEntity.collides = true;
})
world.querySelectorAll('.boat').forEach((boat)=>{
boat.onEntityContact(({entity,other})=>{
if(other.mesh != ''){return}
entity.meshInvisible = true;
entity.collides = false;
other.position.set(49,12,50);
other.mesh = entity.mesh;
other.meshScale = entity.meshScale;
other.meshOrientation = new Box3Quaternion(0,1,0,0);
other.player.invisible = true;
other.player.enableDoubleJump = false;
other.player.showName = false;
other.boatEntity = entity;
world.querySelectorAll('player').forEach((players)=>{
if(players.player.name == other.player.name){
players.player.directMessage('你开走了小船,靠岸即可下船');
}else{
players.player.directMessage(entity.player.name+'开走了小船');
}
})
})
})
world.onVoxelContact(({entity,voxel})=>{
const plank = voxels.id('plank_02');
if(plank == voxel){
if(!entity.boatEntity){return}
entity.position.set(37.5,12,43);
entity.boatEntity.meshInvisible = false;
entity.boatEntity.collides = true;
entity.mesh = entity;
entity.player.enableDoubleJump = true;
entity.player.invisible = false;
entity.player.showName = true;
entity.boatEntity = null;
world.say(entity.player.name + '靠岸了');
}
})
知识点:
对象的变量也可以为对象。
还是那个小橙子丫imgsrc="https://static.cod喵/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
点赞0
评论