Been trying to get a .obj model to spawn at a point as a block, from what i have so far I have an invisible block, a model loaded into the game and a TileEntitySpecialRenderer but for some reason when I place my block there is no modle rendering or it's not even existing where I placed my block! this has probably been a not too good explanation so I just want a model i have loaded to be where I place a block.
(I'm using an item to place the block BTW)
so far I have this:
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;
import org.lwjgl.opengl.GL11;
import Moeyoko.RunicMagic.MainRegistry;
public class RenderTileEntityRiftCrystal extends TileEntitySpecialRenderer{
ResourceLocation objModelLocation;
IModelCustom model;
public RenderTileEntityRiftCrystal(){
objModelLocation = new ResourceLocation(MainRegistry.MODID.toLowerCase() ,"models/RiftCrystalModel.obj");
model = AdvancedModelLoader.loadModel(objModelLocation);
}
@Override
public void renderTileEntityAt(TileEntity te, double posX, double posY, double posZ, float timeSinceLastTick) {
RiftCrystalModel te2 = (RiftCrystalModel) te;
GL11.glPushMatrix();
GL11.glTranslated(posX + 0.5, posY + 0.5, posZ + 0.5);
GL11.glPushMatrix();
model.renderAll();
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}[/Code]
[Code="BRiftCrystal"]package Moeyoko.RunicMagic.Block;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import Moeyoko.RunicMagic.CreativeTab.M_CreativeTab;
import Moeyoko.RunicMagic.Item.M_items;
import Moeyoko.RunicMagic.models.RiftCrystalModel;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BRiftCrystal extends Block {
protected BRiftCrystal(String unlocalizedName, Material p_i45394_1_) {
super(p_i45394_1_);
this.setHarvestLevel("Pickaxe", 2);
this.setHardness(20.F);
this.setStepSound(Block.soundTypeStone);
this.setBlockName(unlocalizedName);
this.setCreativeTab(M_CreativeTab.RunicBlocks);
}
public TileEntity createTileEntity(World world)
{
return new RiftCrystalModel();
}
@Override
public Item getItemDropped(int meta, Random random, int fortune) {
return M_items.RiftCrystal;
}
@Override
public int damageDropped(int metadata) {
return metadata;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side)
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return true;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int quantityDropped(int meta, int fortune, Random random) {
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public void onBlockAdded(World world, int x, int y, int z){
super.onBlockAdded(world, x, y, z);
createTileEntity(world);
}
}
[/Code]
[Code="ClientProxy"]package Moeyoko.RunicMagic;
import Moeyoko.RunicMagic.models.RenderTileEntityRiftCrystal;
import Moeyoko.RunicMagic.models.RiftCrystalModel;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class ClientProxy extends ServerProxy {
public void registerRenderInfo(){
ClientRegistry.bindTileEntitySpecialRenderer(RiftCrystalModel.class, new RenderTileEntityRiftCrystal());
}
public void registerRender(){
}
public int addArmor(String armor){
return RenderingRegistry.addNewArmourRendererPrefix(armor);
}
}
[/Code]
[Code="RiftCrystalModel"]package Moeyoko.RunicMagic.models;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;
public class RiftCrystalModel extends TileEntity{
}
[/Code]
[Code="M_blocks"]
package Moeyoko.RunicMagic.Block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.registry.GameRegistry;
import Moeyoko.RunicMagic.models.RiftCrystalModel;
public class M_blocks {
public static Block RunicBookShelf;
public static Block RiftCrystal;
public static void mainRegistry(){
initializeBlock();
registerBlock();
}
public static void registerBlock(){
GameRegistry.registerBlock(RunicBookShelf, RunicBookShelf.getUnlocalizedName());
GameRegistry.registerBlock(RiftCrystal, RiftCrystal.getUnlocalizedName());
GameRegistry.registerTileEntity(RiftCrystalModel.class, "0x1");
}
public static void initializeBlock(){
RunicBookShelf = new RunicBookShelf(Material.wood);
RiftCrystal = new BRiftCrystal("riftcrystal", Material.clay);
}
}
[/Code]
Am I missing something? is there a server registry?
Methods for the TileEntity?
anything?