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

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

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

-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

-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

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

 

 

aka if you have a boat at 0, 0

 

 

if you rotate then translate:

rotate: the boat faces left:

translate: the boat moves 10 unit

o = origin e = empty b = boat

rotate give

[d]  (for the sake of it well just imagine this is a rotation and now another letter

then translate:

[o][e][e][d]

 

if you translate then rotate:

translate, the boat is now 10 unit away

rotate: opengl rotates the origin, meaning

 

[o][e][e] would actually give  [o]

                                                    [e]

                                                    [e]

                                                   

nvm formating screwup up my ascii art

 

 

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

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

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

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

-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

-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

    • After some time minecraft crashes with an error. Here is the log https://drive.google.com/file/d/1o-2R6KZaC8sxjtLaw5qj0A-GkG_SuoB5/view?usp=sharing
    • The specific issue is that items in my inventory wont stack properly. For instance, if I punch a tree down to collect wood, the first block I collected goes to my hand. So when I punch the second block of wood to collect it, it drops, but instead of stacking with the piece of wood already in my hand, it goes to the second slot in my hotbar instead. Another example is that I'll get some dirt, and then when I'm placing it down later I'll accidentally place a block where I don't want it. When I harvest it again, it doesn't go back to the stack that it came from on my hotbar, where it should have gone, but rather into my inventory. That means that if my inventory is full, then the dirt wont be picked up even though there should be space available in the stack I'm holding. The forge version I'm using is 40.3.0, for java 1.18.2. I'll leave the mods I'm using here, and I'd appreciate it if anybody can point me in the right direction in regards to figuring out how to fix this. I forgot to mention that I think it only happens on my server but I'm not entirely sure. PLEASE HELP ME! LIST OF THE MODS. aaa_particles Adorn AdvancementPlaques AI-Improvements AkashicTome alexsdelight alexsmobs AmbientSounds amwplushies Animalistic another_furniture AppleSkin Aquaculture aquamirae architectury artifacts Atlas-Lib AutoLeveling AutoRegLib auudio balm betterfpsdist biggerstacks biomancy BiomesOPlenty blockui blueprint Bookshelf born_in_chaos Botania braincell BrassAmberBattleTowers brutalbosses camera CasinoCraft cfm (MrCrayfish’s Furniture Mod) chat_heads citadel cloth-config Clumps CMDCam CNB cobweb collective comforts convenientcurioscontainer cookingforblockheads coroutil CosmeticArmorReworked CozyHome CrabbersDelight crashexploitfixer crashutilities Create CreativeCore creeperoverhaul cristellib crittersandcompanions Croptopia CroptopiaAdditions CullLessLeaves curios curiouslanterns curiouslights Curses' Naturals CustomNPCs CyclopsCore dannys_expansion decocraft Decoration Mod DecorationDelightRefurbished Decorative Blocks Disenchanting DistantHorizons doubledoors DramaticDoors drippyloadingscreen durabilitytooltip dynamic-fps dynamiclights DynamicTrees DynamicTreesBOP DynamicTreesPlus Easy Dungeons EasyAnvils EasyMagic easy_npc eatinganimation ecologics effective_fg elevatorid embeddium emotecraft enchantlimiter EnchantmentDescriptions EnderMail engineersdecor entityculling entity_model_features entity_texture_features epicfight EvilCraft exlinefurniture expandability explosiveenhancement factory-blocks fairylights fancymenu FancyVideo FarmersDelight fast-ip-ping FastSuite ferritecore finsandtails FixMySpawnR Forge Middle Ages fossil FpsReducer2 furnish GamingDeco geckolib goblintraders goldenfood goodall H.e.b habitat harvest-with-ease hexerei hole_filler huge-structure-blocks HunterIllager iammusicplayer Iceberg illuminations immersive_paintings incubation infinitybuttons inventoryhud InventoryProfilesNext invocore ItemBorders itemzoom Jade jei (Just Enough Items) JetAndEliasArmors journeymap JRFTL justzoom kiwiboi Kobolds konkrete kotlinforforge lazydfu LegendaryTooltips libIPN lightspeed lmft lodestone LongNbtKiller LuckPerms Lucky77 MagmaMonsters malum ManyIdeasCore ManyIdeasDoors marbledsarsenal marg mcw-furniture mcw-lights mcw-paths mcw-stairs mcw-trapdoors mcw-windows meetyourfight melody memoryleakfix Mimic minecraft-comes-alive MineTraps minibosses MmmMmmMmmMmm MOAdecor (ART, BATH, COOKERY, GARDEN, HOLIDAYS, LIGHTS, SCIENCE) MobCatcher modonomicon mods_optimizer morehitboxes mowziesmobs MutantMonsters mysticalworld naturalist NaturesAura neapolitan NekosEnchantedBooks neoncraft2 nerb nifty NightConfigFixes nightlights nocube's_villagers_sell_animals NoSeeNoTick notenoughanimations obscure_api oculus oresabovediamonds otyacraftengine Paraglider Patchouli physics-mod Pillagers Gun PizzaCraft placeableitems Placebo player-animation-lib pneumaticcraft-repressurized polymorph PrettyPipes Prism projectbrazier Psychadelic-Chemistry PuzzlesLib realmrpg_imps_and_demons RecipesLibrary reeves-furniture RegionsUnexplored restrictedportals revive-me Scary_Mobs_And_Bosses selene shetiphiancore ShoulderSurfing smoothboot
    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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