Jump to content

[Solved] [1.15.2] Cannot set property DirectionProperty as it does not exist in Block{null}


Recommended Posts

Posted (edited)

Hello,
I followed Cadiboo tutorial that uses Forge Docs, and I'm trying to create an interactible block, but I can't find why I get this property error.

I understand that it comes from the blockState of my InterfaceBlock (extending HorizontalBlock), but I don't know if it comes from the registry method I used or another circumstance.


My github is https://github.com/Elsopeen/LyokoMod-1.15, and I added the stacktrace with the error (which indicated me that it came from my InterfaceBlock).

I hope you can find the problem, and I thank you in advance

stacktrace.log

Edited by Elsopeen
Posted (edited)

Just guessing, you might need to override

fillStateContainer

and pass that property into the builder

 

yeah I think you will need to do this

Edited by poopoodice
  • Like 1
Posted

Well, I added this override but I still have the error. So here's what I added, maybe it's not right :

@Override
    protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
        super.fillStateContainer(builder.add(DirectionProperty.create("interface_direction", Direction.Plane.HORIZONTAL)));
    }

 

Posted (edited)
1 minute ago, Elsopeen said:

Well, I added this override but I still have the error. So here's what I added, maybe it's not right :


@Override
    protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
        super.fillStateContainer(builder.add(DirectionProperty.create("interface_direction", Direction.Plane.HORIZONTAL)));
    }

 

There's no reason calling super, just use the property you already have which is

builder.add(HORIZONTAL_FACING);

 

Edited by poopoodice
Posted (edited)

Thanks ! The problem is fixed ! But now the block doesn't seem to be able to rotate (or be placed in another direction...)

 

Edit: the setblock command can rotate it !

Edited by Elsopeen
Setblock test
Posted (edited)

you will need to override some methods such as getStateForPlacement() which provides a blockstate for the blockitem to determine what states does the block have when added, normally something like

return getDefaultState()
                .with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing());

The rotate method you override is probably for structure generation or so.. not so sure.

Edited by poopoodice

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.