BlockIterator iter = new BlockIterator(player, 10);
Block lastBlock = iter.next();
while (iter.hasNext()) {
lastBlock = iter.next();
if (lastBlock.getType() == Material.AIR) {
continue;
}
break;
}
Location loc = lastBlock.getLocation();
public final Block getTargetBlock(Player player, int range) {
BlockIterator iter = new BlockIterator(player, range);
Block lastBlock = iter.next();
while (iter.hasNext()) {
lastBlock = iter.next();
if (lastBlock.getType() == Material.AIR) {
continue;
}
break;
}
return lastBlock;
}
private staredAtBlock(Player player){
return player.getTargetBlock(null, 200);
}
private setStaredBlock(Block block){
staredAtBlock.setType(Material.TNT);
}
@EventHandler
public void onPlayerInteractBlockTeleport(PlayerInteractEvent event) {
Player player = event.getPlayer();
//Null check isn't necessary anymore, an empty item will have Material.AIR and getTargetBlock() now also works if no target block is found
if (player.getItemInHand().getType() == Material.BONE) {
Location playerLoc = player.getLocation(); //Get the player's location
Location target = player.getTargetBlock((Set) null, 200).getLocation().clone().add(0, 1, 0); //Get the block location + 1 y
target.setYaw(playerLoc.getYaw()); //Set the yaw of the target location to the player's yaw
target.setPitch(playerLoc.getPitch()); //Set the pitch of the target location to the player's pitch
player.teleport(target); //Teleport player
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 10, 1); //Play sound
}
}
function Check ()
{
var hit : RaycastHit;
if (Physics.Raycast (transform.position,transform.forward) && hit.collider.name == "Door")
{
this.transform.position = target.position;
}
}
Nie wiem który kod Ci pomoże , ale na pewno nie ten ostatni bo ten ostatni to z Unity 3D wyciąłem
~Obstawiam że ten przedostatni //Rejszpat