Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey,

 

I'm working on some hedges and would like to use the PathNodeType, to set the PathNodeType of my hedge to fences. But it doesn't seem to work. So I was wondering if it is fully implemented, and working?My hedge class is extending block, so unless the PathNodeType method is in another class, that souldn't be the problem, but maybe I'm using the wrong method to add PathNodeType?

 

Is it still like this, as it is in the github? 

@Nullable
@Override
public PathNodeType getAiPathNodeType(IBlockState state, IBlockAccess world, BlockPos pos)
{
	return PathNodeType.FENCE;
}

 

Any help would be great, not sure how many have any information about this, as it's a relative new 'feature' added to forge.

Edited by Erfurt

  • Author
6 minutes ago, diesieben07 said:

It should work. Define "doesn't seem to work".

Well mobs like Zombies and villagers, try to 'jump' over my hedge, which they shouldn't if the PathNodeType was actually set to FENCE. So that why it doesn't seem to work.

  • Author
43 minutes ago, diesieben07 said:

Hm. Is the method called at all?

Not as far as I can tell

  • Author
47 minutes ago, diesieben07 said:

Hm. Is the method called at all?

You properly want to see my class, so here it is

Spoiler

public class Hedge extends Block
{
	public static final PropertyBool NORTH = PropertyBool.create("north");
	public static final PropertyBool EAST = PropertyBool.create("east");
	public static final PropertyBool SOUTH = PropertyBool.create("south");
	public static final PropertyBool WEST = PropertyBool.create("west");
	
	protected static final AxisAlignedBB[] BOUNDING_BOX = new AxisAlignedBB[] { new AxisAlignedBB(0.1875, 0.0, 0.1875, 0.8125, 1.0, 0.8125), new AxisAlignedBB(0.1875, 0.0, 0.1875, 0.8125, 1.0, 1.0), new AxisAlignedBB(0.0, 0.0, 0.1875, 0.8125, 1.0, 0.8125), new AxisAlignedBB(0.0, 0.0, 0.1875, 0.8125, 1.0, 1.0), new AxisAlignedBB(0.1875, 0.0, 0.0, 0.8125, 1.0, 0.8125), new AxisAlignedBB(0.1875, 0.0, 0.0, 0.8125, 1.0, 1.0), new AxisAlignedBB(0.0, 0.0, 0.0, 0.8125, 1.0, 0.8125), new AxisAlignedBB(0.0, 0.0, 0.0, 0.8125, 1.0, 1.0), new AxisAlignedBB(0.1875, 0.0, 0.1875, 1.0, 1.0, 0.8125), new AxisAlignedBB(0.1875, 0.0, 0.1875, 1.0, 1.0, 1.0), new AxisAlignedBB(0.0, 0.0, 0.1875, 1.0, 1.0, 0.8125), new AxisAlignedBB(0.0, 0.0, 0.1875, 1.0, 1.0, 1.0), new AxisAlignedBB(0.1875, 0.0, 0.0, 1.0, 1.0, 0.8125), new AxisAlignedBB(0.1875, 0.0, 0.0, 1.0, 1.0, 1.0), new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 0.8125), new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0) };
    protected static final AxisAlignedBB[] CLIP_BOUNDING_BOX = new AxisAlignedBB[] {BOUNDING_BOX[0].setMaxY(1.5D), BOUNDING_BOX[1].setMaxY(1.5D), BOUNDING_BOX[2].setMaxY(1.5D), BOUNDING_BOX[3].setMaxY(1.5D), BOUNDING_BOX[4].setMaxY(1.5D), BOUNDING_BOX[5].setMaxY(1.5D), BOUNDING_BOX[6].setMaxY(1.5D), BOUNDING_BOX[7].setMaxY(1.5D), BOUNDING_BOX[8].setMaxY(1.5D), BOUNDING_BOX[9].setMaxY(1.5D), BOUNDING_BOX[10].setMaxY(1.5D), BOUNDING_BOX[11].setMaxY(1.5D), BOUNDING_BOX[12].setMaxY(1.5D), BOUNDING_BOX[13].setMaxY(1.5D), BOUNDING_BOX[14].setMaxY(1.5D), BOUNDING_BOX[15].setMaxY(1.5D)};
    
	private static final AxisAlignedBB COLLISION_BOX_CENTER = new AxisAlignedBB(0.1875, 0.0, 0.1875, 0.8125, 1.5, 0.8125);
	private static final AxisAlignedBB COLLISION_BOX_NORTH = CollisionHelper.getBlockBounds(EnumFacing.NORTH, 0.8125, 0.0, 0.1875, 1.0, 1.5, 0.8125);
	private static final AxisAlignedBB COLLISION_BOX_EAST = CollisionHelper.getBlockBounds(EnumFacing.EAST, 0.8125, 0.0, 0.1875, 1.0, 1.5, 0.8125);
	private static final AxisAlignedBB COLLISION_BOX_SOUTH = CollisionHelper.getBlockBounds(EnumFacing.SOUTH, 0.8125, 0.0, 0.1875, 1.0, 1.5, 0.8125);
	private static final AxisAlignedBB COLLISION_BOX_WEST = CollisionHelper.getBlockBounds(EnumFacing.WEST, 0.8125, 0.0, 0.1875, 1.0, 1.5, 0.8125);

	public Hedge(String name)
	{
		super(Material.LEAVES);
		setUnlocalizedName(name);
		setRegistryName(name);
		setSoundType(SoundType.PLANT);
		setHardness(1.0F);
		setDefaultState(blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
		Blocks.FIRE.setFireInfo(this, 30, 60);
		setCreativeTab(CreativeTabs.DECORATIONS);
		
	}
	
	@Nullable
	public PathNodeType getAiPathNodeType(IBlockState state, IBlockAccess world, BlockPos pos)
	{
		System.out.println("PathNodeType have been set to FENCE");
		return PathNodeType.FENCE;
	}
	
	@Override
	public boolean isOpaqueCube(IBlockState state)
    {
		return false;
    }

	@Override
	public boolean isNormalCube(IBlockState state)
	{
		return false;
	}

	@Override
	public boolean isFullCube(IBlockState state)
	{
		return false;
	}
	
	public BlockRenderLayer getBlockLayer()
	{
		return Blocks.LEAVES.getBlockLayer();
	}
    
	@Override
	public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) 
	{
		state = getActualState(state, source, pos);
		return BOUNDING_BOX[getBoundingBoxId(state)];
	}
	
	@Nullable
    public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
    {
        blockState = getActualState(blockState, worldIn, pos);
        return CLIP_BOUNDING_BOX[getBoundingBoxId(blockState)];
    }
	
	private static int getBoundingBoxId(IBlockState state)
    {
        int i = 0;

        if (((Boolean)state.getValue(NORTH)).booleanValue())
        {
            i |= 1 << EnumFacing.NORTH.getHorizontalIndex();
        }

        if (((Boolean)state.getValue(EAST)).booleanValue())
        {
            i |= 1 << EnumFacing.EAST.getHorizontalIndex();
        }

        if (((Boolean)state.getValue(SOUTH)).booleanValue())
        {
            i |= 1 << EnumFacing.SOUTH.getHorizontalIndex();
        }

        if (((Boolean)state.getValue(WEST)).booleanValue())
        {
            i |= 1 << EnumFacing.WEST.getHorizontalIndex();
        }

        return i;
    }
	
	@Override
	public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB axisAligned, List<AxisAlignedBB> axisAlignedList, Entity collidingEntity) 
	{
		if (state.getValue(NORTH))
        {
            super.addCollisionBoxToList(pos, axisAligned, axisAlignedList, COLLISION_BOX_NORTH);
        }

        if (state.getValue(EAST))
        {
        	super.addCollisionBoxToList(pos, axisAligned, axisAlignedList, COLLISION_BOX_EAST);
        }

        if (state.getValue(SOUTH))
        {
        	super.addCollisionBoxToList(pos, axisAligned, axisAlignedList, COLLISION_BOX_SOUTH);
        }

        if (state.getValue(WEST))
        {
        	super.addCollisionBoxToList(pos, axisAligned, axisAlignedList, COLLISION_BOX_WEST);
        }
        
        super.addCollisionBoxToList(pos, axisAligned, axisAlignedList, COLLISION_BOX_CENTER);
	}

	@Override
	public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
	{
		return state.withProperty(NORTH, Boolean.valueOf(isHedge(world, pos.north()))).withProperty(EAST, Boolean.valueOf(isHedge(world, pos.east()))).withProperty(SOUTH, Boolean.valueOf(isHedge(world, pos.south()))).withProperty(WEST, Boolean.valueOf(isHedge(world, pos.west())));
	}

	@Override
	public int getMetaFromState(IBlockState state)
	{
		return 0;
	}
	
	@Override
	protected BlockStateContainer createBlockState()
	{
		return new BlockStateContainer(this, new IProperty[] { NORTH, EAST, SOUTH, WEST });
	}

	public boolean isHedge(IBlockAccess world, BlockPos pos)
	{
		return world.getBlockState(pos).getBlock() instanceof Hedge || world.getBlockState(pos).getBlock() instanceof BlockFenceGate || world.getBlockState(pos).getBlock().isNormalCube(world.getBlockState(pos));
	}
}

 

 

  • Author
7 minutes ago, diesieben07 said:

Hm. Put the breakpoint a bit further up (EntityMoveHelper::onUpdateMoveHelper) and see what is happening.

Nothing seems to be happening. Do I need t o implement something or is there something wrong with the method I use?

  • Author
Just now, diesieben07 said:

onUpdateMoveHelper is not called?

It is, but it seems that it's just looping, but not doing anything. Maybe I'm doing something wrong

  • Author
11 minutes ago, diesieben07 said:

That doesn't sound right.

I agree, most likely me who doesn't understand that code. But for the method I'm using, I can't seem to find it anywhere, other than on the github page. I see nothing in ref files, which I find a bit weird if it's completely implemented, but maybe I'm looking in the wrong places? Also I'm on the 13.20.0.2282 build, maybe it's not in that one?

  • Author
8 hours ago, diesieben07 said:

That doesn't sound right.

I'm an idiot... It would seem that when I updated my mod, I somehow fucked up. So that I was still working in the old 1.10.2 version, which makes so much more sense. Sorry for wasting your time, thanks for your help though

As a note for the future, using the @Override annotation on all the methods you override from Block will help prevent issues like this - it'd cause a compile time error, as the getAiPathNodeType method doesn't exist in the Block class in 1.10.

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.