The bug
Since farmland is now 15/16 of a block, jumping on it will change it back to dirt, which is a full block. The player is now stuck inside the block.
Caused by fixing MC-85162.
Code analysis / Fix
See this comment by @unknown.
Related issues
is cloned by
relates to
testing discovered
Attachments
Comments


Caused by the fix of MC-85162 ?
Can confirm.

You also get stuck if farmland reverts to dirt naturally while you're standing on it.

I didn't see this issue before submitting mine, but that's because I was looking for the keyword villager in the subject and should have searched for farmland or similar. Anyways, on mine, I attached a video showing a villager falling through the block. See MC-104906. Hope it helps get it resolved soon.

Confirmed for 1.10.2 as well. The obvious fix would be that when the farmland converts to dirt, it finds all entities within its new bounding box (or within its old bounding box + 1/16 on the y axis) and teleports them up by 0.0625 (1/16) blocks. From what I remember of modding, that should be just a few lines of code to fix this (of course, I'm not sure how different the Forge API is to the original source code, so maybe it's harder than it seems).

That could work. First I thought you might get teleported into a block, but I just tested it, there is no block that you can fit under when standing on farmland that you can't fit under standing on dirt. Examples: You can stand under a upside down trapdoor in both cases, you can stand under a slab in none of the cases. But it might be possible to align a boat or minecart on snow layers exactly so that you get teleported inside of it when the farmland converts to dirt. On the other hand I don't know in which situation this could become a problem.
Can confirm for 16w32a.

Confirmed for Snapshot 16w32b, even though it's listed as 'fixed'.

It was marked as fixed for a future version by Grumm today. Are you sure it wasn't the version of today?

@unknown, just tested, it's not fixed for 16w32b. But you should stand on the block when the farmland is changing (it's probably fixed for jumping)

Hoping my attached gif will properly animate.
(In the GIF, you will see I aligned "CPU:" with the horizontal line of the ripe crop. I then didn't touch the mouse and took many screenshots. I was in a much more violent vibrating state than the GIF shows. The GIF also shows how sometimes I slip into the block.)
Problem still happens for 16w33a.
WIndows 10 Pro
Java 1.8.0_101-b13
In the case of the attachment above, I got stuck for a slightly different reason, yet the same. I was simply farming potatoes when suddenly I got stuck.
It's the same issue in that it seems I got stuck when the surface I was on changed state. Originally it became dirt when standing on it and getting stuck, but by the time I started started taking screenshots for the animation, it turned green (that's why I'm standing stuck on green and not dirt that I just farmed potatoe from).
To repeat myself,
when looking at the GIF, look at "CPU:" in the top center of the screen.
From here you can more clearly see me bouncing by a couple of pixels before slipping into the block (was not touching the mouse). Even though I took many screenshots to take the GIF, it doesn't represent how violent the up-down motion of a few pixels is. It is extremely violent. Very very bouncy.

I too found this issue in 1.10.2, I recorded a short clip showing it. However I only experience this when dirt turns to farmland or vice-versa. Walking onto it doesn't affect me.
https://gaming.youtube.com/watch?v=bDeOk1FJ6YU&feature=share

Back in 16w43a: MC-109295

I definitely trampled some farmland in pre1 and it worked fine. I even tested what happens if there is a boat in snow layers above you that you go into when the farmland turns into dirt and it seemed like logical behavior to me.
How to reproduce in pre1?
I cannot reproduce.

I couldn't reproduce it in Creative, but maybe it was just Murphy's Law.
I could reproduce it several times in Survival though: https://www.youtube.com/watch?v=NnGQes5Ltnw
It does not always occur, from quick testing it might be one has to be at the edge of the block for it to happen.. at least I couldn't seem to reproduce it whilst I was more "middle'ish", but no guarantee, I did not much testing, but I hope it helps still 🙂

I managed to find another way to reproduce without jumping to trample.
If you have a 2-long patch of farmland, and stand in the middle, and then place a sign on the front farmland, it'll become dirt. You can then hold forward to hold and you'll become stuck in the block that became dirt. This happens in both survival and creative.
I also managed to reproduce with jumping in creative a few times with decent positioning (in creative).
It seems like this only happens if your hitbox is not entirely on the block that changes, but instead partially on another block; however it also needs to have its center over the block that changes (or else the block won't change). Once the block has changed, you need to hold forward so that you can actually fall down.
Try positioning yourself at .9.

Are you sure that your middle is NOT on the block that stays farmland? Because if you get stuck when your middle is on the unchanged block, this might be a variant of MC-1133.

Yes, I am sure that my middle is on the block that changes. (I place the sign by looking down and forwards, and that'll only place it on the block you're on, not the one behind you; also trampling by jumping will (by MC-1133) only affect the block you're directly on and not the one behind you).

I've had this happen even WITHOUT the block turning back to dirt.

Can anyone still reproduce this with a single farmland block only or only with at least two (see this comment)? If not the description needs to be updated.

I could directly reproduce it with the setup described in the post you linked (sign on 2nd farmland etc.), couldn't reproduce with single farmland yet, but maybe my setup for one farmland is wrong atm.
Also can't reproduce it so far with the single-farmland-instructions from the same comment (positioning at .9).

I've only been able to reproduce this (and have only been testing with) the 2-block variant.

Alright, figured this out. (MCP 940, with 1.12.1 SRG mappings)
Why it only works some of the time
@unknown' fix in 16w35a (which was suggested by @unknown) is correct, but the implementation has a slight flaw: it only sets the position on the server; the client isn't informed that it should move up. However, there is another mechanism that later causes the client to be informed: the serverside check that prevents players from moving into blocks. When the block is changed, the client starts falling into it. However, the server detects this and rejects that movement (after all, the server thinks the player is on top of the block). The server then teleports the player on top of the block, and everything is fine.
However, if the player does not fall (i.e. they're partially standing on another block), then the server doesn't move them up (even though they are still positioned inside a block). Why doesn't the server think they're in a block and thus move them out in this case? Well, for some reason, hitboxes are shrunk slightly before checking if the player is in a block. Specifically, they're shrunk by 0.0625D
... or precisely 1/16th of a block. So the server is completely fine with the player being partially inside the farmland. And thus, the player can still move around, and overwrite the moved up position that the farmland chose. Then, when the player moves too far forward and has no other block holding them up, they start falling into the farmland. This time, there's no server position outside of the block to help them, and they get stuck.
Fix
To fix this, the client needs to be informed of the change in position using NetHandlerPlayClient.setPlayerLocation
(this same special casing is used in plenty of other places, including the teleport commands):
private void turnToDirt(World worldIn, BlockPos pos) {
IBlockState iblockstate = Blocks.DIRT.getDefaultState();
worldIn.setBlockState(pos, iblockstate);
AxisAlignedBB axisalignedbb = iblockstate.getCollisionBoundingBox(worldIn, pos).offset(pos);
for (Entity entity : worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb)) {
if (entity instanceof EntityPlayerMP) {
double delta = axisalignedbb.maxY - entity.posY;
((EntityPlayerMP) entity).connection.setPlayerLocation(0, delta, 0, 0, 0, EnumSet.allOf(SPacketPlayerPosLook.EnumFlags.class));
} else {
entity.setPosition(entity.posX, axisalignedbb.maxY, entity.posZ);
}
}
}
(I use a relative teleport instead of an absolute one because a relative teleport will be smoother)
This same logic should be added to BlockGrassPath
. While grass paths can't be trampled, they do change when blocks are placed above them (for instance, signs). They do not make any attempt to move players out of the ground, which means that players will get stuck in them when the block is placed (again, the 1/16th of a block contraction). Fixing this simply requires adding the same code to BlockGrassPath
's dirt conversion logic (which MCP calls updateBlockState
).