40 lines
874 B
Markdown
40 lines
874 B
Markdown
# IScriptRayTrace — giriş
|
|
|
|
[← IScriptRayTrace](index.md) · [← Master](../../wiki.md)
|
|
|
|
mchorse.mappet.api.scripts.user
|
|
|
|
Interface IScriptRayTrace
|
|
|
|
public interface IScriptRayTrace
|
|
|
|
This interface represents a ray tracing result.
|
|
|
|
function main(c)
|
|
{
|
|
var result = c.getSubject().rayTrace(32);
|
|
|
|
if (result.isBlock())
|
|
{
|
|
// Ray hit a block, so we'll change the block to diamond block
|
|
var pos = result.getBlock();
|
|
|
|
c.getWorld().setBlock(mappet.createBlockState("minecraft:diamond_block", 0), pos.x, pos.y, pos.z);
|
|
}
|
|
else if (result.isEntity())
|
|
{
|
|
// Ray hit an entity, so we'll throw it in the air
|
|
result.getEntity().setMotion(0, 1, 0);
|
|
}
|
|
else // if (result.isMissed())
|
|
{
|
|
c.send("Good luck next time!");
|
|
}
|
|
}
|
|
|
|
|
|
Method Summary
|
|
All Methods Instance Methods Abstract Methods
|
|
|
|
Modifier and Type Method and Description
|