Jump to content

Problem with Doors


DnDev

Recommended Posts

I’m trying to make a few new doors for v1.15.2 of the game. I’m having shape/collision problems with a bigger door, 2x2 blocks.

 

01.png.3ec58c693c2ecfad4fde3049f075b3db.png02.png.a5078bab47da627ec3fd6b6549321ffc.png03.png.d2b53b6e05767e817e0f6b64b21864c7.png04.png.9ce9be4aba2719bbfa01f517facdedc4.png05.png.c5e5c1093fa53a6f9473ab3f252f3086.png

 

As you can see in the pictures above, there’s a few problems.

The collision shape is wrong when facing certain directions. Not only that but the rotation is off. I tried using negative values in the getShape (and also in the JSON file) but it corrects one direction and messes up another.

When the door is broken there’s the missing model texture. My other doors don’t do that. I haven’t investigated this one yet.

Also it seems that the “extended” part of the door is ignored. Like the door is still 2x1 blocks.

 

The door class extends DoorBlock and overrides the getShape method.

protected static final VoxelShape SOUTH_AABB_X2 = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 32.0D, 16.0D, 3.0D);
protected static final VoxelShape NORTH_AABB_X2 = Block.makeCuboidShape(0.0D, 0.0D, 13.0D, 32.0D, 16.0D, 16.0D);
protected static final VoxelShape WEST_AABB_X2 = Block.makeCuboidShape(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 32.0D);
protected static final VoxelShape EAST_AABB_X2 = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 3.0D, 16.0D, 32.0D);

 

@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
    Direction direction = state.get(FACING);
    boolean flag = !state.get(OPEN);
    boolean flag1 = state.get(HINGE) == DoorHingeSide.RIGHT;
    switch (direction) {
        case EAST:
        default:
            return flag ? EAST_AABB_X2 : (flag1 ? NORTH_AABB_X2 : SOUTH_AABB_X2);
        case SOUTH:
            return flag ? SOUTH_AABB_X2 : (flag1 ? EAST_AABB_X2 : WEST_AABB_X2);
        case WEST:
            return flag ? WEST_AABB_X2 : (flag1 ? SOUTH_AABB_X2 : NORTH_AABB_X2);
        case NORTH:
            return flag ? NORTH_AABB_X2 : (flag1 ? WEST_AABB_X2 : EAST_AABB_X2);
    }
}

 

Bottom part JSON:

{
"ambientocclusion": false,
    "textures": {
        "big_spruce_door_full": "dn-moredoors:block/big_spruce_door_full"
    },
    "elements": [
        {
            "from": [ 0, 0, 0 ],
            "to": [ 3, 16, 32 ],
            "faces": {
                "down": { "texture": "#big_spruce_door_full",  "uv": [ 0, 10, 16, 12 ], "rotation": 90, "cullface": "down" },
                "north": { "texture": "#big_spruce_door_full", "uv": [ 5, 8, 6, 16 ], "cullface": "north" },
                "south": { "texture": "#big_spruce_door_full", "uv": [ 5, 8, 6, 16 ], "cullface": "south" },
                "west": { "texture": "#big_spruce_door_full",  "uv": [ 0, 8, 16, 16 ], "cullface": "west" },
                "east": { "texture": "#big_spruce_door_full",  "uv": [ 16, 8, 0, 16 ] }
            }
        }
    ]
}

 

Bottom part RH JSON:

{
"ambientocclusion": false,
    "textures": {
        "big_spruce_door_full": "dn-moredoors:block/big_spruce_door_full"
    },
    "elements": [
        {
            "from": [ 0, 0, 0 ],
            "to": [ 3, 16, 32 ],
            "faces": {
                "down": { "texture": "#big_spruce_door_full",  "uv": [ 0, 10, 16, 12 ], "rotation": 90, "cullface": "down" },
                "north": { "texture": "#big_spruce_door_full", "uv": [ 5, 8, 6, 16 ], "cullface": "north" },
                "south": { "texture": "#big_spruce_door_full", "uv": [ 5, 8, 6, 16 ], "cullface": "south" },
                "west": { "texture": "#big_spruce_door_full",  "uv": [ 16, 8, 0, 16 ], "cullface": "west" },
                "east": { "texture": "#big_spruce_door_full",  "uv": [ 0, 8, 16, 16 ] }
            }
        }
    ]
}

 

And the blockstate JSON:

{
  "variants": {
    "facing=east,half=lower,hinge=left,open=false":  { "model": "dn-moredoors:block/big_spruce_door_bottom" },
    "facing=south,half=lower,hinge=left,open=false": { "model": "dn-moredoors:block/big_spruce_door_bottom", "y": 90 },
    "facing=west,half=lower,hinge=left,open=false":  { "model": "dn-moredoors:block/big_spruce_door_bottom", "y": 180 },
    "facing=north,half=lower,hinge=left,open=false": { "model": "dn-moredoors:block/big_spruce_door_bottom", "y": 270 },
    "facing=east,half=lower,hinge=right,open=false":  { "model": "dn-moredoors:block/big_spruce_door_bottom_rh" },
    "facing=south,half=lower,hinge=right,open=false": { "model": "dn-moredoors:block/big_spruce_door_bottom_rh", "y": 90 },
    "facing=west,half=lower,hinge=right,open=false":  { "model": "dn-moredoors:block/big_spruce_door_bottom_rh", "y": 180 },
    "facing=north,half=lower,hinge=right,open=false": { "model": "dn-moredoors:block/big_spruce_door_bottom_rh", "y": 270 },
    "facing=east,half=lower,hinge=left,open=true":  { "model": "dn-moredoors:block/big_spruce_door_bottom_rh", "y": 90 },
    "facing=south,half=lower,hinge=left,open=true": { "model": "dn-moredoors:block/big_spruce_door_bottom_rh", "y": 180 },
    "facing=west,half=lower,hinge=left,open=true":  { "model": "dn-moredoors:block/big_spruce_door_bottom_rh", "y": 270 },
    "facing=north,half=lower,hinge=left,open=true": { "model": "dn-moredoors:block/big_spruce_door_bottom_rh" },
    "facing=east,half=lower,hinge=right,open=true":  { "model": "dn-moredoors:block/big_spruce_door_bottom", "y": 270 },
    "facing=south,half=lower,hinge=right,open=true": { "model": "dn-moredoors:block/big_spruce_door_bottom" },
    "facing=west,half=lower,hinge=right,open=true":  { "model": "dn-moredoors:block/big_spruce_door_bottom", "y": 90 },
    "facing=north,half=lower,hinge=right,open=true": { "model": "dn-moredoors:block/big_spruce_door_bottom", "y": 180 },
    "facing=east,half=upper,hinge=left,open=false":  { "model": "dn-moredoors:block/big_spruce_door_top" },
    "facing=south,half=upper,hinge=left,open=false": { "model": "dn-moredoors:block/big_spruce_door_top", "y": 90 },
    "facing=west,half=upper,hinge=left,open=false":  { "model": "dn-moredoors:block/big_spruce_door_top", "y": 180 },
    "facing=north,half=upper,hinge=left,open=false": { "model": "dn-moredoors:block/big_spruce_door_top", "y": 270 },
    "facing=east,half=upper,hinge=right,open=false":  { "model": "dn-moredoors:block/big_spruce_door_top_rh" },
    "facing=south,half=upper,hinge=right,open=false": { "model": "dn-moredoors:block/big_spruce_door_top_rh", "y": 90 },
    "facing=west,half=upper,hinge=right,open=false":  { "model": "dn-moredoors:block/big_spruce_door_top_rh", "y": 180 },
    "facing=north,half=upper,hinge=right,open=false": { "model": "dn-moredoors:block/big_spruce_door_top_rh", "y": 270 },
    "facing=east,half=upper,hinge=left,open=true":  { "model": "dn-moredoors:block/big_spruce_door_top_rh", "y": 90 },
    "facing=south,half=upper,hinge=left,open=true": { "model": "dn-moredoors:block/big_spruce_door_top_rh", "y": 180 },
    "facing=west,half=upper,hinge=left,open=true":  { "model": "dn-moredoors:block/big_spruce_door_top_rh", "y": 270 },
    "facing=north,half=upper,hinge=left,open=true": { "model": "dn-moredoors:block/big_spruce_door_top_rh" },
    "facing=east,half=upper,hinge=right,open=true":  { "model": "dn-moredoors:block/big_spruce_door_top", "y": 270 },
    "facing=south,half=upper,hinge=right,open=true": { "model": "dn-moredoors:block/big_spruce_door_top" },
    "facing=west,half=upper,hinge=right,open=true":  { "model": "dn-moredoors:block/big_spruce_door_top", "y": 90 },
    "facing=north,half=upper,hinge=right,open=true": { "model": "dn-moredoors:block/big_spruce_door_top", "y": 180 }
  }
}

 

Most of the JSONs are based on the vanilla Spruce Door. Assuming they are correct, there’s probably a method I need to override but have no clue which.

 

Any help would be appreciated :)

Link to comment
Share on other sites

You can't make blocks that extend outside the 1x1x1 volume.

 

No.

 

No. Stop trying. You can't.

The game doesn't support it, everything breaks.

 

If you absolutely must have this feature, then you must use extra blocks, like how the vanilla bed and door do.

Edited by Draco18s

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.

Link to comment
Share on other sites

7 hours ago, Draco18s said:

You can't make blocks that extend outside the 1x1x1 volume.

 

Ok, giving up on that idea.

 

 

7 hours ago, Draco18s said:

If you absolutely must have this feature, then you must use extra blocks, like how the vanilla bed and door do.

 

I've looked in to the code but I'm still a bit confused how does the vanilla do it. Is it in the onBlockPlacedBy ? This is going to be tricky.

This is my first mod so I'm still reading tutorials to get the feel of things. I also have planned a 3x3 blocks door. That one is going to be a headache ?

 

 

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.