Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [Fixed] [1.8] Setting the Item model for an ItemBlock
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Glorfindel22

[Fixed] [1.8] Setting the Item model for an ItemBlock

By Glorfindel22, March 6, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Glorfindel22    1

Glorfindel22

Glorfindel22    1

  • Tree Puncher
  • Glorfindel22
  • Members
  • 1
  • 43 posts
Posted March 6, 2017 (edited)

I am working on updating my mod to 1.8 and I am trying to switch to using ItemBlocks as it looks like it will be required to update to 1.9. I managed to get it mostly working, but I am still confused about a few things and can't find much information online.

 

So here is what I have:

 

The ItemBlock

public class ItemBlockMortarAndPestle extends ItemBlock {

	public ItemBlockMortarAndPestle(Block block) {
		super(block);
		this.maxStackSize = 1;
		this.setUnlocalizedName("mortarAndPestle");
		this.setCreativeTab(CoffeeAndTeaMod.teaTab);
	}

}

 

The Block

public class BlockMortarAndPestle extends Block {

	public static final IProperty<EnumFacing> DIRECTION = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); 
	
	public BlockMortarAndPestle() {
		super(Material.rock);
		this.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.495F, 0.8F);
		this.setCreativeTab(CoffeeAndTeaMod.teaTab);
		this.setDefaultState(blockState.getBaseState().withProperty(DIRECTION, EnumFacing.NORTH));
		this.setHardness(5.0F);
		this.setHarvestLevel("pickaxe", 1);
	}

	@Override
	public boolean isOpaqueCube() {
		return false;
	}
	
	@Override
	public EnumWorldBlockLayer getBlockLayer() {
		return EnumWorldBlockLayer.CUTOUT;
	}
	
	@Override
	public BlockState createBlockState() {
		return new BlockState(this, DIRECTION);
	}
	
	@Override
	public int getMetaFromState(IBlockState state)
    {
		return ((EnumFacing)state.getValue(DIRECTION)).getIndex();
    }

	@Override
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);

        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
        {
            enumfacing = EnumFacing.NORTH;
        }

        return this.getDefaultState().withProperty(DIRECTION, enumfacing);
    }
	
	@Override
	/**
	 * Called when a player places the block and is what is used to set direction
	 */
    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return this.getDefaultState().withProperty(DIRECTION, placer.getHorizontalFacing().getOpposite());
    }
}

 

Then I register it like this:

mortarAndPestle = new BlockMortarAndPestle().setUnlocalizedName("mortarAndPestle");
GameRegistry.registerBlock(mortarAndPestle, ItemBlockMortarAndPestle.class, "mortarAndPestle");

 

So the block itself works perfectly fine and the model shows up when I place it however, there is no item model. It is just a the missing texture image. Which doesn't make sense to me because I have a file named mortarAndPestle.json in assets/teamod/models/item:

{
    "parent": "builtin/generated",
    "textures": {
        "layer0": "teamod:items/mortarAndPestle"
    },
    "display": {
        "thirdperson": {
            "rotation": [ -90, 0, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 1.7, 1.7, 1.7 ]
        }
    }
}

 

So my question is: how do I set an item model for an ItemBlock? Is it any different than normal?

Edited March 7, 2017 by Glorfindel22
Issue was fixed
  • Quote

Creator of the Recipe Expansion Pack mod.

http://www.minecraftforum.net/topic/1983421-172-forge-recipe-expansion-pack-version-012/

Updated to 1.7.2!

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5100 posts
Posted March 7, 2017

You need to set the item's model using ModelLoader.setCustomModelResourceLocation or ModelLoader.setCustomMeshDefinition. Call these in preInit (or ModelRegistryEvent in 1.10.2+) from a client-only class.

 

1.8 isn't really supported by Forge any more, you should update directly to 1.11.2 or at least to 1.8.9.

  • Like 1
  • Quote

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Share this post


Link to post
Share on other sites

Glorfindel22    1

Glorfindel22

Glorfindel22    1

  • Tree Puncher
  • Glorfindel22
  • Members
  • 1
  • 43 posts
Posted March 7, 2017 (edited)

Thanks that fixed my issue. I am updating to 1.8.9 by the way, sorry I wasn't more clear about that.

Edited March 7, 2017 by Glorfindel22
  • Quote

Creator of the Recipe Expansion Pack mod.

http://www.minecraftforum.net/topic/1983421-172-forge-recipe-expansion-pack-version-012/

Updated to 1.7.2!

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • cadbane86140
      Minecraft: Cereal UHC Season 2 Episode 5- THE FINALE!

      By cadbane86140 · Posted 15 minutes ago

      Hello There! A bit of a late upload due to technical issues but ITS UP! So after a week of Cereal UHC we have finally reached the end of it! I am so thankful to be apart of this series and I can't wait for the next season! There are so many hilarious moments especially during the final battle! I hope you all enjoyed this series and if you did don't forget to like and sub for more!  
    • samjviana
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana · Posted 33 minutes ago

      But how can i do that for an enchantment book, for normal items i was able to do that by calling the function "group" as you said, but with the enchantment seems to be different.
    • poopoodice
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By poopoodice · Posted 1 hour ago

      Just create an instance of ItemGroup, and set the group of the item in the item property builder.
    • poopoodice
      Trying to make a crop have an "X" shape model

      By poopoodice · Posted 1 hour ago

      Check the parent of their block model.
    • LexManos
      Forge says this file does not have an app associated with it.

      By LexManos · Posted 1 hour ago

      Some zip managers like to take control of the .jar file extension away from Java. Make sure you have Java installed and try running Jarfix once, then try the installer again.
  • Topics

    • cadbane86140
      0
      Minecraft: Cereal UHC Season 2 Episode 5- THE FINALE!

      By cadbane86140
      Started 15 minutes ago

    • samjviana
      2
      [1.16.5] How to make EnchantedBook go to Custom ItemGroup

      By samjviana
      Started 3 hours ago

    • TheMajorN
      1
      Trying to make a crop have an "X" shape model

      By TheMajorN
      Started 2 hours ago

    • ESCCarp
      3
      Forge says this file does not have an app associated with it.

      By ESCCarp
      Started 5 hours ago

    • hammy3502
      0
      [1.16.4] Fluid Flowing Very Oddly

      By hammy3502
      Started 2 hours ago

  • Who's Online (See full list)

    • Gorp5
    • LiliToBreazy
    • Caseofgames
    • digital_trucker
    • Pickle_Face5
    • cadbane86140
    • Kaeso
    • DerangedPenguins
    • LSMGaming
    • PyRoTheLifeLess
    • PtownCoderSchool
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [Fixed] [1.8] Setting the Item model for an ItemBlock
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community