Posted September 23, 20159 yr 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))); } } } } }
September 23, 20159 yr 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.
September 23, 20159 yr 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.