Jump to content

Recommended Posts

Posted

Hello all,

 

I am having trouble rendering my custom modeled block - I wanted my block's model to face different directions depending on which way the player is facing, which works. The problem arises when I try and make and render my block as an item as well. Whenever I enter the game and the item is visible, the game crashes immediately. I believe I am doing it right, because when I remove the directional code, it renders fine with no crashes. How would I make these two functions work together? My code is as follows:

 

Block Class

public class PottedPlantProp extends BlockContainer {

public PottedPlantProp(Material material) {
	super(material);

	this.setCreativeTab(DesconCreativeTabs.tabExterior);
	this.setHarvestLevel("", 1);
	this.setHardness(1F);
	this.setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.750F, 0.9375F);
	this.setBlockTextureName(Main.modID + ":" + "textures/blocks/pottedplant.png");
}

public int getRenderType() {
	return -1;
}

public boolean isOpaqueCube() {
	return false;
}

public boolean renderAsNormalBlock() {
	return false;
}

@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new TileEntityPottedPlant();
}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
	this.blockIcon = iconRegister.registerIcon(Main.modID + ":" + this.getUnlocalizedName().substring(5));
}

//Directional Code

/*public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack)
    {
        int l = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        
        world.setBlockMetadataWithNotify(x, y, z, l, 3);
        
    }*/
}

 

ClientProxy

//Potted Plant
	TileEntitySpecialRenderer renderPottedPlant = new RenderPottedPlant();
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPottedPlant.class, renderPottedPlant);
	MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(PropsGeneral.pottedplant), new ItemRenderPottedPlant(renderPottedPlant, new TileEntityPottedPlant()));

 

ItemRenderer

public class ItemRenderPottedPlant implements IItemRenderer {

TileEntitySpecialRenderer render;
private TileEntity entity;

public ItemRenderPottedPlant(TileEntitySpecialRenderer render, TileEntity entity) {
	this.entity = entity;
	this.render = render;
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	return true;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
	return true;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

	if(type == IItemRenderer.ItemRenderType.ENTITY)
		GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
	this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);
}

}

 

Block Renderer

public class RenderPottedPlant extends TileEntitySpecialRenderer {

private static final ResourceLocation texture = new ResourceLocation(Main.modID + ":" + "textures/props/PottedPlantTexture.png");

private ModelPottedPlant model;

public RenderPottedPlant() {
	this.model = new ModelPottedPlant();
}	

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
	/*World world = tileEntity.getWorldObj();
	int dir = world.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
	*/
	GL11.glPushMatrix();

	GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
	GL11.glRotatef(180, 0F, 0F, 1F);
	//GL11.glRotatef(dir * (90F), 0F, 1F, 0F);

	this.bindTexture(texture);

		GL11.glPushMatrix();
			this.model.renderModel(0.0625F);
		GL11.glPopMatrix();
	GL11.glPopMatrix();
}
}

 

P.S. In the state the code is in above, the directional code has been commented out, so that the rendering works

Posted

I think(dont know for sure) that its crashing because an Item is not a real tileEntity. This means the game can't calculate the rotation which will cause eventually. So I would recommend trying to make an separate render code, where you don't set(dynamicly) any rotation, and use that for you Item rendering.

 

or use an icon instead of the model for itemEntity, since the game will slowly rotate the model, which in your case will cause a conflict.

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Posted

The crash report is as follows:

[17:31:43] [Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Rendering item
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:624) ~[RenderItem.class:?]
at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973) ~[GuiIngame.class:?]
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209) ~[GuiIngameForge.class:?]
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144) ~[GuiIngameForge.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1114) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1056) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]
Caused by: java.lang.NullPointerException
at com.descon.renderer.RenderPottedPlant.renderTileEntityAt(RenderPottedPlant.java:27) ~[RenderPottedPlant.class:?]
//int dir = world.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
at com.descon.itemrenderer.ItemRenderPottedPlant.renderItem(ItemRenderPottedPlant.java:35) ~[itemRenderPottedPlant.class:?]
//this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);
at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:183) ~[ForgeHooksClient.class:?]
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:583) ~[RenderItem.class:?]
... 15 more
[17:31:43] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----

Time: 18/05/15 5:31 PM
Description: Rendering item

java.lang.NullPointerException: Rendering item
at com.descon.renderer.RenderPottedPlant.renderTileEntityAt(RenderPottedPlant.java:27)
at com.descon.itemrenderer.ItemRenderPottedPlant.renderItem(ItemRenderPottedPlant.java:35)
at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:183)
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:583)
at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973)
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1114)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1056)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78)
at GradleStart.main(GradleStart.java:45)


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

-- Head --
Stacktrace:
at com.descon.renderer.RenderPottedPlant.renderTileEntityAt(RenderPottedPlant.java:27)
at com.descon.itemrenderer.ItemRenderPottedPlant.renderItem(ItemRenderPottedPlant.java:35)
at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:183)

-- Item being rendered --
Details:
Item Type: net.minecraft.item.ItemBlock@34d644b5
Item Aux: 0
Item NBT: null
Item Foil: false
Stacktrace:
at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:583)
at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973)
at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209)
at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player37'/264, l='MpServer', x=59.02, y=70.62, z=232.56]]
Chunk stats: MultiplayerChunkCache: 10, 10
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: World: (56,64,248), Chunk: (at 8,4,8 in 3,15; contains blocks 48,0,240 to 63,255,255), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 1321 game time, 1321 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 6 total; [EntityItem['item.item.seeds'/114, l='MpServer', x=32.81, y=63.13, z=212.25], EntitySquid['Squid'/115, l='MpServer', x=41.59, y=59.28, z=217.16], EntitySquid['Squid'/116, l='MpServer', x=47.94, y=55.34, z=209.31], EntityClientPlayerMP['Player37'/264, l='MpServer', x=59.02, y=70.62, z=232.56], EntitySquid['Squid'/125, l='MpServer', x=51.97, y=55.00, z=212.94], EntitySquid['Squid'/126, l='MpServer', x=52.84, y=54.00, z=209.50]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2555)
at net.minecraft.client.Minecraft.run(Minecraft.java:973)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78)
at GradleStart.main(GradleStart.java:45)

 

This...

  Quote
Caused by: java.lang.NullPointerException

at com.descon.renderer.RenderPottedPlant.renderTileEntityAt(RenderPottedPlant.java:27) ~[RenderPottedPlant.class:?]

...is where my code is first referenced in the crash log I believe

 

Thanks,

-Whyneb360

 

P.S. In the above crash report, I annotated which line of code related to the reference.

Posted

Hi

 

so...

either tileEntity is null

or

tileEntity.world is null.

 

Set a breakpoint or System.out.println there, to find out which one...

 

In this case tileEntity.world is null.  You are trying to pull information about a block from a TileEntity which you created from nothing

new ItemRenderPottedPlant(renderPottedPlant, new TileEntityPottedPlant()))

 

Your renderer needs to check for that, and use a default value if it's an item not a block.

eg

if (tileEntity.hasWorldObj()) {

  get value from world block

} else {

use default value

}

 

-TGG

 

 

Posted

Thank you for your response, however I'm not sure where to put the the if statement you mentioned, or what the default value would be. Sorry if this seems like an obvious question

Posted

Hi

 

Check out TileEntityChestRenderer, it has a similar example.

 

The key problem is - your TileEntityRenderer is trying to use the TileEntity's direction to figure out which direction to render.  That only makes sense if your TileEntity is associated with a block that you've placed in the world.

 

The if statement goes in your renderer before you try to use the world object to retrieve the direction.

 

-TGG

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com   I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com
    • There is an issue with Modular Force Field System (mffs) Remove it or try other builds
    • I never imagined I would be writing this kind of testimony, but I feel it’s important to share my experience with Malice Cyber Recovery and how they helped me recover $230,000 I lost to crypto scammers. A few months ago, I got involved in a crypto investment opportunity that seemed legitimate at first. The scammers were incredibly convincing. They showed me impressive returns, sent regular updates, and even gave me access to what looked like a real trading platform. I was initially cautious, but after seeing the returns, I began to invest more, ultimately transferring over $230,000. Unfortunately, after a few weeks, when I tried to withdraw my funds, I found that the platform had disappeared, and I could no longer contact anyone involved. It was clear I had been scammed, and I felt completely helpless. For weeks, I tried everything to get my money back—contacting the authorities, reaching out to the platform’s so-called support team (who of course were unreachable), and trying to trace the transactions myself. But everything led to dead ends. The more I researched, the more I realized just how hard it was to recover stolen crypto. I began to lose hope. That’s when I came across Malice Cyber Recovery. At first, I was skeptical. Could they really help me recover my funds after everything I had been through? I decided to reach out anyway, just to see if they could offer any guidance. From the very first conversation, their team was not only professional but also deeply empathetic. They understood exactly how I was feeling and immediately made it clear that they were dedicated to helping me recover my lost funds. Malice Cyber Recovery’s team got to work quickly. They walked me through every step of the process, explaining the methods they would use to track down my stolen crypto. Their knowledge of blockchain technology and how to trace crypto transactions was incredibly impressive. They didn’t just give me vague promises they showed me the action they were taking and the progress they were making, which gave me hope that my money wasn’t gone forever. One of the most reassuring aspects of working with Malice Cyber Recovery was their transparency. They kept me updated regularly, letting me know what they were doing, what obstacles they encountered, and how they were overcoming them. It wasn’t an easy process; tracing funds through blockchain and dealing with scammers who hide behind fake identities and complex networks is incredibly difficult. But Malice Cyber Recovery’s team was relentless. They used advanced tools and techniques to trace the flow of my funds, and within just a few weeks, they managed to locate a significant portion of my lost funds. I couldn’t believe it when they informed me that they had successfully recovered a large chunk of my money. I never thought I’d see that $230,000 again. The recovery process wasn’t instantaneous it  took time, patience, and persistence but Malice Cyber Recovery delivered on their promise.  
    • Almost, just the java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui and if that doesn't work, try java --version
    • What so just copy and paste " java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui Pause >nul " into a cmd terminal? If that's what you mean, nothing happens
  • Topics

×
×
  • Create New...

Important Information

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