Jump to content

Recommended Posts

Posted

Hey all,

I'm trying to make my custom crafting table with specific recipes, and I've come into this crash that I cannot understand..

 

The crash report:

net.minecraft.util.ReportedException: Rendering screen
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1175) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1140) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:404) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:?]
Caused by: java.lang.NullPointerException: Rendering screen
at net.minecraft.client.renderer.RenderItem.renderItemOverlayIntoGUI(RenderItem.java:429)
at net.minecraft.client.gui.inventory.GuiContainer.drawSlot(GuiContainer.java:299)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:114)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:355)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1148)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1140)
at net.minecraft.client.Minecraft.run(Minecraft.java:404)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

 

I can see that the exception is reported in Minecraft's code, and that it is a NullPointerException, but I can't understand how to fix it...

 

My code (I hope it'll have a use in finding the solution)

 

TileEntityConstructionTable (The "checkRecipes" method is called whenever an Item is placed or removed in the gui)

private ItemStack[] slots = new ItemStack[18];

public void checkRecipes() {
	ItemStack[] gridInputs = getGridInputs();
	ItemStack[] secInputs = getSecInputs();

	CraftingHandlerConstructionTable.RecipeType recipeType = CraftingHandlerConstructionTable.getCurrentRecipeType(gridInputs, secInputs, worldObj);
	ItemStack output = null;
	if (recipeType != CraftingHandlerConstructionTable.RecipeType.None) {
		if (recipeType == CraftingHandlerConstructionTable.RecipeType.Vanilla && CraftingHandlerConstructionTable.getVanillaRecipeOutput(gridInputs, worldObj) != null) {
			output = CraftingHandlerConstructionTable.getVanillaRecipeOutput(gridInputs, worldObj);
		} else if (recipeType == CraftingHandlerConstructionTable.RecipeType.CTShaped && CraftingHandlerConstructionTable.getConstructionTableShapedRecipeOutput(gridInputs, secInputs) != null) {
			output = CraftingHandlerConstructionTable.getConstructionTableShapedRecipeOutput(gridInputs, secInputs);
		}
	}

	this.slots[0] = output;
}

 

CraftingHandlerConstructionTable

public static ItemStack getVanillaRecipeOutput(ItemStack[] gridInputs, World world) {
	InventoryCrafting ic = new InventoryCrafting(new ContainerDummy(), 3, 3);
	for (int i = 0; i < 9; i++) {
		ic.setInventorySlotContents(i, gridInputs[i]);
	}
	return CraftingManager.getInstance().findMatchingRecipe(ic, world);
}

public static ItemStack getConstructionTableShapedRecipeOutput(ItemStack[] gridInputs, ItemStack[] secInputs) {
	ItemStack output = null;
	int numOfItemStacks = 0;
	for (ItemStack secInput : secInputs) {
		if (secInput != null) {
			numOfItemStacks++;
		}
	}
	ItemStack[] secNoNulls = new ItemStack[numOfItemStacks];
	int index = 0;
	for (ItemStack secInput : secInputs) {
		if (secInput != null) {
			secNoNulls[index] = secInput;
			index++;
		}
	}
	for (RecipeBaseConstructionTable recipe : IJCAPI.constructionTableRecipes) {
		if (recipe instanceof RecipeShapedConstructionTable) {
			if (recipe.matches(gridInputs, secNoNulls)) {
				output = recipe.getOutput();
			}
		}
	}
	return output;
}

public static RecipeType getCurrentRecipeType(ItemStack[] gridInputs, ItemStack[] secInputs, World world) {
	RecipeType currentType = RecipeType.None;

	if (getVanillaRecipeOutput(gridInputs, world) != null) currentType = RecipeType.Vanilla;
	if (getConstructionTableShapedRecipeOutput(gridInputs, secInputs) != null) currentType = RecipeType.CTShaped;

	return currentType;
}

public enum RecipeType {
	None,
	Vanilla,
	CTShaped,
	CTShapeless,
	CTPrecise
}

 

I hope this is enough. I can also post the actual methods of matching the recipes (those work, and I don't think they are the problem..)

 

Posted
Caused by: java.lang.NullPointerException: Rendering screen

at net.minecraft.client.renderer.RenderItem.renderItemOverlayIntoGUI(RenderItem.java:429)

 

This exception is thrown when Minecraft attempts to render an

ItemStack

with a

null

Item

. Ensure all of your

Item

s have been properly initialised.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

You were correct,  thank you!

I was registering my blocks and crafting recipes both in preInit. Once I moved the recipes to init, that problem was fixed... I still have a few other minor fixes to do to this constructionTable, but this problem was solved. Thanks again!

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.