Я работаю и хорошо пишу на Forge. Мне стал интересен Sponge. Но тут есть несколько непонятных мне моментов.
Как постваить блок в мир? Да это максимально глупо, но world.setBlockType(0, 100, 0, BlockTypes.DIAMOND_ORE);
не работает..... Вот полный код:
@Listener
public void onBlockBreak(ChangeBlockEvent event)
{
Cause cause = event.getCause();
EventContext context = event.getContext();
if(cause.containsType(Player.class)) {
Player firstPlayer = cause.first(Player.class).get();
firstPlayer.sendMessage(Text.of("игрок есть"));
if(context.containsKey(EventContextKeys.BLOCK_HIT))
{
firstPlayer.sendMessage(Text.of("блок есть"));
World world = firstPlayer.getWorld();
BlockSnapshot snapshot = context.get(EventContextKeys.BLOCK_HIT).get();
Location location = snapshot.getLocation().get();
if(location.getBlockX() == 0 && location.getBlockY() == 100 && location.getBlockZ() == 0)
{
firstPlayer.sendMessage(Text.of("локация совпадает"));
world.setBlockType(0, 100, 0, BlockTypes.DIAMOND_ORE);
}
}
}
}
Когда ломаю блок на 0 100 0 сообщение "локация совпадает" появляется, но блок не меняется. Тут по ходу дела будут еще вопросы(чтоб потоки не плодить).