@@ -95,29 +95,40 @@ class PlayerObject : LuaValue() {
9595 arg1 : LuaValue ?
9696 ): LuaValue ? {
9797 if (arg1?.isnumber() == true ) {
98- val raycast = mc.player?.raycast(arg1.todouble(), 1f , false )
99- if (raycast?.type == HitResult .Type .BLOCK && raycast is BlockHitResult ) {
100- val table = tableOf()
101- val blockPos = BlockPos (raycast.blockPos.x, raycast.blockPos.y, raycast.blockPos.z)
102- table.set(" type" , " block" )
103- table.set(" x" , blockPos.x)
104- table.set(" y" , blockPos.y)
105- table.set(" z" , blockPos.z)
106- return table
107- }
108- else if (raycast?.type == HitResult .Type .ENTITY && raycast is EntityHitResult ) {
109- val table = tableOf()
110- table.set(" type" , " entity" )
111- table.set(" data" , EntityUtils .ToLua (raycast.entity))
112- return table
113- }
114- else if (raycast?.type == HitResult .Type .MISS ) {
115- val table = tableOf()
116- table.set(" type" , " miss" )
117- return table
98+ val hitResult = mc.player?.raycast(arg1.todouble(), 1f , false )
99+ return when (hitResult?.type) {
100+ HitResult .Type .BLOCK -> {
101+ val table = tableOf()
102+ table.set(" type" , " block" )
103+ table.set(" x" , valueOf(hitResult.pos.x))
104+ table.set(" y" , valueOf(hitResult.pos.y))
105+ table.set(" z" , valueOf(hitResult.pos.z))
106+
107+ if (hitResult is BlockHitResult ) {
108+ val blockPos = tableOf()
109+ blockPos.set(" x" , valueOf(hitResult.blockPos.x))
110+ blockPos.set(" y" , valueOf(hitResult.blockPos.y))
111+ blockPos.set(" z" , valueOf(hitResult.blockPos.y))
112+ table.set(" blockPos" , blockPos)
113+ }
114+ table
115+ }
116+ HitResult .Type .ENTITY -> {
117+ val table = tableOf()
118+ if (hitResult is EntityHitResult ) {
119+ table.set(" type" , " entity" )
120+ table.set(" data" , EntityUtils .ToLua (hitResult.entity))
121+ }
122+ table
123+ }
124+ HitResult .Type .MISS -> {
125+ val table = tableOf()
126+ table.set(" type" , " miss" )
127+ table
128+ }
129+ else -> NIL
118130 }
119131 }
120-
121132 return NIL
122133 }
123134 }
0 commit comments