LightningEvent.java 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * This file is part of architectury.
  3. * Copyright (C) 2020, 2021, 2022 architectury
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 3 of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this program; if not, write to the Free Software Foundation,
  17. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. package me.shedaniel.architectury.event.events;
  20. import me.shedaniel.architectury.event.Event;
  21. import me.shedaniel.architectury.event.EventFactory;
  22. import net.minecraft.world.entity.Entity;
  23. import net.minecraft.world.entity.LightningBolt;
  24. import net.minecraft.world.level.Level;
  25. import net.minecraft.world.phys.Vec3;
  26. import java.util.List;
  27. public interface LightningEvent {
  28. // TODO Pre - Invoked before a lightning bolt entity is added to the world. (cancellable)
  29. /**
  30. * @see Strike#onStrike(LightningBolt, Level, Vec3, List)
  31. */
  32. Event<Strike> STRIKE = EventFactory.createLoop();
  33. // TODO Post - Invoked before a lightning bolt entity is removed from the world.
  34. interface Strike {
  35. /**
  36. * Invoked after the lightning has gathered a list of entities to strike.
  37. *
  38. * @param bolt The lightning bolt.
  39. * @param level The level the lighting is spawned in.
  40. * @param pos The position the lightning strikes.
  41. * @param toStrike A list of all entities the lightning affects.
  42. */
  43. void onStrike(LightningBolt bolt, Level level, Vec3 pos, List<Entity> toStrike);
  44. }
  45. }