PlayerEvent.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * This file is part of architectury.
  3. * Copyright (C) 2020, 2021 shedaniel
  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 me.shedaniel.architectury.utils.IntValue;
  23. import net.minecraft.advancements.Advancement;
  24. import net.minecraft.core.BlockPos;
  25. import net.minecraft.server.level.ServerPlayer;
  26. import net.minecraft.world.Container;
  27. import net.minecraft.world.InteractionResult;
  28. import net.minecraft.world.entity.item.ItemEntity;
  29. import net.minecraft.world.entity.player.Player;
  30. import net.minecraft.world.inventory.AbstractContainerMenu;
  31. import net.minecraft.world.item.ItemStack;
  32. import net.minecraft.world.level.Level;
  33. import net.minecraft.world.level.block.state.BlockState;
  34. import org.jetbrains.annotations.Nullable;
  35. public interface PlayerEvent {
  36. Event<PlayerJoin> PLAYER_JOIN = EventFactory.createLoop(PlayerJoin.class);
  37. Event<PlayerQuit> PLAYER_QUIT = EventFactory.createLoop(PlayerQuit.class);
  38. Event<PlayerRespawn> PLAYER_RESPAWN = EventFactory.createLoop(PlayerRespawn.class);
  39. Event<PlayerAdvancement> PLAYER_ADVANCEMENT = EventFactory.createLoop(PlayerAdvancement.class);
  40. Event<PlayerClone> PLAYER_CLONE = EventFactory.createLoop(PlayerClone.class);
  41. Event<CraftItem> CRAFT_ITEM = EventFactory.createLoop(CraftItem.class);
  42. Event<SmeltItem> SMELT_ITEM = EventFactory.createLoop(SmeltItem.class);
  43. Event<PickupItemPredicate> PICKUP_ITEM_PRE = EventFactory.createInteractionResult(PickupItemPredicate.class);
  44. Event<PickupItem> PICKUP_ITEM_POST = EventFactory.createLoop(PickupItem.class);
  45. Event<DropItem> DROP_ITEM = EventFactory.createLoop(DropItem.class);
  46. Event<OpenMenu> OPEN_MENU = EventFactory.createLoop(OpenMenu.class);
  47. Event<CloseMenu> CLOSE_MENU = EventFactory.createLoop(CloseMenu.class);
  48. Event<BreakBlock> BREAK_BLOCK = EventFactory.createInteractionResult(BreakBlock.class);
  49. interface PlayerJoin {
  50. void join(ServerPlayer player);
  51. }
  52. interface PlayerQuit {
  53. void quit(ServerPlayer player);
  54. }
  55. interface PlayerRespawn {
  56. void respawn(ServerPlayer newPlayer, boolean conqueredEnd);
  57. }
  58. interface PlayerClone {
  59. void clone(ServerPlayer oldPlayer, ServerPlayer newPlayer, boolean wonGame);
  60. }
  61. interface PlayerAdvancement {
  62. void award(ServerPlayer player, Advancement advancement);
  63. }
  64. interface CraftItem {
  65. void craft(Player player, ItemStack smelted, Container inventory);
  66. }
  67. interface SmeltItem {
  68. void smelt(Player player, ItemStack smelted);
  69. }
  70. interface PickupItemPredicate {
  71. InteractionResult canPickup(Player player, ItemEntity entity, ItemStack stack);
  72. }
  73. interface PickupItem {
  74. void pickup(Player player, ItemEntity entity, ItemStack stack);
  75. }
  76. interface DropItem {
  77. InteractionResult drop(Player player, ItemEntity entity);
  78. }
  79. interface BreakBlock {
  80. InteractionResult breakBlock(Level world, BlockPos pos, BlockState state, ServerPlayer player, @Nullable IntValue xp);
  81. }
  82. interface OpenMenu {
  83. void open(Player player, AbstractContainerMenu menu);
  84. }
  85. interface CloseMenu {
  86. void close(Player player, AbstractContainerMenu menu);
  87. }
  88. }