- Баллы
- 76
- Имя в Minecraft
- AguRChek_TV
Как проверить нажатие ПКМ ?
Следуйте инструкциям в видео ниже, чтобы узнать, как установить наш сайт как веб-приложение на главный экран вашего устройства.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
PlayerInteractEvent#getAction()
RIGHT_CLICK_AIR
RIGHT_CLICK_BLOCK
Можно пример кода? Я пробовал но у меня ничего не получилось.
@EventHandler
public void playerInteract(PlayerInteractEvent e){
if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
//Код
}
}
Код:@EventHandler public void playerInteract(PlayerInteractEvent e){ if(e.getAction() == Action.RIGHT_CLICK_BLOCK){ //Код } }
Это исключение или ошибка в IDE?Я пробовал вот так:
@EventHandler
public void playerInteract(PlayerInteractEvent e){
Action a = e.getAction();
if(a != Action.RIGHT_CLICK_BLOCK && a != Action.RIGHT_CLICK_AIR) return;
}
}
-RIGHT_CLIK_BLOCK cannot be resolved or is not field
-RIGHT_CLIK_AIR cannot be resolved or is not field
Это исключение или ошибка в IDE?
Собери ядро нужной версии, и используй его как либу в проекте.А как мне это исправить ?
Собери ядро нужной версии, и используй его как либу в проекте.
Мб потому что у тебя CLIK, а не CLICK?Я пробовал вот так:
@EventHandler
public void playerInteract(PlayerInteractEvent e){
Action a = e.getAction();
if(a != Action.RIGHT_CLICK_BLOCK && a != Action.RIGHT_CLICK_AIR) return;
}
}
-RIGHT_CLIK_BLOCK cannot be resolved or is not field
-RIGHT_CLIK_AIR cannot be resolved or is not field
Нет у меня CLICKМб потому что у тебя CLIK, а не CLICK?
Мб потому что у тебя CLIK, а не CLICK?
Всё работает, просто у тебя Action импортирован не от туда.Я пробовал вот так:
@EventHandler
public void playerInteract(PlayerInteractEvent e){
Action a = e.getAction();
if(a != Action.RIGHT_CLICK_BLOCK && a != Action.RIGHT_CLICK_AIR) return;
}
}
-RIGHT_CLIK_BLOCK cannot be resolved or is not field
-RIGHT_CLIK_AIR cannot be resolved or is not field
@EventHandler
public void onInteract(PlayerInteractEvent e){
if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
//Код
}
}