Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Event for player dropping an item? (1.19.4)

Featured Replies

Posted

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!!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.