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:

 

 

public class mod_test {

@SidedProxy(blabla)

    public static CommonProxy proxy;

@Instance(value = Logic.MOD_ID)

    public static mod_test instance;

private GuiHandlerTestTable guiHandlerTestTable = new GuiHandlerTestTable();

public static CreativeTabs TestModBlocks = new CreativeTabsTestBlocks(CreativeTabs.getNextID(), "BlocksTestTab", "Test Mod Blocks Tab");

//Blocks

public static Block TestTable;

//BlockID

public static int TestTableID;

@EventHandler

    public void preInit(FMLPreInitializationEvent event) {

TestBlockManager();

TestBlockRegistry();

    }

 

@EventHandler

    public void load(FMLInitializationEvent event) {

proxy.registerRenderers();

    }

@EventHandler

    public void postInit(FMLPostInitializationEvent event) {

   

    }

   

    private void TestBlockManager() {

    Table = new BlocTestkProjectTableTestTableID, TileEntityTestTable.class, Material.wood).setHardness(3.0F).setResistance(5.0F).setStepSound(Block.soundWoodFootstep).setUnlocalizedName("testbench").setCreativeTab(TestModBlocks);

    }

   

    private void TestBlockRegistry() {

    //Registry

    GameRegistry.registerBlock(TestTable, TestTable.getUnlocalizedName());{

    //Names

    LanguageRegistry.addName(TestTable, "Test Table");

}

 

 

BlockClass:

 

 

private Class TileEntityClass;

 

public BlockTestTable(int i,Class tClass, Material par3Material)

  {

        super(i, par3Material);

        TileEntityClass = tClass;

          float f = 0F;

          setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.05F, 1.0F);

  }

 

@Override

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t)

{

    TileEntity tile_entity = world.getBlockTileEntity(x, y, z);

   

            if(tile_entity == null || player.isSneaking()){

            return false;

            }

 

    player.openGui(mod_test.instance, 0, world, x, y, z);

    return true;

    }

 

 

@Override

public void breakBlock(World world, int x, int y, int z, int i, int j)

{

    super.breakBlock(world, x, y, z, i, j);

    }

 

 

        public TileEntity getBlockEntity()

        {

                        try{

                                        return (TileEntity)TileEntityClass.newInstance();

                        }

                        catch(Exception exception){

                                        throw new RuntimeException(exception);

                        }

        }

 

        public int idDropped(int i, Random random, int j)

        {

                return this.blockID;

        }

 

       

        public int quanityDropped(Random random)

        {

          return 1;

        }

 

        @Override

        public int getRenderType()

        {

        return ClientProxy.BlockTestTableRenderID;

        }

 

        public boolean isOpaqueCube()

        {

                return false;

        }

 

        public boolean renderAsNormalBlock()

        {

                return false;

        }

public TileEntity createNewTileEntity(World world)

{

  return new TileEntityTestTable();

 

}

}

 

 

TileEntityTestTable:

 

 

 

This is for the gui not need code;

 

 

 

TileEntityRender:

 

 

 

public class TileEntityTestTableRenderer extends TileEntitySpecialRenderer

{

public static final ResourceLocation testTableLoc = new ResourceLocation (Logic.MOD_IDFOLDER + ":" + "textures/entity/test_tabletest_table.png");

        public TileEntityTestTableRenderer()

        {

                aModel = new TestTableModel();

        }

 

        public void renderAModelAt(TileEntityTestTable 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);

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

                GL11.glRotatef(180F, 0F, 0F, 1F);

                bindTexture(testTableLoc);

                GL11.glPushMatrix();

                aModel.renderModel(0.0625F);

                GL11.glPopMatrix();   

                GL11.glPopMatrix();                                   

        }

        public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2,

                        float f)

        {

                renderAModelAt((TileEntityTestTable)tileentity, d, d1, d2, f);

        }

        private TestTableModel aModel;

}

 

 

 

 

client proxy:

 

 

public class ClientProxy extends CommonProxy {

 

public static int BlockTestTableRenderID;

 

@Override

    public void registerRenderers() {

BlockTestTableRenderID = RenderingRegistry.getNextAvailableRenderId();

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTestTable.class, new TileEntityTestTableRenderer());

}

 

 

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Honestly, the forums are a back burner thing. Not many people use it. Best option is discord. I know that I haven't looked at the forums for more then admin tasks in quite a while. You're also best off not following tutorials which give you code. Knowing programming and reading the MC/Forge code yourself would be the best way to go.
    • on my last computer, i had a similar problem with forge/ neoforge mods but instead them launcher screen was black
    • I am trying to make a mod, all it is, a config folder that tells another mod to not require a dependency, pretty simple right.. well, I dont want whoever downloads my mod to have to download 4 other mods and then decide if they want 2 more that they kinda really need.. i want to make my mod basically implement all of these mods, i really dont care how it does it, ive tried putting them in every file location you can think of, ive downloaded intellij, mcreator, and tried vmware but thats eh (had it from school). I downloaded them in hopes theyd create the correct file i needed but honestly im only more lost now. I have gotten my config file to work, if i put all these mods into my own mods folder and the config file into the config and it works (unvbelievably) but i want to share this to everyone else, lets just say this mod will legitimately get 7M downloads.  I tried putting them in a run folder then having it create all the contents in that for a game (mods,config..etc) then i drop the mods in and all the sudden i cant even open the game, like it literally works with my own world i play on, but i cant get it to work on any coding platform, they all have like built in java versions you cant switch, its a nightmare. I am on 1.20.1 I need Java 17 (i dont think the specific versions of 17 matter) I have even tried recreating the mods i want to implement and deleting import things like net.adamsandler.themodsname and replacing it with what mine is. that only creates other problems, where im at right now is i got the thing to start opening then it crashes, closest ive gotten it, then it just says this  exception in thread "main" cpw.mods.niofs.union.unionfilesystem$uncheckedioexception: java.util.zip.zipexception: zip end header not found caused by: java.util.zip.zipexception: zip end header not found basically saying theres something wrong with my java.exe file, so i tried downloading so many different versions of java and putting them all in so many different spots, nothing, someone online says its just a mod that isnt built right so i put the mod into an editor and bunch of errors came up, id post it but i deleted it on accident, i just need help integrating mods
    • Vanilla 1.16.5 Crash Report [#L2KYKaK] - mclo.gs  
    • Hello, probably the last update, if anyone has the same problem or this can be of any help, the answer was pretty simple, textures started rendering just using a Tesselator instead of a VertexConsumer given by a MultibufferSource and a RenderType, pretty simple
  • Topics

×
×
  • Create New...

Important Information

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