Jump to content

Recommended Posts

Posted

I'm making a block (specifically a Stove) and I want it to face the direction that I'm standing. I think I have to use something related to ForgeDirection. FYI it is a TileEntity

 

The Block Code:

  Reveal hidden contents

 

 

The TileEntity Code:

  Reveal hidden contents

 

 

I'm new to modding so I'm probably a noob.

Thanks in advance!

Posted

Look at BlockDispenser. You'll learn more.

 

{Method to Activate} : in your block class.

public void onBlockAdded(World par1World, int par2, int par3, int par4) {
     super.onBlockAdded(par1World, par2, par3, par4);
     this.setDirectionOfBlock(par1World, par2, par3, par4);
}

 

setDirectionOfBlock

    private void setDirectionOfBlock(World par1World, int par2, int par3, int par4)
    {
        if (!par1World.isRemote)
        {
            int l = par1World.getBlockId(par2, par3, par4 - 1);
            int i1 = par1World.getBlockId(par2, par3, par4 + 1);
            int j1 = par1World.getBlockId(par2 - 1, par3, par4);
            int k1 = par1World.getBlockId(par2 + 1, par3, par4);
            byte b0 = 3;

            if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1])
            {
                b0 = 3;
            }

            if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l])
            {
                b0 = 2;
            }

            if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1])
            {
                b0 = 5;
            }

            if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1])
            {
                b0 = 4;
            }

            par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);
        }
    }

Now all you got to do is register the textures on each side of the block corresponding to BlockMetadata.

 

Maybe next time you can look at HOW some vanilla blocks do that first, before asking :P

Posted
  On 1/29/2014 at 10:18 PM, MajhenriquBoss said:

I'm making a block (specifically a Stove) and I want it to face the direction that I'm standing. I think I have to use something related to ForgeDirection. FYI it is a TileEntity

 

The Block Code:

  Reveal hidden contents

 

 

The TileEntity Code:

  Reveal hidden contents

 

 

I'm new to modding so I'm probably a noob.

Thanks in advance!

 

I'm using that code. Put it in BlockName.class file.

 

  Reveal hidden contents

 

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.