Tomask4

Untitled

Jul 28th, 2025
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. package net.mcreator.annoyingmod.procedures;
  2.  
  3. import net.neoforged.neoforge.event.entity.player.PlayerEvent;
  4. import net.neoforged.fml.common.EventBusSubscriber;
  5. import net.neoforged.bus.api.SubscribeEvent;
  6. import net.neoforged.bus.api.Event;
  7.  
  8. import net.minecraft.world.item.ItemStack;
  9. import net.minecraft.world.entity.player.Player;
  10. import net.minecraft.world.entity.Entity;
  11.  
  12. import javax.annotation.Nullable;
  13.  
  14. @EventBusSubscriber
  15. public class SetCraftingOutputProcedure {
  16. @SubscribeEvent
  17. public static void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
  18. execute(event, event.getEntity());
  19. }
  20.  
  21. public static void execute(Entity entity) {
  22. execute(null, entity);
  23. }
  24.  
  25. private static void execute(@Nullable Event event, Entity entity) {
  26. if (entity == null)
  27. return;
  28. if (entity instanceof Player _player && _player.containerMenu instanceof AnnoyingmodModMenus.MenuAccessor _menu) {
  29. _menu.getSlots().get(0).set(ItemStack.EMPTY);
  30. _player.containerMenu.broadcastChanges();
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment