Отслеживание предметов, упавших на землюJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Гость
 Отслеживание предметов, упавших на землю

Сообщение Гость »


I'm making a spigot plugin that makes dropped item explode when it touched the ground and the version I'm working on is Minecraft 1.20.2(paper server) with spigot 1.20.2 API.
The problem is that when I drop a item, it just keeps falling and nothing happened even after the item touches the ground.
I have found out that when I tried to get the location of the item, its value remains on the location I dropped it.
This is my code now.

Код: Выделить всё

    @EventHandler
public void onItemDrop(PlayerDropItemEvent e) {

Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,new Runnable() {
public void run() {
if (e.getItemDrop().getItemStack().getItemMeta().getDisplayName().equals(ItemControl.unstable_tnt.getItemMeta().getDisplayName())) {
Location location = e.getItemDrop().getLocation();
while (location.add(0,-1,0).getBlock().getType() == Material.AIR) {
location = e.getItemDrop().getLocation();
System.out.println(location.add(0,-1,0));
System.out.println(location.add(0,-1,0).getBlock().getType());
}
System.out.println("explode");
World world = location.getWorld();
for (int i=0;i

Источник: [url]https://stackoverflow.com/questions/77839773/tracking-items-dropped-to-the-ground[/url]
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»