Jump to content

[1.8.9] OBJ Model Block Not working?


NecroTheif

Recommended Posts

I am trying to use the OBJLoader to load and obj model in one of my blocks but for some reason it only works for the item itself and not the block? If I change the ModelResourceLocation from inventory to normal neither works? I tried to look at the mbe05 example but nothing seems to be wrong: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe05_block_smartblockmodel2

 

My ModelBakeEvent:

        @SubscribeEvent
public void ModelBakeEvent(ModelBakeEvent event){
	try {
    	Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
    		  public TextureAtlasSprite apply(ResourceLocation resourceLocation) {
    		        return Minecraft.getMinecraft().getTextureMapBlocks().registerSprite(resourceLocation);
    			  }
    			};
    	OBJModel model = (OBJModel) OBJLoader.instance.loadModel(new ResourceLocation(RefValues.MOD_ID+":models/obj/Gemstone.obj"));
    	IBakedModel baked = model.bake(model.getDefaultState(), Attributes.DEFAULT_BAKED_FORMAT, textureGetter);
		event.modelRegistry.putObject(new ModelResourceLocation(RefValues.MOD_ID+":"+RefValues.RUBY+RefValues.GEMSTONE, "inventory"), baked);
	} catch (IOException e) {
		e.printStackTrace();
	}
}

Link to comment
Share on other sites

I tried adding my own custom state mapper but it doesn't seem to do anything?

 

        @SubscribeEvent
public void ModelBakeEvent(ModelBakeEvent event){

	StateMapperBase ignoreState = new StateMapperBase() {
	      @Override
	      protected ModelResourceLocation getModelResourceLocation(IBlockState iBlockState) {
	        return new ModelResourceLocation(RefValues.MOD_ID+":"+RefValues.RUBY+RefValues.GEMSTONE);
	      }
	    };
    ModelLoader.setCustomStateMapper(Gemstone.getGemstone(RefValues.RUBY), ignoreState);

	try {
    	Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {
    		  public TextureAtlasSprite apply(ResourceLocation resourceLocation) {
    		        return Minecraft.getMinecraft().getTextureMapBlocks().registerSprite(resourceLocation);
    			  }
    			};
    	OBJModel model = (OBJModel) OBJLoader.instance.loadModel(new ResourceLocation(RefValues.MOD_ID+":models/obj/Gemstone.obj"));
    	IBakedModel baked = model.bake(model.getDefaultState(), Attributes.DEFAULT_BAKED_FORMAT, textureGetter);
		event.modelRegistry.putObject(new ModelResourceLocation(RefValues.MOD_ID+":"+RefValues.RUBY+RefValues.GEMSTONE, "inventory"), baked);
	} catch (IOException e) {
		e.printStackTrace();
	}
}

Link to comment
Share on other sites

That still didn't seem to work... So I was looking over the mbe05 example again and it turns out I don't even need the ModelBakeEvent since I'm using a custom ModelLoader but it doesn't seem to work.

 

blockstate json

{
    "variants": {
        "normal": { "model": "cwm:Gemstone.obj"  }
    }
}

 

Setting StateMap on Load

OBJLoader.instance.addDomain(RefValues.MOD_ID);
StateMapperBase objState = new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState iBlockState) {
        return new ModelResourceLocation(RefValues.MOD_ID+":"+RefValues.RUBY+RefValues.GEMSTONE);
}
};
ModelLoader.setCustomStateMapper(Gemstone.getGemstone(RefValues.RUBY), objState);

 

Setting Item Renderer

Item item = Item.getItemFromBlock(Gemstone.getGemstone(RefValues.RUBY));
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0,
new ModelResourceLocation(RefValues.MOD_ID+":"+RefValues.RUBY+RefValues.GEMSTONE));

 

Relevant console output

[12:29:53] [Client thread/ERROR] [FML]: Model definition for location cwm:rubyGemstone#facing=north not found
[12:29:53] [Client thread/ERROR] [FML]: Model definition for location cwm:rubyGemstone#facing=east not found
[12:29:53] [Client thread/ERROR] [FML]: Model definition for location cwm:rubyGemstone#facing=south not found
[12:29:44] [Client thread/ERROR] [FML]: Model definition for location cwm:rubyGemstone#facing=down not found
[12:29:44] [Client thread/ERROR] [FML]: Model definition for location cwm:rubyGemstone#facing=west not found
[12:29:44] [Client thread/ERROR] [FML]: Model definition for location cwm:rubyGemstone#facing=north not found

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.