Jump to content

Recommended Posts

Posted

I'm getting a ticking block entity error from this method below I know this is where is coming from. Its coming from the for loop. Now I'm building a dual input machine and I'm not sure if I'm doing this correctly. I'm looping through the fuel, and 2 input slots. Now I also have 3 upgrade slots. should I be looping though and checking ALL slots and not just the fuel and 2 inputs? The loop is whats crashing out the game and I'm just not sure if I'm writing it correctly or I'm just not checking what i need too. I can supply the rest of the code if needed but everything worked perfectly until I wrote this method.

 

private void infuseItem() {
	if (canInfuse()) {
		ItemStack itemstack = InfusionRecipes.getInfusionResults(slots[1].getItem(), slots[2].getItem());

            if (slots[3] == null) {
            	slots[3] = itemstack.copy();
            } else if (slots[3].getItem() == itemstack.getItem()) {
                this.slots[3].stackSize += itemstack.stackSize; // Forge BugFix: Results may have multiple items
            }

            for (int i = 0; i < 2; i++) {
            	if (slots[i].stackSize <= 0) {
            		slots[i] = new ItemStack(slots[i].getItem().setFull3D());
            	} else {
            		slots[i].stackSize--;
            	}
            	if (slots[i].stackSize <= 0) {
                	slots[i] = null;
                }
            }
        }
    }

 

any help would be appreciated.

Posted

I went and reviewed the vanilla smeltItem method and clipped in the the section of code that decreases stack size to see if it was in fact my loop crashing and its not. with the vanilla smeltItem method it crashed when trying to decrease the stack size.

 

as for the setFull3d 'm honestly not sure why i put that in there lol is removed though its not needed.

 

method with error causing line pointed out.

private void infuseItem() {
	if (canInfuse()) {
		ItemStack itemstack = InfusionRecipes.getInfusionResults(slots[1].getItem(), slots[2].getItem());

            if (slots[3] == null) {
            	slots[3] = itemstack.copy();
            } else if (slots[3].getItem() == itemstack.getItem()) {
                this.slots[3].stackSize += itemstack.stackSize; // Forge BugFix: Results may have multiple items
            }

            for (int i = 0; i < 2; i++) {
            	if (slots[i].stackSize <= 0) { // < --------------------------------------------------------------------------------------------------- CRASH IS ON THIS LINE
            		slots[i] = new ItemStack(slots[i].getItem());
            	} else {
            		slots[i].stackSize--;
            	}
            	if (slots[i].stackSize <= 0) {
                	slots[i] = null;
                }
            }
        }
    }

 

Crash Report

---- Minecraft Crash Report ----
// Oops.

Time: 2/5/15 2:18 PM
Description: Ticking block entity

java.lang.NullPointerException: Ticking block entity
at AdvancedEnergy.tileentities.MetallicInfuserTE.infuseItem(MetallicInfuserTE.java:237)
at AdvancedEnergy.tileentities.MetallicInfuserTE.updateEntity(MetallicInfuserTE.java:286)
at net.minecraft.world.World.updateEntities(World.java:2160)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
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:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at AdvancedEnergy.tileentities.MetallicInfuserTE.infuseItem(MetallicInfuserTE.java:237)
at AdvancedEnergy.tileentities.MetallicInfuserTE.updateEntity(MetallicInfuserTE.java:286)

-- Block entity being ticked --
Details:
Name: MetallicInfuserTE // AdvancedEnergy.tileentities.MetallicInfuserTE
Block type: ID #167 (tile.null // AdvancedEnergy.machines.MetallicInfuser)
Block data value: 5 / 0x5 / 0b0101
Block location: World: (229,69,262), Chunk: (at 5,4,6 in 14,16; contains blocks 224,0,256 to 239,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Actual block type: ID #167 (tile.null // AdvancedEnergy.machines.MetallicInfuser)
Actual block data value: 5 / 0x5 / 0b0101
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:2160)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515)

-- Affected level --
Details:
Level name: Copy of New World
All players: 1 total; [EntityPlayerMP['Player265'/209, l='Copy of New World', x=231.39, y=69.00, z=261.17]]
Chunk stats: ServerChunkCache: 709 Drop: 0
Level seed: 2850766302080461089
Level generator: ID 00 - default, ver 1. Features enabled: true
Level generator options: 
Level spawn location: World: (224,64,248), Chunk: (at 0,4,8 in 14,15; contains blocks 224,0,240 to 239,255,255), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 746 game time, 746 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 17383 (now: false), thunder time: 81497 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.8.0_31, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 837371904 bytes (798 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.1230 Minecraft Forge 10.13.2.1230 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.10.85.1230} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.13.2.1230} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
ae{1.0a} [Advanced Energy] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP['Player265'/209, l='Copy of New World', x=231.39, y=69.00, z=261.17]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

Posted

Seems like the slot at that position is null, your trying to access it when it's null,

 

When this is called

 

if (slots[i].stackSize <= 0) 
{
    slots[i] = null;
}

 

next time round it will be null and .stackSize will not be available because slots at position 'i' will be null.

 

You have to initialize it before accessing .stackSize

I require Java, both the coffee and the code :)

Posted

I switched up the method so it looks like this...

private void infuseItem() {
	if (!canInfuse()) {
		return;
	}

	ItemStack itemstack = InfusionRecipes.getInfusionResults(slots[1].getItem(), slots[2].getItem());

	if (slots[3] == null) {
		slots[3] = itemstack.copy();
	} else if (slots[3] == itemstack) {
		this.slots[3].stackSize++;
	}

	for (int i = 0; i < 2; i++) {
		if (slots[i].stackSize <= 0) {
			slots[i] = new ItemStack(slots[i].getItem());
		} else {
			slots[i].stackSize--;
		}
		if (slots[i].stackSize <= 0) {
			slots[i] = null;
		}
	}
}

 

It resolved the crash, however now it will burn fuel but not create the item but that is more than likely in my recipes class so i can figure that out. You were right Belpois, thanks for the help.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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