Jump to content

DudeGuyCraft

Members
  • Posts

    3
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

DudeGuyCraft's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Awesome that fixed it. Thanks!
  2. Ok, I changed it up a bit as to avoid getting errors if that is null. Maybe a bit excessive, but this is what I did: @SubscribeEvent public void onEvent(BlockEvent.HarvestDropsEvent event) { Item breaker = null; if (event.harvester != null && event.harvester.getCurrentEquippedItem() != null && event.harvester.getCurrentEquippedItem().getItem() != null) { breaker = event.harvester.getCurrentEquippedItem().getItem(); } if (event.drops != null && event.drops.size() != 0) { for (int x = event.drops.size() - 1; x >= 0; x--) { if (FurnaceRecipes.smelting().getSmeltingResult(event.drops.get(x)) != null) { ItemStack thisItem = FurnaceRecipes.smelting().getSmeltingResult(event.drops.get(x)); if ((breaker == ItemManager.fireAxe || breaker == ItemManager.firePickaxe || breaker == ItemManager.fireSpade) && breaker != null) { event.drops.remove(x); event.drops.add(thisItem); } } } } } I tried it out and the world generates and loads, and the first time I cut a log with the axe it dropped 1 charcoal, so something must be working. Every time after that, however, nothing dropped. I tried relogging, then making a new world and still nothing. When I punch the logs with my hand, however, I get the log back normally. I'm not sure if it's still relevant, but here's the crash report from before I made that change. After the change it isn't working, but there are no errors.
  3. I'm working on my mod in which I'm trying to create new auto smelting tools (cliché I know), and I'm trying to modify the HarvestDropsEvent. I'm new to events, but from everything I've seen it doesn't look like it should be too hard. I'm sure there's probably a better way to do this, but right now this seems like the best option (suggestions are welcomed). Here's my current code. Right now I'm trying to make it so 3 of my tools auto smelt blocks (I'll fine tune which tools smelt which blocks later, I'm just trying to get it working now). package com.chocolatemc.event; import java.util.ArrayList; import com.chocolatemc.item.ItemManager; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraftforge.event.world.BlockEvent; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class BlockEventManager { @SubscribeEvent public void onEvent(BlockEvent.HarvestDropsEvent event) { Item breaker = event.harvester.getCurrentEquippedItem().getItem(); if (event.drops != null && event.drops.size() != 0) { for (int x = event.drops.size() - 1; x >= 0; x--) { if (FurnaceRecipes.smelting().getSmeltingResult(event.drops.get(x)) != null) { ItemStack thisItem = FurnaceRecipes.smelting().getSmeltingResult(event.drops.get(x)); if (breaker == ItemManager.fireAxe || breaker == ItemManager.firePickaxe || breaker == ItemManager.fireSpade) { event.drops.remove(x); event.drops.add(thisItem); } } } } } } I have the BlockEventManager registered in my FMLInitializationEvent like this (from what I've seen, this works fine): MinecraftForge.EVENT_BUS.register(new BlockEventManager()); Basically, every time I try to load up a new world with the new event, I get an error and a crash. I thought it might have had something to do with it doing something with blocks that aren't harvestable, so I added the check to see if the drops array is empty or zero, but I don't think that should be even a question since the event isn't associated with world gen, and it's registered in Init, not PreInit (not 100% sure about those, it's been a while since I looked into those and I don't know them well, probably entirely wrong lol). Any ideas why it might not be working?
×
×
  • Create New...

Important Information

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