Posted June 27, 20232 yr Hi there! I am currently trying to create a feature where an event is triggered when the player drops an item, and I want to stop the player from dropping it if a boolean is set to true. What event can I use to do this? I've looked at other events and I can't seem to find one that isn't deprecated. A few that I've tried are things like onItemToss, onPlayerDropItem, and onPlayerDestroyItem, but they all appear to be deprecated and not functional. With this in mind, what other event is out there that could work for my project? Thank you!!
June 27, 20232 yr on_toss it is // #################### #################### #################### @SubscribeEvent public static void on_toss(ItemTossEvent event) { Entity entity = event.getEntity(); Level warudo = entity.level; if (entity instanceof ItemEntity) { ItemEntity item_e = (ItemEntity) entity; ItemStack itemstack = item_e.getItem(); System.out.println("\n ItemTossEvent " + itemstack.getDisplayName().getString() + "\n"); // #################### #################### if (itemstack.getItem() == ItemInit.INGOT_IRON_RED_HOT.get() && !warudo.isClientSide) { try { red_hot_iron_entity w_entity = new red_hot_iron_entity(EntityInit.RED_HOT_IRON_ENTITY.get(), warudo, item_e); w_entity.setPos(item_e.getX(), item_e.getY(), item_e.getZ()); warudo.addFreshEntity(w_entity); } catch (Exception e) { System.out.println("Something went wrong." + e.toString()); } } // #################### #################### if (itemstack.getItem() == Items.EGG && !warudo.isClientSide) { System.out.println("\n\n EGGGGGGG \n\n"); try { ItemStack itemdrop = new ItemStack(Items.FEATHER, 1); ItemEntity newdrop = new ItemEntity(warudo, (double) (entity.position().x), (double) (entity.position().y + 1.0F), (double) (entity.position().z), itemdrop); warudo.addFreshEntity(newdrop); } catch (Exception e) { System.out.println("Something went wrong." + e.toString()); } } } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.