Jump to content

Custom Rendered Item


majesticmadman98

Recommended Posts

Never made a custom rendered item before, so I'm trying to use similar method to how a block is done. I've got to a point where there's no errors but the item doesn't render in game it's just a flat item with a missing texture. I think the error is in the client proxy but not sure, thanks in advance. Sorry forgot spoilers

 

Main:

package dma.main;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.registry.GameRegistry;

import dma.block.DalekConsole2;

import dma.items.SonicScrewdriver;

import dma.proxies.CommonProxy;

 

@Mod(modid = "dma", name = "Dalek Mod Addon", version = "1.0.0")

 

public class main {public static final String MODID = "dma";

public static final String VERSION = "1.0";

 

public static Block DalekConsole2;

public static Item sonic;

 

@SidedProxy(clientSide = "dma.proxies.ClientProxy", serverSide = "dma.proxies.CommonProxy")

public static CommonProxy Proxy;

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

 

/*public static CreativeTabs dmaTab = new CreativeTabs("dmatab"){

  @Override

  public Item getTabIconItem() {

        return Items.baked_potato;

}

    }; */

   

DalekConsole2 = new DalekConsole2(Material.rock).setBlockName("DalekConsole2");

GameRegistry.registerBlock(DalekConsole2, "DalekConsole2");

 

sonic = new SonicScrewdriver().setUnlocalizedName("SonicScrewdriver");

GameRegistry.registerItem(sonic, "SonicScrewdriver");

 

Proxy.registerRenderThings();

}

 

 

 

@EventHandler

public void init(FMLInitializationEvent event)

{

   

}

}

 

 

Item:

package dma.items;

 

import dma.tileentity.TileEntityDalekConsole2;

import dma.tileentity.TileEntitySonicScrewdriver;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

public class SonicScrewdriver extends Item{

 

public SonicScrewdriver() {

setCreativeTab(CreativeTabs.tabTools);

 

}

public int getRenderType() {

return -1;

}

public TileEntity createNewTileEntity(World var1, int var2) {

return new TileEntitySonicScrewdriver();

}

 

 

}

 

 

Client Proxy:

package dma.proxies;

 

import renderer.RenderDalekConsole2;

import cpw.mods.fml.client.registry.ClientRegistry;

import dma.tileentity.TileEntityDalekConsole2;

import dma.tileentity.TileEntitySonicScrewdriver;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.item.Item;

import net.minecraftforge.client.MinecraftForgeClient;

 

public class ClientProxy extends CommonProxy{

public void registerRenderThings() {

//dalek console 2

TileEntitySpecialRenderer render = new RenderDalekConsole2();

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDalekConsole2.class, render);

 

//sonic

TileEntitySpecialRenderer render1 = new RenderDalekConsole2();

ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySonicScrewdriver.class, render);

 

 

}

public void registerTileEntitySpecialRenderer() {

}

}

 

Tile Entity:package dma.tileentity;

 

import net.minecraft.tileentity.TileEntity;

 

public class TileEntitySonicScrewdriver extends TileEntity{

 

}

 

 

Render:

package renderer;

 

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.client.IItemRenderer;

 

import org.lwjgl.opengl.GL11;

 

import dma.items.SonicScrewdriver;

import dma.main.main;

import dma.models.DalekConsole2;

import dma.models.sonic;

 

public class RenderSonicScrewdriver implements IItemRenderer{

 

private static final ResourceLocation texture = new ResourceLocation(main.MODID + ":" + "textures/models/Sonic.png");

 

 

TileEntitySpecialRenderer render;

private TileEntity entity;

 

public RenderSonicScrewdriver(TileEntitySpecialRenderer render, TileEntity entity){

this.entity = entity;

this.render = render;

}

@Override

public boolean handleRenderType(ItemStack item, ItemRenderType type) {

 

return false;

}

 

@Override

public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,

ItemRendererHelper helper) {

return false;

}

 

@Override

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

if(type == IItemRenderer.ItemRenderType.ENTITY)

GL11.glTranslatef(-0.5F, 0F, -0.5F);

this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);

 

}

 

 

 

 

}

 

 

model:

 

package dma.models;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class sonic extends ModelBase

{

  //fields

    ModelRenderer Shape2;

    ModelRenderer Shape1;

    ModelRenderer Shape4;

    ModelRenderer Shape5;

    ModelRenderer Shape6;

    ModelRenderer Shape7;

    ModelRenderer Shape9;

    ModelRenderer Shape8;

    ModelRenderer Shape3;

    ModelRenderer Shape10;

    ModelRenderer Shape11;

    ModelRenderer Shape12;

    ModelRenderer Shape13;

    ModelRenderer Shape14;

    ModelRenderer Shape15;

    ModelRenderer Shape16;

    ModelRenderer Shape17;

    ModelRenderer Shape18;

    ModelRenderer Shape19;

    ModelRenderer Shape20;

    ModelRenderer Shape21;

 

  public sonic()

  {

    textureWidth = 64;

    textureHeight = 32;

   

      Shape2 = new ModelRenderer(this, 0, 29);

      Shape2.addBox(0F, 0F, 0F, 1, 2, 1);

      Shape2.setRotationPoint(0F, -8F, 0F);

      Shape2.setTextureSize(64, 32);

      Shape2.mirror = true;

      setRotation(Shape2, 0F, 0F, 0F);

      Shape1 = new ModelRenderer(this, 4, 29);

      Shape1.addBox(-0.5F, -2F, -0.5F, 1, 2, 1);

      Shape1.setRotationPoint(0.5F, -7.8F, 0.5F);

      Shape1.setTextureSize(64, 32);

      Shape1.mirror = true;

      setRotation(Shape1, 0F, 0F, 0.2443461F);

      Shape4 = new ModelRenderer(this, 0, 29);

      Shape4.addBox(0F, 0F, 0F, 1, 2, 1);

      Shape4.setRotationPoint(4F, -8F, 0F);

      Shape4.setTextureSize(64, 32);

      Shape4.mirror = true;

      setRotation(Shape4, 0F, 0F, 0F);

      Shape5 = new ModelRenderer(this, 4, 29);

      Shape5.addBox(-0.5F, -2F, -0.5F, 1, 2, 1);

      Shape5.setRotationPoint(4.5F, -7.8F, 0.5F);

      Shape5.setTextureSize(64, 32);

      Shape5.mirror = true;

      setRotation(Shape5, 0F, 0F, -0.2443461F);

      Shape6 = new ModelRenderer(this, 4, 29);

      Shape6.addBox(-0.5F, -2F, -0.5F, 1, 2, 1);

      Shape6.setRotationPoint(2.5F, -7.8F, 2.5F);

      Shape6.setTextureSize(64, 32);

      Shape6.mirror = true;

      setRotation(Shape6, 0.2443461F, 0F, 0F);

      Shape7 = new ModelRenderer(this, 0, 29);

      Shape7.addBox(0F, 0F, 0F, 1, 2, 1);

      Shape7.setRotationPoint(2F, -8F, 2F);

      Shape7.setTextureSize(64, 32);

      Shape7.mirror = true;

      setRotation(Shape7, 0F, 0F, 0F);

      Shape9 = new ModelRenderer(this, 4, 29);

      Shape9.addBox(-0.5F, -2F, -0.5F, 1, 2, 1);

      Shape9.setRotationPoint(2.5F, -7.8F, -1.5F);

      Shape9.setTextureSize(64, 32);

      Shape9.mirror = true;

      setRotation(Shape9, -0.2443461F, 0F, 0F);

      Shape8 = new ModelRenderer(this, 0, 29);

      Shape8.addBox(0F, 0F, 0F, 1, 2, 1);

      Shape8.setRotationPoint(2F, -8F, -2F);

      Shape8.setTextureSize(64, 32);

      Shape8.mirror = true;

      setRotation(Shape8, 0F, 0F, 0F);

      Shape3 = new ModelRenderer(this, 0, 23);

      Shape3.addBox(0F, 0F, 0F, 4, 1, 4);

      Shape3.setRotationPoint(0.5F, -6F, -1.5F);

      Shape3.setTextureSize(64, 32);

      Shape3.mirror = true;

      setRotation(Shape3, 0F, 0F, 0F);

      Shape10 = new ModelRenderer(this, 0, 0);

      Shape10.addBox(0F, 0F, 0F, 1, 1, 1);

      Shape10.setRotationPoint(4F, -6F, 0F);

      Shape10.setTextureSize(64, 32);

      Shape10.mirror = true;

      setRotation(Shape10, 0F, 0F, 0F);

      Shape11 = new ModelRenderer(this, 0, 0);

      Shape11.addBox(0F, 0F, 0F, 1, 1, 1);

      Shape11.setRotationPoint(2F, -6F, 2F);

      Shape11.setTextureSize(64, 32);

      Shape11.mirror = true;

      setRotation(Shape11, 0F, 0F, 0F);

      Shape12 = new ModelRenderer(this, 0, 0);

      Shape12.addBox(0F, 0F, 0F, 1, 1, 1);

      Shape12.setRotationPoint(2F, -6F, -2F);

      Shape12.setTextureSize(64, 32);

      Shape12.mirror = true;

      setRotation(Shape12, 0F, 0F, 0F);

      Shape13 = new ModelRenderer(this, 0, 0);

      Shape13.addBox(0F, 0F, 0F, 1, 1, 1);

      Shape13.setRotationPoint(0F, -6F, 0F);

      Shape13.setTextureSize(64, 32);

      Shape13.mirror = true;

      setRotation(Shape13, 0F, 0F, 0F);

      Shape14 = new ModelRenderer(this, 8, 28);

      Shape14.addBox(0F, 0F, 0F, 1, 3, 1);

      Shape14.setRotationPoint(2F, -9F, 0F);

      Shape14.setTextureSize(64, 32);

      Shape14.mirror = true;

      setRotation(Shape14, 0F, 0F, 0F);

      Shape15 = new ModelRenderer(this, 0, 16);

      Shape15.addBox(0F, 1F, 0F, 5, 2, 5);

      Shape15.setRotationPoint(0F, -6F, -2F);

      Shape15.setTextureSize(64, 32);

      Shape15.mirror = true;

      setRotation(Shape15, 0F, 0F, 0F);

      Shape16 = new ModelRenderer(this, 16, 27);

      Shape16.addBox(0F, 0F, 0F, 4, 1, 4);

      Shape16.setRotationPoint(0.5F, -3F, -1.5F);

      Shape16.setTextureSize(64, 32);

      Shape16.mirror = true;

      setRotation(Shape16, 0F, 0F, 0F);

      Shape17 = new ModelRenderer(this, 0, 9);

      Shape17.addBox(0F, 0F, 0F, 5, 2, 5);

      Shape17.setRotationPoint(0F, -2F, -2F);

      Shape17.setTextureSize(64, 32);

      Shape17.mirror = true;

      setRotation(Shape17, 0F, 0F, 0F);

      Shape18 = new ModelRenderer(this, 48, 4);

      Shape18.addBox(0F, 0F, 0F, 4, 24, 4);

      Shape18.setRotationPoint(0.5F, 0F, -1.5F);

      Shape18.setTextureSize(64, 32);

      Shape18.mirror = true;

      setRotation(Shape18, 0F, 0F, 0F);

      Shape19 = new ModelRenderer(this, 20, 20);

      Shape19.addBox(0F, 0F, 0F, 3, 6, 1);

      Shape19.setRotationPoint(1F, 4F, -2F);

      Shape19.setTextureSize(64, 32);

      Shape19.mirror = true;

      setRotation(Shape19, 0F, 0F, 0F);

      Shape20 = new ModelRenderer(this, 28, 21);

      Shape20.addBox(0F, 0F, 0F, 5, 1, 5);

      Shape20.setRotationPoint(0F, 12F, -2F);

      Shape20.setTextureSize(64, 32);

      Shape20.mirror = true;

      setRotation(Shape20, 0F, 0F, 0F);

      Shape21 = new ModelRenderer(this, 28, 9);

      Shape21.addBox(0F, 0F, 0F, 5, 7, 5);

      Shape21.setRotationPoint(0F, 17.1F, -2F);

      Shape21.setTextureSize(64, 32);

      Shape21.mirror = true;

      setRotation(Shape21, 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, entity);

    Shape2.render(f5);

    Shape1.render(f5);

    Shape4.render(f5);

    Shape5.render(f5);

    Shape6.render(f5);

    Shape7.render(f5);

    Shape9.render(f5);

    Shape8.render(f5);

    Shape3.render(f5);

    Shape10.render(f5);

    Shape11.render(f5);

    Shape12.render(f5);

    Shape13.render(f5);

    Shape14.render(f5);

    Shape15.render(f5);

    Shape16.render(f5);

    Shape17.render(f5);

    Shape18.render(f5);

    Shape19.render(f5);

    Shape20.render(f5);

    Shape21.render(f5);

  }

  public void renderModel(float f){

  Shape1.render(f);

    Shape4.render(f);

    Shape5.render(f);

    Shape6.render(f);

    Shape7.render(f);

    Shape9.render(f);

    Shape8.render(f);

    Shape3.render(f);

    Shape10.render(f);

    Shape11.render(f);

    Shape12.render(f);

    Shape13.render(f);

    Shape14.render(f);

    Shape15.render(f);

    Shape16.render(f);

    Shape17.render(f);

    Shape18.render(f);

    Shape19.render(f);

    Shape20.render(f);

    Shape21.render(f);

 

  }

 

  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, Entity entity)

  {

    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);

  }

 

}

 

 

Link to comment
Share on other sites

Two things.

 

You haven't even set a texture location (path) for your item, no wonder it shows a missing texture.

If I remember you need to bind/set both models and textures to "that" specific item.

 

Take a look at this. Although it's outdated, I bet you can find a way to work around the methods and things. c:

 

Link to comment
Share on other sites

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.