Помогите Установить урон к коде

  • Автор темы Автор темы iniga7
  • Дата начала Дата начала

iniga7

Новичок
Пользователь
Баллы
21
Имя в Minecraft
BeTePaH
Как установить урон при попадании в игрока ?
@EventHandler
public void PlayerInteractEvent(final PlayerInteractEvent e) {
e.getPlayer().launchProjectile((Class)Arrow.class);
}
Я лишнюю часть кода убрал. Как при попадании стрелы через этот метод нанести игроку определённый урон или дать какой-то эффект ?
 
Источник: bukkit
PHP:
Arrow arrow = null;
Location location = player.getLocation();
location.setX(location.getX() + direction.getX() * (1 + Math.random() * arrowCount));
location.setY(location.getY() + 1.5f);
location.setZ(location.getZ() + direction.getZ() * (1 + Math.random() * arrowCount));

arrow = player.getWorld().spawnArrow(location, direction, speed, spread);

if (arrow == null)
{
    sendMessage("One of your arrows fizzled");
    return SpellResult.FAILURE;
}

arrow.setShooter(player);

if (useFire) {
    arrow.setFireTicks(300);
}

// Hackily make this an infinite arrow and set damage
try {
    Method getHandleMethod = arrow.getClass().getMethod("getHandle");
    Object handle = getHandleMethod.invoke(arrow);
    Field fromPlayerField = handle.getClass().getField("fromPlayer");
    fromPlayerField.setInt(handle, 2);
    Method setDamageMethod = handle.getClass().getMethod("b", Double.TYPE);
    setDamageMethod.invoke(handle, damage);
} catch (Throwable ex) {
    ex.printStackTrace();
}
arrow.setTicksLived(300);
 
Источник: bukkit
PHP:
Arrow arrow = null;
Location location = player.getLocation();
location.setX(location.getX() + direction.getX() * (1 + Math.random() * arrowCount));
location.setY(location.getY() + 1.5f);
location.setZ(location.getZ() + direction.getZ() * (1 + Math.random() * arrowCount));

arrow = player.getWorld().spawnArrow(location, direction, speed, spread);

if (arrow == null)
{
    sendMessage("One of your arrows fizzled");
    return SpellResult.FAILURE;
}

arrow.setShooter(player);

if (useFire) {
    arrow.setFireTicks(300);
}

// Hackily make this an infinite arrow and set damage
try {
    Method getHandleMethod = arrow.getClass().getMethod("getHandle");
    Object handle = getHandleMethod.invoke(arrow);
    Field fromPlayerField = handle.getClass().getField("fromPlayer");
    fromPlayerField.setInt(handle, 2);
    Method setDamageMethod = handle.getClass().getMethod("b", Double.TYPE);
    setDamageMethod.invoke(handle, damage);
} catch (Throwable ex) {
    ex.printStackTrace();
}
arrow.setTicksLived(300);
Какой то бред)
 
Назад
Верх