ブロック
- 板やブロック、ガラス、羊毛などなど
- ブロックによって何かを建てたり、設備を作ってみたりしている。
- ブロックを出現させるなどという処理はあまりしたくない。
- 秘密の階段を出現させるなどは、できるとゲームが面白くなる。
実装
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
World world = player.getWorld();
Location playerlocation = player.getLocation();
world.spawn(new Location(world, playerlocation.getX() + 3, playerlocation.getY(), playerlocation.getZ()), Chicken.class);
}
前回のこれを利用
world.spawn(new Location(world, playerlocation.getX() + 3, playerlocation.getY(), playerlocation.getZ()), Chicken.class);
ここを変更する。
まず「spawn」を「getBlockAt」に変更。
そこの特定のロケーションにあるブロックの情報を取ってきてくれる。
次に「Chicken.class」を消して変更。
最後の部分に「.setType(Material.DARK_OAK_WOOD)」を挿入
world.getBlockAt(new Location(world,
playerlocation.getX() + 3,
playerlocation.getY(),
playerlocation.getZ())).setType(Material.DARK_OAK_WOOD);
3歩先の空間を木のブロックに変える。
実行

成功!!!
ちなみに、違うものも出現させてみました。

成功!!!

違うものも出現させてみました。
「これはなんだろう?????😂」
コメント