Jump to content

Recommended Posts

Posted

First, i hava specified OBJLoader during preint().

second, in my blocks , i  havd used getRenderType() and getExtendedState() methods.

why does not it work ?

sorry for my poor English,thank you.

 

Posted
6 minutes ago, larsgerrits said:

Show every file related to the OBJ and model, and post the logs.

package lj.fmltutor.block;
import lj.fmltutor.creativetab.CreativeTabsFMLTutor;
import lj.fmltutor.creativetab.CreativeTabsLoader;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.property.IExtendedBlockState;


public class BlockOBJTest2 extends Block {
    protected BlockOBJTest2( ) {
        super(Material.ROCK);
        this.setUnlocalizedName("blockTest2");
        this.setRegistryName("block_test2");
        this.setCreativeTab(CreativeTabsLoader.FMLTUTOR);
    }

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

    @Override
    public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
        IExtendedBlockState restates = (IExtendedBlockState)state;
        return restates;
    }
    @Override
    public EnumBlockRenderType getRenderType(IBlockState state) {
        return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
    }
}

 

package lj.fmltutor.block;

import lj.fmltutor.FMLTutor;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.client.model.obj.OBJModel;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockLoader2 {
    private static Block block = new BlockOBJTest2();
    public static void init(){
        OBJLoader.INSTANCE.addDomain(FMLTutor.MODID);
        ForgeRegistries.BLOCKS.register(block);
        ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
    }
    @SideOnly(Side.CLIENT)
    public static void clientInit(){
        Item item = Item.getItemFromBlock(block);
        ModelLoader.setCustomModelResourceLocation(item,0,new ModelResourceLocation(block.getRegistryName(),"inventory"));
    }

}

 

thanks!

 

 

 

Posted
34 minutes ago, larsgerrits said:

Show every file related to the OBJ and model, and post the logs.

package lj.fmltutor.block;
import lj.fmltutor.creativetab.CreativeTabsFMLTutor;
import lj.fmltutor.creativetab.CreativeTabsLoader;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.property.IExtendedBlockState;


public class BlockOBJTest2 extends Block {
    protected BlockOBJTest2( ) {
        super(Material.ROCK);
        this.setUnlocalizedName("blockTest2");
        this.setRegistryName("block_test2");
        this.setCreativeTab(CreativeTabsLoader.FMLTUTOR);
    }

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

    @Override
    public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
        IExtendedBlockState restates = (IExtendedBlockState)state;
        return restates;
    }
    @Override
    public EnumBlockRenderType getRenderType(IBlockState state) {
        return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
    }
}

 

package lj.fmltutor.block;

import lj.fmltutor.FMLTutor;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.client.model.obj.OBJModel;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockLoader2 {
    private static Block block = new BlockOBJTest2();
    public static void init(){
        OBJLoader.INSTANCE.addDomain(FMLTutor.MODID);
        ForgeRegistries.BLOCKS.register(block);
        ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
    }
    @SideOnly(Side.CLIENT)
    public static void clientInit(){
        Item item = Item.getItemFromBlock(block);
        ModelLoader.setCustomModelResourceLocation(item,0,new ModelResourceLocation(block.getRegistryName(),"inventory"));
    }

}

 

thanks!

 

 

 

Posted

OBJ file

 

# Blender v2.79 (sub 0) OBJ File: ''
# www.blender.org
mtllib models/block/block_test2.mtl
o Cube
v 1.000000 0.000000 -2.500000
v 1.000000 0.000000 -0.500000
v -1.000000 0.000000 -0.500000
v -1.000000 0.000000 -2.500000
v 1.000000 2.000000 -2.500000
v 0.999999 2.000000 -0.499999
v -1.000000 2.000000 -0.500000
v -1.000000 2.000000 -2.500000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn -0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 1//1 2//1 3//1 4//1
f 5//2 8//2 7//2 6//2
f 1//3 5//3 6//3 2//3
f 2//4 6//4 7//4 3//4
f 3//5 7//5 8//5 4//5
f 5//6 1//6 4//6 8//6
Posted

mtl file

 

# Blender MTL File: 'None'
# Material Count: 1

newmtl Material
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

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.