Jump to content

Help with rendering obj file as block [1.7.10]


MikeyJY
 Share

Recommended Posts

I'm trying to make a laptop in minecraft. I created an obj in blender, I created an texture atlas(.png), I can't figure out the rendering in minecraft. It is my first mod:

Mod name "JavaProgrammingMod"(It adds java in minecraft)

JavaProgrammingMod.java:

package com.mikeyjy.JavaProgramming;

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

@Mod(modid = "jp", name = "JavaProgramming", version = "0.27b")
public class JavaProgrammingMod {

	public static Block blockPC;
	public static Item itemJavaSoft;
	
	@EventHandler
	public void preInit(FMLPreInitializationEvent event) {
		blockPC = new BlockPC(Material.anvil).setBlockName("BlockPC").setCreativeTab(tabJavaProgrammingMod);
		GameRegistry.registerBlock(blockPC, blockPC.getUnlocalizedName().substring(5));
		itemJavaSoft = new ItemJavaSoft().setUnlocalizedName("ItemJavaSoft").setTextureName("jp:itemjavasoft").setCreativeTab(tabJavaProgrammingMod);
		GameRegistry.registerItem(itemJavaSoft, itemJavaSoft.getUnlocalizedName().substring(5));
		GameRegistry.registerTileEntity(TileEntityBlockPC.class, "tileBlockPC");
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlockPC.class, new RenderTileEntityBlockPC());
	}
	
	@EventHandler
	public void preInit(FMLInitializationEvent event) {
		
	}
	
	@EventHandler
	public void preInit(FMLPostInitializationEvent event) {
		
	}
	
	public static CreativeTabs tabJavaProgrammingMod = new CreativeTabs("tabJavaProgrammingMod") {
		@Override
		public Item getTabIconItem() {
			return new ItemStack(blockPC).getItem();
		}
	};
}

BlockPC.java:

package com.mikeyjy.JavaProgramming;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockPC extends BlockContainer{

    public BlockPC(Material material) {
        super(material);

        this.setBlockName("Computer");
    }

    @Override
    public boolean renderAsNormalBlock(){
        return false;
    }

    @Override
    public int getRenderType(){
        return -1;
    }

    @Override
    public boolean isOpaqueCube(){
        return false;
    }

    @Override
    public TileEntity createNewTileEntity(World world, int par2) {
        return new TileEntityBlockPC();
    }
}

RenderTileEntityBlockPC:

package com.mikeyjy.JavaProgramming;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;

public class RenderTileEntityBlockPC extends TileEntitySpecialRenderer {

	ResourceLocation texture;
	ResourceLocation objModelLocation;
	IModelCustom model;
	public RenderTileEntityBlockPC(){
        texture = new ResourceLocation("jp", "models/BlockPCTexture.png");
        objModelLocation = new ResourceLocation("jp", "models/BlockPC.obj");
        model = AdvancedModelLoader.loadModel(objModelLocation);
	}
	@Override
    public void renderTileEntityAt(TileEntity te, double posX, double posY, double posZ, float timeSinceLastTick) {
		TileEntityBlockPC te2 = (TileEntityBlockPC) te;
		bindTexture(texture);

		GL11.glPushMatrix();
		GL11.glTranslated(posX + 0.5, posY + 0.5, posZ + 0.5);
	
		GL11.glPushMatrix();
	
		model.renderAll();
		GL11.glPopMatrix();
		GL11.glPopMatrix();
	}
}

I have these errors:

BlockPC.java line 34: TileEntityBlockPC cannot be resolved to a type

RenderTileEntityBlockPC line 23: TileEntityBlockPC cannot be resolved to a type

JavaProgrammingMod line 28: The method registerTileEntity(Class<? extends TileEntity>, String) in the type GameRegistry is not applicable for the arguments (Class<TileEntityBlockPC>, String)

JavaProgrammingMod line 29: The method bindTileEntitySpecialRenderer(Class<? extends TileEntity>, TileEntitySpecialRenderer) in the type ClientRegistry is not applicable for the arguments (Class<TileEntityBlockPC>, RenderTileEntityBlockPC)

 

I followed this tutorial: https://forums.minecraftforge.net/topic/29600-1710-rendering-obj-models-as-blocks/

 

Please help

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

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