Erfurt Posted April 21, 2017 Posted April 21, 2017 (edited) 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? https://github.com/MinecraftForge/MinecraftForge/pull/3546 @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 April 22, 2017 by Erfurt Quote
Erfurt Posted April 21, 2017 Author Posted April 21, 2017 On 4/21/2017 at 4:59 PM, diesieben07 said: It should work. Define "doesn't seem to work". Expand 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. Quote
Erfurt Posted April 21, 2017 Author Posted April 21, 2017 On 4/21/2017 at 5:26 PM, diesieben07 said: Hm. Is the method called at all? Expand Not as far as I can tell Quote
Erfurt Posted April 21, 2017 Author Posted April 21, 2017 On 4/21/2017 at 5:26 PM, diesieben07 said: Hm. Is the method called at all? Expand You properly want to see my class, so here it is Reveal hidden contents 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)); } } Quote
Erfurt Posted April 21, 2017 Author Posted April 21, 2017 On 4/21/2017 at 6:20 PM, diesieben07 said: Hm. Put the breakpoint a bit further up (EntityMoveHelper::onUpdateMoveHelper) and see what is happening. Expand Nothing seems to be happening. Do I need t o implement something or is there something wrong with the method I use? Quote
Erfurt Posted April 21, 2017 Author Posted April 21, 2017 On 4/21/2017 at 6:31 PM, diesieben07 said: onUpdateMoveHelper is not called? Expand It is, but it seems that it's just looping, but not doing anything. Maybe I'm doing something wrong Quote
Erfurt Posted April 21, 2017 Author Posted April 21, 2017 On 4/21/2017 at 6:38 PM, diesieben07 said: That doesn't sound right. Expand 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? Quote
Erfurt Posted April 22, 2017 Author Posted April 22, 2017 On 4/21/2017 at 6:38 PM, diesieben07 said: That doesn't sound right. Expand 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 Quote
quadraxis Posted April 22, 2017 Posted April 22, 2017 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. Quote
Recommended Posts
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.