Jump to content

Easy way to put torches on new fences


werl

Recommended Posts

I'm adding new fences, sadly you cannot put torches on my new fences. So I did this.

 

This is in BlockTorch.java.

 

Original code:

private boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
    {
        if (par1World.isBlockSolidOnSide(par2, par3, par4, 1))
        {
            return true;
        }
        else
        {
            int var5 = par1World.getBlockId(par2, par3, par4);


            if (var5 != Block.fence.blockID && var5 != Block.netherFence.blockID && var5 != Block.glass.blockID)
            {
                if (Block.blocksList[var5] != null && Block.blocksList[var5] instanceof BlockStairs)
                {
                    int var6 = par1World.getBlockMetadata(par2, par3, par4);


                    if ((4 & var6) != 0)
                    {
                        return true;
                    }
                }
                
                return false;
            }
            else
            {
                return true;
            }
        }
    }

 

 

New code:

private boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
    {
        if (par1World.isBlockSolidOnSide(par2, par3, par4, 1))
        {
            return true;
        }
        else
        {
            int var5 = par1World.getBlockId(par2, par3, par4);


            if (var5 != Block.fence.blockID && var5 != Block.netherFence.blockID && var5 != Block.glass.blockID)
            {
                if (Block.blocksList[var5] != null && Block.blocksList[var5] instanceof BlockStairs)
                {
                    int var6 = par1World.getBlockMetadata(par2, par3, par4);


                    if ((4 & var6) != 0)
                    {
                        return true;
                    }
                }
                
                else if (Block.blocksList[var5] != null && Block.blocksList[var5] instanceof BlockTorch)
                {
                   return true;
                }
                
                return false;
            }
            else
            {
                return true;
            }
        }
    }

Both server and client are the same.

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.