Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Villagers don't recognize special type of door as a door.


Recommended Posts

Hello, I have tried to update the code to my door. The door is a special type of door where instead of hanging on the edge of a block, it goes through the center. For some reason however, the villagers do not recognize it as a door, and therefore never use it. How can I add to my code to make them use it?

 

package com.kenmod.objects.blocks.doors;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.Property;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.DoorHingeSide;
import net.minecraft.state.properties.DoubleBlockHalf;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;

public class CenteredDoor extends DoorBlock {
	
	public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
	public static final BooleanProperty OPEN = BlockStateProperties.OPEN;
	public static final EnumProperty<DoorHingeSide> HINGE = BlockStateProperties.DOOR_HINGE;
	public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
	public static final EnumProperty<DoubleBlockHalf> HALF = BlockStateProperties.DOUBLE_BLOCK_HALF;
	
	protected static final VoxelShape default_shape = Block.makeCuboidShape(0.0D, 0.0D, 7.0D, 16.0D, 16.0D, 9.0D);
	protected static final VoxelShape north_south = Block.makeCuboidShape(0.0D, 0.0D, 7.0D, 16.0D, 16.0D, 9.0D);
	protected static final VoxelShape east_west = Block.makeCuboidShape(7.0D, 0.0D, 0.0D, 9.0D, 16.0D, 16.0D);
	protected static final VoxelShape south_l = Block.makeCuboidShape(13.0D, 0.0D, 7.0D, 16.0D, 16.0D, 21.0D);
	protected static final VoxelShape south_r = Block.makeCuboidShape(0.0D, 0.0D, 7.0D, 3.0D, 16.0D, 21.0D);
	protected static final VoxelShape north_l = Block.makeCuboidShape(0.0D, 0.0D, 9.0D, 3.0D, 16.0D, -5.0D);
	protected static final VoxelShape north_r = Block.makeCuboidShape(13.0D, 0.0D, 9.0D, 16.0D, 16.0D, -5.0D);
	protected static final VoxelShape east_l = Block.makeCuboidShape(7.0D, 0.0D, 0.0D, 21.0D, 16.0D, 3.0D);
	protected static final VoxelShape east_r = Block.makeCuboidShape(7.0D, 0.0D, 13.0D, 21.0D, 16.0D, 16.0D);
	protected static final VoxelShape west_l = Block.makeCuboidShape(9.0D, 0.0D, 13.0D, -5.0D, 16.0D, 16.0D);
	protected static final VoxelShape west_r = Block.makeCuboidShape(9.0D, 0.0D, 0.0D, -5.0D, 16.0D, 3.0D);
	
	public CenteredDoor (Properties properties) {
		super(properties);
	}
	@Override
	public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
		Direction dir = (Direction)state.get((Property<?>)FACING);
	    DoorHingeSide side = (DoorHingeSide)state.get((Property<DoorHingeSide>)HINGE);
	    Boolean open = (Boolean)state.get((Property<?>)OPEN);
	    if ((dir == Direction.NORTH || dir == Direction.SOUTH) && !open.booleanValue()) {
	    	return north_south; 
	    }
	    if ((dir == Direction.EAST || dir == Direction.WEST) && !open.booleanValue()) {
	    	return east_west; 
	    }
	    if (dir == Direction.NORTH && side == DoorHingeSide.LEFT) {
	    	return north_l; 
	    }
	    if (dir == Direction.NORTH && side == DoorHingeSide.RIGHT) {
	    	return north_r; 
	    }
	    if (dir == Direction.SOUTH && side == DoorHingeSide.LEFT) {
	    	return south_l; 
	    }
	    if (dir == Direction.SOUTH && side == DoorHingeSide.RIGHT) {
	    	return south_r; 
	    }
	    if (dir == Direction.EAST && side == DoorHingeSide.LEFT) {
	    	return east_l; 
	    }
	    if (dir == Direction.EAST && side == DoorHingeSide.RIGHT) {
	    	return east_r; 
	    }
	    if (dir == Direction.WEST && side == DoorHingeSide.LEFT) {
	    	return west_l; 
	    }
	    if (dir == Direction.WEST && side == DoorHingeSide.RIGHT) {
	    	return west_r; 
	    }
	    return default_shape;
	}
	
	@Override
	protected void fillStateContainer(Builder<Block, BlockState> builder) {
		builder.add(new Property[] {
			HALF,
			FACING,
			OPEN,
			HINGE,
			POWERED
		});
	}
}

 

Link to post
Share on other sites

Ok I did this:

{
    "replace": false,
    "values": [
        "minecraft:oak_door",
        "minecraft:spruce_door",
        "minecraft:birch_door",
        "minecraft:jungle_door",
        "minecraft:acacia_door",
        "minecraft:dark_oak_door",
        "minecraft:crimson_door",
        "minecraft:warped_door",
        "kenmod:oak_cabin_door"
    ]
}

{
	"replace": false,
	"values": [
		"minecraft:oak_door",
		"minecraft:spruce_door",
		"minecraft:birch_door",
		"minecraft:jungle_door",
		"minecraft:acacia_door",
		"minecraft:dark_oak_door",
		"minecraft:crimson_door",
		"minecraft:warped_door",
		"kenmod:oak_cabin_door"
	]
}

But they still don't open the door.

Link to post
Share on other sites
19 hours ago, ken2020 said:

Ok I did this:

{
    "replace": false,
    "values": [
        "minecraft:oak_door",
        "minecraft:spruce_door",
        "minecraft:birch_door",
        "minecraft:jungle_door",
        "minecraft:acacia_door",
        "minecraft:dark_oak_door",
        "minecraft:crimson_door",
        "minecraft:warped_door",
        "kenmod:oak_cabin_door"
    ]
}


{
	"replace": false,
	"values": [
		"minecraft:oak_door",
		"minecraft:spruce_door",
		"minecraft:birch_door",
		"minecraft:jungle_door",
		"minecraft:acacia_door",
		"minecraft:dark_oak_door",
		"minecraft:crimson_door",
		"minecraft:warped_door",
		"kenmod:oak_cabin_door"
	]
}

But they still don't open the door.

Where did you put this?

How to ask a good coding question: https://stackoverflow.com/help/how-to-ask

Give any applicable of: logs, code, desired effects, and actual effects. Be thorough or we can't help you, and don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy.

 

My own mod, Magiks Most Evile! GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki)

Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/

Link to post
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.

Guest
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 Privacy Policy.