Jump to content

Recommended Posts

Posted

So i just started make custom modeled blocks and it works but the blocks don't show up in my inventory it just says Texture missing

EDW5wTM.png

If someone could help me i would be really happy ^^

Posted

Two questions:

1: have you done .setUnlocalizedName("Mod:block.png") when you initialized the block?

2: did you use a tile entity in that block? if so what line did you put in your main mod file to register the renderer to the tile entity?

Posted
  On 6/22/2013 at 12:58 AM, ninjapancakes87 said:

Two questions:

1: have you done .setUnlocalizedName("Mod:block.png") when you initialized the block?

2: did you use a tile entity in that block? if so what line did you put in your main mod file to register the renderer to the tile entity?

Two answers:

1: Yes

2:Yes

BlockFryer:

@Override
public TileEntity createNewTileEntity(World world) {

	return new TileEntityFryer();
}

Main:

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFryer.class, new RenderFryer());

Posted

Since you are using a custom rendering method for the block in the overworld, then you also need to use a custom rendering method for the block in other cases, such as in your inventory.

To do this, you need to create a IItemRenderer and register it for your block ID.

 

For example, in your new class that implements IItemRenderer:

public class FryerRenderer implements IItemRenderer {
@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) {
	switch(type) {
		case INVENTORY: {
			renderYourModel();
			return;
		}

		default: return;
	}
}

private void renderYourModel()
{
	// insert OpenGL code here....
}
}

 

Then, register it for your blockID in your mod class:

MinecraftForgeClient.registerItemRenderer(block_fryer.blockID, new FryerRenderer());

 

Hope I helped!

Posted
  On 6/27/2013 at 5:24 PM, Naftoreiclag said:

Since you are using a custom rendering method for the block in the overworld, then you also need to use a custom rendering method for the block in other cases, such as in your inventory.

To do this, you need to create a IItemRenderer and register it for your block ID.

 

For example, in your new class that implements IItemRenderer:

public class FryerRenderer implements IItemRenderer {
@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) {
	switch(type) {
		case INVENTORY: {
			renderYourModel();
			return;
		}

		default: return;
	}
}

private void renderYourModel()
{
	// insert OpenGL code here....
}
}

 

Then, register it for your blockID in your mod class:

MinecraftForgeClient.registerItemRenderer(block_fryer.blockID, new FryerRenderer());

 

Hope I helped!

I don't know what you mean with insert opengl code

Sorry this is first time i made a custom modeled block

Posted
  On 6/27/2013 at 6:21 PM, TwinAndy said:

  Quote

-snip-

I don't know what you mean with insert opengl code

Sorry this is first time i made a custom modeled block

 

How are you rendering your "custom modeled block" then? Certainly there is some code you used. Did you use a wavefront (.obj)? Did you code it out yourself using those tedious openGL functions? Can you show me your class for rendering your tile entity? I kind of assumed that you already knew the rendering stuff; sorry if I confused you. I'll be able to help you if you show me your rendering code.

Posted
  On 6/27/2013 at 6:59 PM, Naftoreiclag said:

-snip-

How are you rendering your "custom modeled block" then? Certainly there is some code you used. Did you use a wavefront (.obj)? Did you code it out yourself using those tedious openGL functions? Can you show me your class for rendering your tile entity? I kind of assumed that you already knew the rendering stuff; sorry if I confused you. I'll be able to help you if you show me your rendering code.

RenderFryer

package TwinAndysMods.SomeLittleThingsMod;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

import org.lwjgl.opengl.GL11;
public class RenderFryer extends TileEntitySpecialRenderer
{
        public RenderFryer()
        {
                aModel = new ModelFryer();
        }

        public void renderAModelAt(TileEntityFryer tileentity1, double d, double d1, double d2, float f)
        {  
                GL11.glPushMatrix();
                GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.52F, (float)d2 + 0.5F);
                GL11.glRotatef(180F, 0F, 0F, 1F);
                bindTextureByName("/textures/blocks/FryerTexture.png");
                GL11.glPushMatrix();
                aModel.renderAll(0.0625F);
                GL11.glPopMatrix();     
                GL11.glPopMatrix();                                     
        }
        public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2,
                        float f)
        {
                renderAModelAt((TileEntityFryer)tileentity, d, d1, d2, f);
        }
        private ModelFryer aModel;
}



If you could help me i would love you (No homo)

Posted
  On 6/27/2013 at 9:03 PM, TwinAndy said:

If you could help me i would love you (No homo)

 

How about just a simple "thank you"?  :P

 

Anyway, since you didn't provide the code for the model, I couldn't test it, so I just copied and pasted your code. (Like I expected you would have tried on your own...)

 

Add this to the FryerRenderer class I made for you.

private ModelFryer aModel;

public FryerRenderer()
{
    aModel = new ModelFryer();
}

...

private void renderYourModel()
{
    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, 0.0F, 0.0F); // play around with these numbers until you get it where you want it. (should work by itself)
    GL11.glRotatef(180F, 0F, 0F, 1F);
    bindTextureByName("/textures/blocks/FryerTexture.png");
    aModel.renderAll(0.0625F);
    GL11.glPopMatrix();
}

 

Also, I don't think you need to do two glPushMatrix()'s since you aren't doing anything special to your model between the second one and the first glPopMatrix(); one pair should be good enough.

Posted
  Quote
Also, I don't think you need to do two glPushMatrix()'s since you aren't doing anything special to your model between the second one and the first glPopMatrix(); one pair should be good enough.

 

definitely ^

 

you probably should rotate before you translate

 

doing translation before implies that you want to rotate according to the origin

 

 

  Reveal hidden contents

 

 

if you dont give a shit about why, or if i wasn't clear enough,

 

jsut switch glRotate and glTranslate order

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted
  On 6/28/2013 at 5:59 PM, Naftoreiclag said:

  Quote

If you could help me i would love you (No homo)

 

How about just a simple "thank you"?  :P

 

Anyway, since you didn't provide the code for the model, I couldn't test it, so I just copied and pasted your code. (Like I expected you would have tried on your own...)

 

Add this to the FryerRenderer class I made for you.

-snip-

 

Also, I don't think you need to do two glPushMatrix()'s since you aren't doing anything special to your model between the second one and the first glPopMatrix(); one pair should be good enough.

It doesn't work.

Im sorry that i didn't gave you a model.

ModelFryer

package TwinAndysMods.SomeLittleThingsMod;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelFryer extends ModelBase
{
  //fields
    ModelRenderer Shape1;
    ModelRenderer Shape2;
    ModelRenderer Shape3;
    ModelRenderer Shape4;
    ModelRenderer Shape5;
    ModelRenderer Shape6;
    ModelRenderer Shape7;
    ModelRenderer Shape8;
    ModelRenderer Shape9;
    ModelRenderer Shape10;
    ModelRenderer Shape11;
    ModelRenderer Shape12;
  
  public ModelFryer()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(0F, 0F, 0F, 13, 1, 9);
      Shape1.setRotationPoint(-8F, 23F, -4F);
      Shape1.setTextureSize(64, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 12);
      Shape2.addBox(0F, 0F, 0F, 1, 5, 9);
      Shape2.setRotationPoint(4F, 18F, -4F);
      Shape2.setTextureSize(64, 32);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
      Shape3 = new ModelRenderer(this, 44, 1);
      Shape3.addBox(0F, 0F, 0F, 1, 9, 9);
      Shape3.setRotationPoint(-8F, 14F, -4F);
      Shape3.setTextureSize(64, 32);
      Shape3.mirror = true;
      setRotation(Shape3, 0F, 0F, 0F);
      Shape4 = new ModelRenderer(this, 32, 26);
      Shape4.addBox(0F, 0F, 0F, 11, 5, 1);
      Shape4.setRotationPoint(-7F, 18F, 4F);
      Shape4.setTextureSize(64, 32);
      Shape4.mirror = true;
      setRotation(Shape4, 0F, 0F, 0F);
      Shape5 = new ModelRenderer(this, 32, 26);
      Shape5.addBox(0F, 0F, 0F, 11, 5, 1);
      Shape5.setRotationPoint(-7F, 18F, -4F);
      Shape5.setTextureSize(64, 32);
      Shape5.mirror = true;
      setRotation(Shape5, 0F, 0F, 0F);
      Shape6 = new ModelRenderer(this, 32, 19);
      Shape6.addBox(0F, 0F, 0F, 10, 1, 6);
      Shape6.setRotationPoint(-6.5F, 21F, -2.5F);
      Shape6.setTextureSize(64, 32);
      Shape6.mirror = true;
      setRotation(Shape6, 0F, 0F, 0F);
      Shape7 = new ModelRenderer(this, 0, 28);
      Shape7.addBox(0F, 0F, 0F, 10, 3, 1);
      Shape7.setRotationPoint(-6.5F, 18F, -2.5F);
      Shape7.setTextureSize(64, 32);
      Shape7.mirror = true;
      setRotation(Shape7, 0F, 0F, 0F);
      Shape8 = new ModelRenderer(this, 0, 28);
      Shape8.addBox(0F, 0F, 0F, 10, 3, 1);
      Shape8.setRotationPoint(-6.5F, 18F, 2.5F);
      Shape8.setTextureSize(64, 32);
      Shape8.mirror = true;
      setRotation(Shape8, 0F, 0F, 0F);
      Shape9 = new ModelRenderer(this, 22, 25);
      Shape9.addBox(0F, 0F, 0F, 1, 3, 4);
      Shape9.setRotationPoint(2.5F, 18F, -1.5F);
      Shape9.setTextureSize(64, 32);
      Shape9.mirror = true;
      setRotation(Shape9, 0F, 0F, 0F);
      Shape10 = new ModelRenderer(this, 22, 25);
      Shape10.addBox(0F, 0F, 0F, 1, 3, 4);
      Shape10.setRotationPoint(-6.5F, 18F, -1.5F);
      Shape10.setTextureSize(64, 32);
      Shape10.mirror = true;
      setRotation(Shape10, 0F, 0F, 0F);
      Shape11 = new ModelRenderer(this, 13, 11);
      Shape11.addBox(0F, 0F, 0F, 11, 0, 7);
      Shape11.setRotationPoint(-7F, 19F, -3F);
      Shape11.setTextureSize(64, 32);
      Shape11.mirror = true;
      setRotation(Shape11, 0F, 0F, 0F);
      Shape12 = new ModelRenderer(this, 0, 26);
      Shape12.addBox(0F, 0F, 0F, 6, 1, 1);
      Shape12.setRotationPoint(2.5F, 17F, 0F);
      Shape12.setTextureSize(64, 32);
      Shape12.mirror = true;
      setRotation(Shape12, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5);
    Shape1.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
    Shape6.render(f5);
    Shape7.render(f5);
    Shape8.render(f5);
    Shape9.render(f5);
    Shape10.render(f5);
    Shape11.render(f5);
    Shape12.render(f5);
  }
  public void renderAll(float f5){
  Shape1.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
    Shape6.render(f5);
    Shape7.render(f5);
    Shape8.render(f5);
    Shape9.render(f5);
    Shape10.render(f5);
    Shape11.render(f5);
    Shape12.render(f5);

  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
  {
    
  }

}

FryerRenderer

package TwinAndysMods.SomeLittleThingsMod;

import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

public class FryerRenderer implements IItemRenderer {
@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) {
	switch(type) {
		case INVENTORY: {
			renderModelFryer();
			return;
		}

		default: return;
	}
}


private ModelFryer aModel;

public FryerRenderer()
{
    aModel = new ModelFryer();
}


private void renderModelFryer()
{
    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, 0.0F, 0.0F); // play around with these numbers until you get it where you want it. (should work by itself)
    GL11.glRotatef(180F, 0F, 0F, 1F);
    bindTextureByName("/textures/blocks/FryerTexture.png");
    aModel.renderAll(0.0625F);
    GL11.glPopMatrix();
}

private void bindTextureByName(String string) {


}
}

I think i did something wron with the bindTextureByName....

I already gave you a thank you but if you still want to help me out a bit.

Posted
  On 6/28/2013 at 7:30 PM, TwinAndy said:

  Quote

  Quote

If you could help me i would love you (No homo)

 

How about just a simple "thank you"?  :P

 

Anyway, since you didn't provide the code for the model, I couldn't test it, so I just copied and pasted your code. (Like I expected you would have tried on your own...)

 

Add this to the FryerRenderer class I made for you.

-snip-

 

Also, I don't think you need to do two glPushMatrix()'s since you aren't doing anything special to your model between the second one and the first glPopMatrix(); one pair should be good enough.

It doesn't work.

Im sorry that i didn't gave you a model.

ModelFryer

package TwinAndysMods.SomeLittleThingsMod;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelFryer extends ModelBase
{
  //fields
    ModelRenderer Shape1;
    ModelRenderer Shape2;
    ModelRenderer Shape3;
    ModelRenderer Shape4;
    ModelRenderer Shape5;
    ModelRenderer Shape6;
    ModelRenderer Shape7;
    ModelRenderer Shape8;
    ModelRenderer Shape9;
    ModelRenderer Shape10;
    ModelRenderer Shape11;
    ModelRenderer Shape12;
  
  public ModelFryer()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(0F, 0F, 0F, 13, 1, 9);
      Shape1.setRotationPoint(-8F, 23F, -4F);
      Shape1.setTextureSize(64, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 12);
      Shape2.addBox(0F, 0F, 0F, 1, 5, 9);
      Shape2.setRotationPoint(4F, 18F, -4F);
      Shape2.setTextureSize(64, 32);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
      Shape3 = new ModelRenderer(this, 44, 1);
      Shape3.addBox(0F, 0F, 0F, 1, 9, 9);
      Shape3.setRotationPoint(-8F, 14F, -4F);
      Shape3.setTextureSize(64, 32);
      Shape3.mirror = true;
      setRotation(Shape3, 0F, 0F, 0F);
      Shape4 = new ModelRenderer(this, 32, 26);
      Shape4.addBox(0F, 0F, 0F, 11, 5, 1);
      Shape4.setRotationPoint(-7F, 18F, 4F);
      Shape4.setTextureSize(64, 32);
      Shape4.mirror = true;
      setRotation(Shape4, 0F, 0F, 0F);
      Shape5 = new ModelRenderer(this, 32, 26);
      Shape5.addBox(0F, 0F, 0F, 11, 5, 1);
      Shape5.setRotationPoint(-7F, 18F, -4F);
      Shape5.setTextureSize(64, 32);
      Shape5.mirror = true;
      setRotation(Shape5, 0F, 0F, 0F);
      Shape6 = new ModelRenderer(this, 32, 19);
      Shape6.addBox(0F, 0F, 0F, 10, 1, 6);
      Shape6.setRotationPoint(-6.5F, 21F, -2.5F);
      Shape6.setTextureSize(64, 32);
      Shape6.mirror = true;
      setRotation(Shape6, 0F, 0F, 0F);
      Shape7 = new ModelRenderer(this, 0, 28);
      Shape7.addBox(0F, 0F, 0F, 10, 3, 1);
      Shape7.setRotationPoint(-6.5F, 18F, -2.5F);
      Shape7.setTextureSize(64, 32);
      Shape7.mirror = true;
      setRotation(Shape7, 0F, 0F, 0F);
      Shape8 = new ModelRenderer(this, 0, 28);
      Shape8.addBox(0F, 0F, 0F, 10, 3, 1);
      Shape8.setRotationPoint(-6.5F, 18F, 2.5F);
      Shape8.setTextureSize(64, 32);
      Shape8.mirror = true;
      setRotation(Shape8, 0F, 0F, 0F);
      Shape9 = new ModelRenderer(this, 22, 25);
      Shape9.addBox(0F, 0F, 0F, 1, 3, 4);
      Shape9.setRotationPoint(2.5F, 18F, -1.5F);
      Shape9.setTextureSize(64, 32);
      Shape9.mirror = true;
      setRotation(Shape9, 0F, 0F, 0F);
      Shape10 = new ModelRenderer(this, 22, 25);
      Shape10.addBox(0F, 0F, 0F, 1, 3, 4);
      Shape10.setRotationPoint(-6.5F, 18F, -1.5F);
      Shape10.setTextureSize(64, 32);
      Shape10.mirror = true;
      setRotation(Shape10, 0F, 0F, 0F);
      Shape11 = new ModelRenderer(this, 13, 11);
      Shape11.addBox(0F, 0F, 0F, 11, 0, 7);
      Shape11.setRotationPoint(-7F, 19F, -3F);
      Shape11.setTextureSize(64, 32);
      Shape11.mirror = true;
      setRotation(Shape11, 0F, 0F, 0F);
      Shape12 = new ModelRenderer(this, 0, 26);
      Shape12.addBox(0F, 0F, 0F, 6, 1, 1);
      Shape12.setRotationPoint(2.5F, 17F, 0F);
      Shape12.setTextureSize(64, 32);
      Shape12.mirror = true;
      setRotation(Shape12, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5);
    Shape1.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
    Shape6.render(f5);
    Shape7.render(f5);
    Shape8.render(f5);
    Shape9.render(f5);
    Shape10.render(f5);
    Shape11.render(f5);
    Shape12.render(f5);
  }
  public void renderAll(float f5){
  Shape1.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
    Shape6.render(f5);
    Shape7.render(f5);
    Shape8.render(f5);
    Shape9.render(f5);
    Shape10.render(f5);
    Shape11.render(f5);
    Shape12.render(f5);

  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
  {
    
  }

}

FryerRenderer

package TwinAndysMods.SomeLittleThingsMod;

import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

public class FryerRenderer implements IItemRenderer {
@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) {
	switch(type) {
		case INVENTORY: {
			renderModelFryer();
			return;
		}

		default: return;
	}
}


private ModelFryer aModel;

public FryerRenderer()
{
    aModel = new ModelFryer();
}


private void renderModelFryer()
{
    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, 0.0F, 0.0F); // play around with these numbers until you get it where you want it. (should work by itself)
    GL11.glRotatef(180F, 0F, 0F, 1F);
    bindTextureByName("/textures/blocks/FryerTexture.png");
    aModel.renderAll(0.0625F);
    GL11.glPopMatrix();
}

private void bindTextureByName(String string) {


}
}

I think i did something wron with the bindTextureByName....

I already gave you a thank you but if you still want to help me out a bit.

I'll daresay you did. This probably isn't right, but try Minecraft.theMinecraft.renderEngine.bindTexture("..."); instead.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted
  On 6/30/2013 at 10:40 PM, ObsequiousNewt said:

I'll daresay you did. This probably isn't right, but try Minecraft.theMinecraft.renderEngine.bindTexture("..."); instead.

Minecraft.theMinecraft.renderEngine.bindTexture("/textures/blocks/FryerTexture.png");

I get an error under theMinecraft

Posted

Try this:

this.bindTexture("/textures/blocks/FryerTexture.png");

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

So

bindTextureByName("/textures/blocks/FryerTexture.png");

In this code you need to place your model texture into the minecraft.jar/textures/block

So, you need this, If you want to have your texture in diff location:

bindTextureByName("mods/YOURMODID/textures/blocks/FryerTexture.png");

And your modid is Mod´s modid, defined in main class of mod.

This will allow you to place the texture into the minecraft.jar/mods/YOURMODID/textures/block

Try, and write back! Good luck with your mod  :)

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted
  On 7/4/2013 at 3:40 PM, mar21 said:

-snip-

Try, and write back! Good luck with your mod  :)

I do have my textures in textures/blocks but the model doesn't show up in my inventory...

Posted
  On 7/5/2013 at 12:11 PM, TwinAndy said:

  Quote

-snip-

Try, and write back! Good luck with your mod  :)

I do have my textures in textures/blocks but the model doesn't show up in my inventory...

 

Ok let me help you out with this quickly because it's easy enough if you know where what goes

 

Now we are assuming the following;

 

1) You are using a model ingame

2) You manage to render the model ingame

3) You haven't manage to render the model in your hand while holding it.

 

Now another way to do this one used by many was to create a normal item then register that item and use the item to place the model, this off course is a lot more work for something you can easily obtain by usng the following methods.

 

Drop your render file as it is atm as in completely and create a new one that should look like this

 

public class FryerRenderer extends TileEntitySpecialRenderer
{
    private ModelFryer aModel = new ModelFryer();

    public void renderAModel(TileEntityFryer var1, double var2, double var4, double var6, float var8)
    {
    	
        int i1 = 0;

        if (var1.worldObj != null)
        {
            i1 = var1.getBlockMetadata();
        }
    	
    	
        int var9;

        if (var1.worldObj == null)
        {
            var9 = 0;
        }
        else
        {
            Block var10 = var1.getBlockType();
            var9 = var1.getBlockMetadata();

            if (var10 != null && var9 == 0)
            {
                var9 = var1.getBlockMetadata();
            }
        }

        GL11.glPushMatrix();
        GL11.glTranslatef((float)var2 + 0.5F, (float)var4 + 1.5F, (float)var6 + 0.5F);
        short var11 = 0;

        if (var9 == 3)
        {
            var11 = 90;
        }

        if (var9 == 2)
        {
            var11 = 180;
        }

        if (var9 == 1)
        {
            var11 = 270;
        }

        GL11.glRotatef((float)var11, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
        this.bindTextureByName("/textures/blocks/FryerTexture.png");
        GL11.glPushMatrix();
        this.aModel.renderModel(0.0625F);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
    }

    public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8)
    {
        this.renderAModel((TileEntityFryer)var1, var2, var4, var6, var8);
    }
    

}

 

So instead of implementing ItemRenderer you implement TileEntitySpecialRenderer, for your tile entity you just need a file that can basically be empty something like this

 

public class TileEntityFryer extends TileEntity
{
}

 

Off course if your model has special function it would be in the tileentity so it will look a bit different.

 

Your model file is fine no changes needed their, the method that will be rendering your item for you is inside the render file this bit public void renderTileEntityAt, this is also used to render the model in game so the results would be that whatever you place in world would render in your hands and also in the inventory

 

The last bit of info you need to make sure you have is the registering part;

 

Now depending on how you go about registering your model the code should be like below I basically call my model registering from another class because i have over 30+ models in game and I use my clientproxy to register the model in cause you mostly need this to be client side only it will look something like this;

 

RenderingRegistry.registerBlockHandler(FryerID,new RenderInv());
FryerID = RenderingRegistry.getNextAvailableRenderId();

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFryer.class, new FryerRenderer());

 

then the following need to be register inside your proxy i basicly have thsi inside my client proxy and proxy just to make double sure it gets registered

 

GameRegistry.registerTileEntity(TileEntityFryer.class, "TileEntityFryer");

 

Now this code can be place anywhere as long as it's executed at runtime or while registering takes place.

 

just import all your class files you need and then you wil have to create the following class file you can call it anything you like actually I call mine RenderInv and this is where I would tell my model where and how to render the item in hand the code will look like this

 

public class RenderInv  implements ISimpleBlockRenderingHandler
{

public void renderInventoryBlock(Block block, int metadata, int modelID,
		RenderBlocks renderer) {

        if (block == BlockFryer)
        {
         TileEntityRenderer.instance.renderTileEntityAt(new TileEntityFryer(), 0.0D, 0.0D, 0.0D, 0.0F);
        }

}

public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,
		Block block, int modelId, RenderBlocks renderer) {
	return false;
}

public boolean shouldRender3DInInventory() {
	return true;
}

public int getRenderId() {
	return 0;
}

}

 

That's basically all you need to see your model in your hand, without the need to add an extra item into the game this will take your 3d model and create a 3d model for you that you can hold it in your hand. All you now need to do is take this code and implement it into your project the RenderInv can be expanded later on to include all your models inventory items and off course you need to make sure everything is imported and pointing towards the right class file names.

 

Happy coding...

Posted
  On 7/5/2013 at 1:18 PM, Conraad said:

  Quote

  Quote

-snip-

Try, and write back! Good luck with your mod  :)

I do have my textures in textures/blocks but the model doesn't show up in my inventory...

-snip-

Do you maybe have skype, still i don't really getting it to work

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

    • my game keeps crashing right before launching the game before full screen and keeps poping up this error message "error code 1 " The game crashed: rendering overlay Error: java.lang.IllegalAccessError: failed to access class com.mojang.blaze3d.platform.GlStateManager$TextureState from class net.coderbot.iris.gl.IrisRenderSystem$DSAARB (com.mojang.blaze3d.platform.GlStateManager$TextureState is in module minecraft@1.18.2 of loader 'TRANSFORMER' @d919544; net.coderbot.iris.gl.IrisRenderSystem$DSAARB is in module oculus@1.6.4 of loader 'TRANSFORMER' @d919544)
    • removing oculus or any of ETF or EMF or even embeddium doesn't change anything it just crashes again with error -1  https://gist.github.com/Tikalian-coconut/d49e8fb83bf57d5e04eb042522046786 this time i removed all 4 at same time and that gave it something is wrong with the game seriously..
    • crash report -> https://gist.github.com/Tikalian-coconut/18c41f97bdacef54725e5141f57697d7 from what i see it seems like Entity Texture Features doesn't like Oculus doing something or invert.. not sure it's why everything is all black textured but that causes a -1 error
    • well that's bad, cuz there's no crash report at all (the last crash report is from previous replies) it's probably another issue that doesn't fit in this bug report, the game works fine except that everything is black, no texture except the sky and skin, everything else is just black i've tried reloading the textures in game, see for drivers updates but it did nothing, seems like an issue with Embeddium or Oculus i think, but i know nothing compared to you i can still send the latest debug and latest.log files.. edit: it seems that when i re-add rechiseled (1.1.6-1.20.1) it crashes as error 1 (i can't remove it off from the modpack cuz that'll break all my builds on some maps) lemme start the game and get it to crash to get a crash report done)
    • If you've fallen victim to a crypto scam, you're not alone and thankfully, you're not without options. I highly recommend iBolt Cyber Hacker Company for anyone seeking professional and effective assistance in recovering scammed cryptocurrency. After extensive research and hearing from multiple satisfied clients, it's clear that iBolt stands out in a crowded and often unreliable market. Their team of experienced cyber experts and blockchain analysts uses advanced tracking techniques to follow stolen funds across the blockchain and engage with crypto exchanges when possible. They’re not just tech-savvy—they’re strategic and persistent. WHY CHOOSE iBOLT CYBER HACKER COMPANY? (1) Proven success in crypto asset recovery (2) Fast, professional, and discreet service (3) Skilled in blockchain forensics and cyber investigation (4) Committed to fighting online fraud and supporting victims Don’t give up. I strongly recommend reaching out to iBolt Cyber Hacker Company. ENQUIRIES: info @ iboltcyberhack . org/ www . iboltcyberhack. org/ +39. 351. 105. 3619.
  • Topics

×
×
  • Create New...

Important Information

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