While clearing out a mineshaft recently, I discovered something I hadn't noticed before.
I was standing in a tunnel waiting for a group of zombies to come toward me. There was a rail track down the tunnel with one of the support structures across it. When the zombies came to there, they would not step onto the track to go under the arch. I walked right up to the arch opposite them and they still would not come through to attack me. I knew they could not spawn on track, but is there a restriction of them even walking on it also? There is plenty of room for my character to walk through, so why won't the zombies?
The Meaning of Life, the Universe, and Everything.
Join Date:
8/19/2014
Posts:
253
Member Details
I believe it has to do with the AI thinking the rail is a full block, similarly to how mobs believe trap doors are full blocks allowing them to just walk off of a ledges.
This is because the pathfinding AI was specifically coded to avoid rails (they will pathfind over rails if they are pushed onto them, usually when there is a group of mobs), a feature introduced in the snapshots for 1.5, released over 7 years ago:
The same also goes for other blocks, like doors and trapdoors (this is from my own modded PathFinder class but the rails, doors, trapdoors, fences, and walls are vanilla behavior. The latter two already do block mobs due to their collision box being 1.5 blocks high but this ensures they don't actively try to get over them since they see them as being only 1 block high):
Block block = Block.blocksList[this.worldMap.getBlockId(x, y, z)];
if (block != null)
{
Material material = block.blockMaterial;
if (block == Block.trapdoor)
{
flag = true;
}
else if (material == Material.water)
{
if (this.isPathingInWater) return -1;
flag = true;
}
else if (!this.canOpenWoodDoor && block == Block.doorWood)
{
return 0;
}
// Added checks for cactus, fire, magma, and dry ice so mobs avoid them. Does not check if
// shouldAvoidBlocks is false so mobs can pathfind when standing on these blocks.
if (this.shouldAvoidBlocks)
{
if (material == Material.cactus) return -2;
if (this.avoidsDryIce && block == Block.dryIce) return -2;
if (this.avoidsFire && (material == Material.fire || block == Block.magmaBlock)) return -2;
}
if (block instanceof BlockRailBase)
{
// Rails acts as a barrier unless a mob is already on/in them
if (!this.isBlockRail(this.entityY) && !this.isBlockRail(this.entityY - 1)) return -3;
}
else if (!block.getBlocksMovement(this.worldMap, x, y, z) && (!this.isMovementBlockAllowed || block != Block.doorWood))
{
// isBlockFence includes fence gates
if (BlockFenceTMCW.isBlockFence(block.blockID) || block == Block.cobblestoneWall) return -3;
if (block == Block.trapdoor) return -4;
if (material != Material.lava) return 0;
if (!this.pathingEntity.handleLavaMovement()) return -2;
}
}
This is because the pathfinding AI was specifically coded to avoid rails (they will pathfind over rails if they are pushed onto them, usually when there is a group of mobs), a feature introduced in the snapshots for 1.5, released over 7 years ago:
The same also goes for other blocks, like doors and trapdoors (this is from my own modded PathFinder class but the rails, doors, trapdoors, fences, and walls are vanilla behavior. The latter two already do block mobs due to their collision box being 1.5 blocks high but this ensures they don't actively try to get over them since they see them as being only 1 block high)
Not really up on my Java and can't tell from the code snippet, but does this apply to all mobs, and does it imply that even livestock can be blocked by a rail track?
Not really up on my Java and can't tell from the code snippet, but does this apply to all mobs, and does it imply that even livestock can be blocked by a rail track?
Yes, at least for ordinary mobs that walk (as opposed to flying or jumping) but it isn't reliable because if a mob is pushed onto a rail they will no longer be seen as an obstacle (including other rails, not just the one it is in), so it is only useful for individual mobs (this can be compared to mobs that avoid sunlight; while they avoid it they will pathfind through sunlit areas if they are already in it, same for mobs that avoid water, lava, or other hazards).
Yes, at least for ordinary mobs that walk (as opposed to flying or jumping) but it isn't reliable because if a mob is pushed onto a rail they will no longer be seen as an obstacle (including other rails, not just the one it is in), so it is only useful for individual mobs (this can be compared to mobs that avoid sunlight; while they avoid it they will pathfind through sunlit areas if they are already in it, same for mobs that avoid water, lava, or other hazards).
That leads to some very interesting thoughts. Gives me some new ideas for base and village building.
While clearing out a mineshaft recently, I discovered something I hadn't noticed before.
I was standing in a tunnel waiting for a group of zombies to come toward me. There was a rail track down the tunnel with one of the support structures across it. When the zombies came to there, they would not step onto the track to go under the arch. I walked right up to the arch opposite them and they still would not come through to attack me. I knew they could not spawn on track, but is there a restriction of them even walking on it also? There is plenty of room for my character to walk through, so why won't the zombies?
Learn something new each day
I believe it has to do with the AI thinking the rail is a full block, similarly to how mobs believe trap doors are full blocks allowing them to just walk off of a ledges.
This is because the pathfinding AI was specifically coded to avoid rails (they will pathfind over rails if they are pushed onto them, usually when there is a group of mobs), a feature introduced in the snapshots for 1.5, released over 7 years ago:
https://minecraft.gamepedia.com/Java_Edition_13w04a#Mobs_2
The same also goes for other blocks, like doors and trapdoors (this is from my own modded PathFinder class but the rails, doors, trapdoors, fences, and walls are vanilla behavior. The latter two already do block mobs due to their collision box being 1.5 blocks high but this ensures they don't actively try to get over them since they see them as being only 1 block high):
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
Not really up on my Java and can't tell from the code snippet, but does this apply to all mobs, and does it imply that even livestock can be blocked by a rail track?
Learn something new each day
Yes, at least for ordinary mobs that walk (as opposed to flying or jumping) but it isn't reliable because if a mob is pushed onto a rail they will no longer be seen as an obstacle (including other rails, not just the one it is in), so it is only useful for individual mobs (this can be compared to mobs that avoid sunlight; while they avoid it they will pathfind through sunlit areas if they are already in it, same for mobs that avoid water, lava, or other hazards).
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
That leads to some very interesting thoughts. Gives me some new ideas for base and village building.
Learn something new each day