Posted September 4, 20187 yr Hello! I want to affect entities (items) that are dropped after block breaking with certain tool. I found only BlockBreakEvent which is called just before block is breaked so I cannot affect dropped items. What can I do? Is there some other event? Edited September 4, 20187 yr by Krevik
September 4, 20187 yr I think there’s an onHarvest (or something similar) event. There might also be a getDrops event? About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
September 4, 20187 yr Author Just now, diesieben07 said: HarvestDropsEvent can be used to change the drops of a block. THANKS! 1 minute ago, Cadiboo said: I think there’s an onHarvest (or something similar) event. There might also be a getDrops event? Thanks
September 4, 20187 yr Author 2 hours ago, diesieben07 said: HarvestDropsEvent can be used to change the drops of a block. Okay so I was trying, but the events doesn't seems to be working. Forge version: 2747. Method: Spoiler @SubscribeEvent public void blockBreakEvent(BlockEvent.HarvestDropsEvent event) { System.out.println("fired1"); EntityPlayer breaker = event.getHarvester(); List<ItemStack> items=event.getDrops(); ItemStack heldStack = breaker.getHeldItemMainhand(); Item heldItem = heldStack.getItem(); System.out.println("fired2"); if(!breaker.world.isRemote) { System.out.println("!remote"); if(heldItem.equals(KCore.Magnethium_Axe)) { System.out.println("equals1"); event.setDropChance(0); event.setCanceled(true); System.out.println("equals2"); for(int c=0;c<items.size();c++) { ItemStack itemStack=items.get(c); EntityItem currentItem=new EntityItem(breaker.world,event.getPos().getX()+0.5,event.getPos().getY()+0.5,event.getPos().getZ()+0.5,itemStack); breaker.world.spawnEntity(currentItem); currentItem.motionX=breaker.posX-currentItem.posX; currentItem.motionY=breaker.posY-currentItem.posY; currentItem.motionZ=breaker.posZ-currentItem.posZ; System.out.println("for"); } } } } No word is fired in console so it looks like the event isn't fired. Also I have another events in the same class and another are working
September 4, 20187 yr How are you registering your event handler class? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
September 4, 20187 yr Author 2 minutes ago, Draco18s said: How are you registering your event handler class? @Mod.EventHandler public void postInit(FMLPostInitializationEvent e) { MinecraftForge.EVENT_BUS.register(KathairisEventsHandler.class); } in the post init method of main mod class, but I don't think that matters cause another events in the same class are working Edited September 4, 20187 yr by Krevik update
September 4, 20187 yr The method isn't static and it needs to be if you are registering it like that. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
September 4, 20187 yr Author 2 minutes ago, Draco18s said: The method isn't static and it needs to be if you are registering it like that. Yeah that was the problem, thank you!
September 4, 20187 yr Author 33 minutes ago, diesieben07 said: That is not how you use this method! Please do not do this. so could you guide me what's wrong?
September 4, 20187 yr You need to remove the existing drops and add the new ones to the list. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
September 4, 20187 yr Author 24 minutes ago, Draco18s said: You need to remove the existing drops and add the new ones to the list. but that wouldn't let me affect theirs motions.
September 4, 20187 yr You shouldn't be doing that anway. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.