Jump to content

Recommended Posts

Posted

SOLVED REMAKING IT WITH A MODEL IN OBJ AND MODIFY THE METHODS

Hello all, I make a custom block with a model created with techne.

It work (the texture of the block into the game world see) but into inventory it not have a texture...

My situation is similar to the chest: the texture of the block is into "assets/mymod/textures/entity/texture.png"

 

How can I apply the texture of the world into the inventory also? (What'is the metod, and if you can make a example of it)

 

Thanks

Posted

That took me while to figure out  but now that I know it its easy

 

first you need an Item render class for it such as this

 

Disclaimer: this works for blocks, may or may not work for items

 

itemcomputerrenderer

package kakarotvg.omega.render.itemrender;

import kakarotvg.omega.entity.tileentity.TileEntityComputerEntity;
import kakarotvg.omega.model.ModelComputer;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;

public class ItemComputerRenderer implements IItemRenderer {

    private ModelComputer computermodel;

    public ItemComputerRenderer() {
        computermodel = new ModelComputer();
    }

    @Override
    public boolean handleRenderType(ItemStack item, ItemRenderType type) {
        // TODO Auto-generated method stub
        return true;
    }

    @Override
    public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
        // TODO Auto-generated method stub
        return true;
    }

    @Override
    public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
        TileEntityRenderer.instance.renderTileEntityAt(new TileEntityComputerEntity(), 0.0D, 0.0D, 0.0D, 0.0f);
    }

}

 

then you need to register the item renderer in your client proxy

package kakarotvg.omega.proxys;

import kakarotvg.omega.entity.mobs.EntityAnnihilator;
import kakarotvg.omega.entity.mobs.EntityEliminator;
import kakarotvg.omega.entity.mobs.EntityJungleAssasin;
import kakarotvg.omega.entity.mobs.EntityOmegaHound;
import kakarotvg.omega.entity.mobs.EntityOmegakiller;
import kakarotvg.omega.entity.mobs.EntitySlayer;
import kakarotvg.omega.entity.tileentity.TileEntityComputerEntity;
import kakarotvg.omega.entity.tileentity.TileEntityDarknessSolidEntity;
import kakarotvg.omega.handlers.tileentity.TileEntityHandler;
import kakarotvg.omega.model.ModelAnnihilator;
import kakarotvg.omega.model.ModelEliminator;
import kakarotvg.omega.model.ModelJungleAsasin;
import kakarotvg.omega.model.ModelOmegaHound;
import kakarotvg.omega.model.ModelOmegakiller;
import kakarotvg.omega.model.ModelSlayer;
import kakarotvg.omega.render.itemrender.ItemComputerRenderer;
import kakarotvg.omega.render.itemrender.UnderworldChestItemRender;
import kakarotvg.omega.render.mobs.RenderAnnihilator;
import kakarotvg.omega.render.mobs.RenderEliminator;
import kakarotvg.omega.render.mobs.RenderJungleAssasin;
import kakarotvg.omega.render.mobs.RenderOmegaHound;
import kakarotvg.omega.render.mobs.RenderOmegaKiller;
import kakarotvg.omega.render.mobs.RenderSlayer;
import kakarotvg.omega.render.tileentity.TileEntityComputerRenderer;
import kakarotvg.omega.render.tileentity.TileEntityDarknessSolidRenderer;
import kakarotvg.omega.render.tileentity.TileEntityUnderworldchestrenderer;
import kakarotvg.omega.tileentity.TileEntityUnderworldChest;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxy extends CommonProxy {

    public void registerRenderInformation() {
        // Renders the Mobs
        RenderingRegistry.registerEntityRenderingHandler(EntityOmegaHound.class, new RenderOmegaHound(new ModelOmegaHound(), 0.05F));
        RenderingRegistry.registerEntityRenderingHandler(EntityOmegakiller.class, new RenderOmegaKiller(new ModelOmegakiller(), 0.5F));
        RenderingRegistry.registerEntityRenderingHandler(EntityEliminator.class, new RenderEliminator(new ModelEliminator(), 0.5F));
        RenderingRegistry.registerEntityRenderingHandler(EntitySlayer.class, new RenderSlayer(new ModelSlayer(), 0.5F));
        RenderingRegistry.registerEntityRenderingHandler(EntityAnnihilator.class, new RenderAnnihilator(new ModelAnnihilator(), 0.5F));
        RenderingRegistry.registerEntityRenderingHandler(EntityJungleAssasin.class, new RenderJungleAssasin(new ModelJungleAsasin(), 0.5F));
    }

    public void registerRenderThings() {
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDarknessSolidEntity.class, new TileEntityDarknessSolidRenderer());
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityComputerEntity.class, new TileEntityComputerRenderer());
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityUnderworldChest.class, new TileEntityUnderworldchestrenderer());
        // the item renderers
        MinecraftForgeClient.registerItemRenderer(TileEntityHandler.underworldchest.blockID, new UnderworldChestItemRender());
        MinecraftForgeClient.registerItemRenderer(TileEntityHandler.computer.blockID, new ItemComputerRenderer());
    }

    @Override
    public void registerRenders() {

    }

    @Override
    public int addArmor(String armor) {
        return RenderingRegistry.addNewArmourRendererPrefix(armor);
    }

}

 

then you need to make sure that if your block rotates based on your direction when placing it.

then you have to have an if else statement for the world

package kakarotvg.omega.render.tileentity;

import kakarotvg.omega.Reference;
import kakarotvg.omega.model.ModelComputer;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

public class TileEntityComputerRenderer extends TileEntitySpecialRenderer {

    //The model of your block
    public final ModelComputer model;
    private static final ResourceLocation resourceloc = new ResourceLocation(Reference.MOD_ID + ":" + "textures/tileentity/computer.png");

    public TileEntityComputerRenderer() {
        this.model = new ModelComputer();
    }

    @Override
    public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
        //The PushMatrix tells the renderer to "start" doing something.
        GL11.glPushMatrix();

        //This is setting the initial location.
        GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
        //This is the texture of your block. It's pathed to be the same place as your other blocks here.
        //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!    
        Minecraft.getMinecraft().renderEngine.func_110577_a(resourceloc);
        GL11.glPushMatrix();
        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

        adjustLightFixture(te.worldObj, te.xCoord, te.yCoord, te.zCoord, te.blockType);

        //A reference to your Model file. Again, very important.
        //Tell it to stop rendering for both the PushMatrix's
        GL11.glPopMatrix();
        GL11.glPopMatrix();
    }

    //Set the lighting stuff, so it changes it's brightness properly.       
    private void adjustLightFixture(World world, int i, int j, int k, Block block) {
        //  the if statement checking for if the world is null or not if not renders the block if null renders the item model
        // != means not equal
        if (world != null) {
            int dir = world.getBlockMetadata(i, j, k);

            GL11.glPushMatrix();
            //This line actually rotates the renderer.
            GL11.glRotatef(dir * (90F), 0F, 1F, 0F);

            this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
            /*
             * Place your rendering code here.
             */

            GL11.glPopMatrix();
        }
        else {
            GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
            this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        }

    }
}

if (You.likescoding == false){
      You.goaway;
}

Posted

in your class add this code

public static final ResourceLocation TEXTURE = new ResourceLocation("mymod", "textures/entity/texture.png");

and add this to your item renderers render method after the GL11.glDisable line and after the GL11.glTranslate line

FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);

and just leave the TEXTURE as TEXTURE, its referencing the ResourceLocation. If that doesn't work toy with it.

Posted

this is 1.6.2 bind texture does not exist and registering textures requires this format for custom mobs and custom blocks ("modid:texture/(pathtoimage).png

if (You.likescoding == false){
      You.goaway;
}

Posted

I just tried the

 

FMLClientHandler.instance().getClient().renderEngine.bindtexture(TEXTURE);

 

in my mod and it could not find bindtexture but this worked

 

FMLClientHandler.instance().getClient().renderEngine.func_110577_a(resourceloc);

if (You.likescoding == false){
      You.goaway;
}

Posted

Ok Place my code maybe it help more:

 

 

  Reveal hidden contents

 

BlockClass:

 

 

  Reveal hidden contents

 

 

TileEntityTestTable:

 

 

  Reveal hidden contents

 

 

TileEntityRender:

 

 

  Reveal hidden contents

 

 

client proxy:

 

  Reveal hidden contents

 

 

1)How can I render my model into inventory?

2)How can I render the texture file into the inventory?

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.