Jump to content

[1.12.2] Block rotating on place


XpresS

Recommended Posts

Hello guys, I had a little problem, I spend too much hours looking for the best solution. But i didnt find it. Can somebody explain me. I wants something like this:
When i placed the block and block should be rotating where I looking.

I had some code and the blocks rotating only to two sides. 
lC58HO5.pngCode:

https://pastebin.com/E5erjEYe

Thanks for all  helps. :)

(sorry for my bad english)

Link to comment
Share on other sites

Quote

 extends BlockBase

BlockBase is an antipattern. You don't need it.

 

Quote

 public void onBlockPlacedBy

Don't set the blockstate in Block#onBlockPlaced or Block#onBlockPlacedBy. Just return the state you want in Block#getStateForPlacement.

 

if(entityFacing == EnumFacing.NORTH) {
                entityFacing = EnumFacing.NORTH;
            } else if(entityFacing == EnumFacing.EAST) {
                entityFacing = EnumFacing.EAST;
            } else if(entityFacing == EnumFacing.SOUTH) {
                entityFacing = EnumFacing.SOUTH;
            } else if(entityFacing == EnumFacing.WEST) {
                entityFacing = EnumFacing.WEST;
            }

if x is x then set the x to x? Why? This is equivalent to writing

if (x == 1) x = 1;

It does nothing.

 

As for the rotation - this looks correct to me. See BlockFurnace#getStateForPlacement - it does a very similar thing. So I suspect the issue may be somewhere else. Could your please show your blockstate file?

Link to comment
Share on other sites

That is not how forge's blockstate format works. You are trying to merge vanilla's blockstate format with forge's. Choose one.

 

7 minutes ago, XpresS said:

I had 4 models for this but when I wants 1 it will be perfect.

What do you need 4 models for? Just have one and rotate it around the Y axis. In fact you are already rotating them. This might be the cause of your issue.

Link to comment
Share on other sites

Thank you very much.

24 minutes ago, V0idWa1k3r said:

Don't set the blockstate in Block#onBlockPlaced or Block#onBlockPlacedBy. Just return the state you want in Block#getStateForPlacement.

 

    @Override
    public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
			float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
        return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand).withProperty(FACING, placer.getHorizontalFacing());
        
    }

Maybe this will be then before.

When somebody will have same problem as me the solution for this is on following lines:

{
    "forge_marker": 1,
    "defaults": { "model": "prisonthings:red_chair1" },
    "variants": {
        "facing=north": {
            "y": 0
        },
        "facing=east": {
            "y": 90
        },
        "facing=south": {
            "y": 180
        },
        "facing=west": {
            "y": 270
        },

        "inventory": {
            "model": "prisonthings:red_chair1",
            "transform": "forge:default-block"
        }
    }
}

 

Edited by XpresS
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.

Announcements



×
×
  • Create New...

Important Information

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