Jump to content

[1.7.10] How to have the front texture of a block face player when placed


Recommended Posts

Posted

Hello, I was wondering how do I get the front texture of a multi-textured block to face the player when the block is placed, similar to when a furnace is placed. Any help would be awesome.

Posted

The chest uses ForgeDirection some how, but I have no idea how (I've never done anything like this). Try to look at the vanilla code.

Posted

@RYxINATORx314 I'll try that, but where do I find the furnace or oak tree classes? Sorry for asking, I haven't made a mod since 1.4.6 or 1.4.7..  :-\ Nvm, I got it..

 

@Awesome_Spider Thanks, I'll play around with ForgeDirection and see if I can get something working(or broken)

Posted

Hi

 

For clues look at BlockFurnace.onBlockPlacedBy.  It uses metadata to specify the four directions the furnace can face.

For more background information, see the Block topics on this link:

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

 

  public void onBlockPlacedBy(World world, int wx, int wy, int wz, EntityLivingBase entityLivingBase, ItemStack itemStack)
  {
    int l = MathHelper.floor_double((double) (entityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; // which compass point is the player facing?

    if (l == 0)
    {
      world.setBlockMetadataWithNotify(wx, wy, wz, 2, 2);
    }

    if (l == 1)
    {
      world.setBlockMetadataWithNotify(wx, wy, wz, 5, 2);
    }

    if (l == 2)
    {
      world.setBlockMetadataWithNotify(wx, wy, wz, 3, 2);
    }

    if (l == 3)
    {
      world.setBlockMetadataWithNotify(wx, wy, wz, 4, 2);
    }

    if (itemStack.hasDisplayName())
    {
      ((TileEntityFurnace)world.getTileEntity(wx, wy, wz)).func_145951_a(itemStack.getDisplayName());
    }
  }

 

-TGG

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.