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.

Featured Replies

Posted

Hi Guys,

sorry for my bad English, but anyway I need help with the Leafblocks.

 

I want that the Oakleaves drop apples everytime I break them with an specific item. Now I have to separate between all the Leafblocks (They have all the same ID, Metadata,...). Any ideas?

 

public class SaplingDrop extends Event {


    @SubscribeEvent
    public void onDrops(BlockEvent.HarvestDropsEvent event) {


        int meta;
        Block block = event.block;
        EntityPlayer player= event.harvester;
        World world = event.world;
        int x = event.x;
        int y = event.y;
        int z = event.z;

        if (block == Blocks.leaves /** && meta = *//) {

            LogHelper.info("ICH BIN DURCH 1");
            if(player.getHeldItem() !=null)
            {
                LogHelper.info("ICH BIN DURCH 2");
                if(player.getHeldItem().getItem() == ModItems.applePickerWood)
                {
                        LogHelper.error("ICH BIN DURCH 3");
                        world.spawnEntityInWorld(new EntityItem(world,x,y,z, new ItemStack(Items.apple, 3)));
                }
            }
        }
  }
}

  • Author

-According to the game they all have the same Metadata (4); i have checked that with all leafblocks that I manually placed...

-in my test the harvest event works fine and i also have tried the BlockBreak event. And I want to spawn it manually.

and yes I have read the docs...

 

But I can't find a way to trigger the event with the Damage Value, because I need the Damage Value to seperate the different leafblocks.

  • Author

I've changed my original answer, if I place a leaveblock manually it always had the Metadata of 4 (in my dev enviroment)

and thanks for "event.harvester!=null"; in the flat world I had no issue, but in a "normal" world I got and StackOverflow......

 

And with the spawnEntity I now that it will spawn, maybe I will this change later.

And with event.blockMetadata I have checked the Meta in the flatworld just to find out what I have to use.

 

Now that I looked at my code again I've realised that I had a logic fail in there... Now it works fine^^

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.