Jump to content

Polar Bears not dropping their meat


Recommended Posts

I was about to add bear meat to Polar Bears, but it didn't drop any meat at all! (Just some fish according to the vanilla game)

Here's the code for it:

    @SubscribeEvent
    public static void onLivingDeathEvent(LivingDeathEvent event) {
        Level level = event.getEntity().level();
        BlockPos pos = event.getEntity().blockPosition();
        Entity entity = event.getSource().getEntity();
        try {
            if (SmiffleModConfig.ENABLE_POLAR_BEAR_MEAT.get() && entity instanceof PolarBear) {
                int i = event.getEntity().level().getRandom().nextInt(2);
                if (i == 1) {
                    ItemEntity itemEntity = new ItemEntity(EntityType.ITEM, level);
                    itemEntity.setPos(pos.getX() + 0.5D, pos.getY() + 0.2D, pos.getZ() + 0.5D);
                    itemEntity.setItem(SmiffleModItems.BEAR_MEAT.get().getDefaultInstance());
                    event.getEntity().level().addFreshEntity(itemEntity);
                }
            }
        } catch(Exception e){
            SmiffleMod.LOGGER.warn("Tried to add unique behaviors to vanilla mobs when slain and encountered an error");
        }
    }

Hope you guys can fix this for me in time.

Link to comment
Share on other sites

could it be something whit the SmiffleModConfig.ENABLE_POLAR_BEAR_MEAT.get()

or could be coze onLivingDeathEvent has two entities

 

 

	@SubscribeEvent
public static void onLivingDeathEvent(LivingDeathEvent event) {
Level level = event.getEntity().level();
Entity target = event.getEntity();
Entity entity = event.getSource().getEntity();

if(!level.isClientSide() && target != null && entity != null ){
System.out.println("onLivingDeathEvent(" + entity.getDisplayName().getString() + ", " + target.getDisplayName().getString() + ")");
BlockPos pos = entity.blockPosition();
	

 Villager['Butcher'/47, l='ServerLevel[New World]', x=41.51, y=72.00, z=84.30] died, message: 'Butcher was slain by Zombie'
onLivingDeathEvent(Zombie, Butcher)

 

 

 

 

 

Link to comment
Share on other sites

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.