Jump to content

Recommended Posts

Posted (edited)

Hello, i have a problem. If you arrange the blocks to the North or to the East after rejoining the game, everything is fine, but if placed on a South or West some of the blocks shifted. What could be the problem?

  Reveal hidden contents

BlockSide:

  Reveal hidden contents

 

2017-05-08_13.04.39.png

2017-05-08_13.05.12.png

Edited by WildHeart
Posted
 return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta))

This line won't work if meta > 4 (which BARREL and SPIGOT make it be)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 5/8/2017 at 12:31 PM, Draco18s said:
 return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta))

This line won't work if meta > 4 (which BARREL and SPIGOT make it be)

Expand  

Then I need not to take EnumFacing.getHorizontal, to do it my way?

Posted

No, what you need to do is extract the 2 bits of metadata.

EnumFacing.getHorizontal(meta&3)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
  On 5/8/2017 at 12:49 PM, Draco18s said:

Нет, то, что вам нужно сделать, это извлечь 2 бита метаданных.

EnumFacing.getHorizontal(Мета&3)
Expand  

Where you can read more about metadata for blocks?

Edited by WildHeart
Posted

Solved

@Override
    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta & 3)).withProperty(BARREL, Boolean.valueOf((meta & 8) > 0)).withProperty(SPIGOT, Boolean.valueOf((meta & 4) > 0));
    }

    @Override
    public int getMetaFromState(IBlockState state)
    {
        int i = 0;
        i = i | state.getValue(FACING).getHorizontalIndex();

        if(state.getValue(BARREL).booleanValue())
        {
            i |= 8;
        }

        if(state.getValue(SPIGOT).booleanValue())
        {
            i |= 4;
        }

        return i;
    }

 

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.