Jump to content

Recommended Posts

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

Posted

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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