Jump to content

[SOLVED][1.7.10] Changing block drops (auto smelting)


DudeGuyCraft

Recommended Posts

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?

Link to comment
Share on other sites

Well, not having the error log makes things trickier, but...

 

event.harvester.getCurrentEquippedItem().getItem();

 

I see a lot of things in that line that might be null in some cases and would crash the game.  Remember: punching trees gives you wood.

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.

Link to comment
Share on other sites

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.

 

---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.

Time: 12/16/14 10:55 PM
Description: Exception in server tick loop

java.lang.NullPointerException: Exception in server tick loop
at com.chocolatemc.event.BlockEventManager.onEvent(BlockEventManager.java:20)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_19_BlockEventManager_onEvent_HarvestDropsEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)
at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:155)
at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:806)
at net.minecraft.block.Block.dropBlockAsItem(Block.java:795)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:184)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:162)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:132)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:162)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:128)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:128)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:128)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:132)
at net.minecraft.world.WorldServer.scheduleBlockUpdateWithPriority(WorldServer.java:455)
at net.minecraft.world.WorldServer.scheduleBlockUpdate(WorldServer.java:432)
at net.minecraft.block.BlockDynamicLiquid.onBlockAdded(BlockDynamicLiquid.java:352)
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:713)
at net.minecraft.world.World.setBlock(World.java:519)
at net.minecraft.block.BlockDynamicLiquid.func_149813_h(BlockDynamicLiquid.java:187)
at net.minecraft.block.BlockDynamicLiquid.updateTick(BlockDynamicLiquid.java:152)
at net.minecraft.world.gen.feature.WorldGenLiquids.generate(WorldGenLiquids.java:83)
at net.minecraft.world.biome.BiomeDecorator.genDecorations(BiomeDecorator.java:344)
at net.minecraft.world.biome.BiomeDecorator.decorateChunk(BiomeDecorator.java:145)
at net.minecraft.world.biome.BiomeGenBase.decorate(BiomeGenBase.java:412)
at net.minecraft.world.biome.BiomeGenJungle.decorate(BiomeGenJungle.java:62)
at net.minecraft.world.gen.ChunkProviderGenerate.populate(ChunkProviderGenerate.java:444)
at net.minecraft.world.gen.ChunkProviderServer.populate(ChunkProviderServer.java:313)
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1157)
at net.minecraft.world.gen.ChunkProviderServer.originalLoadChunk(ChunkProviderServer.java:208)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:149)
at net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:119)
at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:305)
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:79)
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.7.0_71, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 894944304 bytes (853 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.05 FML v7.10.85.1264 Minecraft Forge 10.13.2.1264 6 mods loaded, 6 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
FML{7.10.85.1264} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1264.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
Forge{10.13.2.1264} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1264.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
CodeChickenCore{1.0.4.29} [CodeChicken Core] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
NotEnoughItems{1.0.3.67} [Not Enough Items] (NotEnoughItems-1.7.10-1.0.3.67-universal.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
cmc{1.1.0} [Chocolate Minecraft] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Player Count: 0 / 8; []
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

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