[1.95b] BUG+FIX CropCard.onEntityCollision still broken on servers.

  • Observed behaviour: While connected to a server, contacting crops while on the ground randomly causes them to break.


    Expected behaviour: As in simgleplayer, crops should only break in multiplayer if the player falls or sprints on them.


    Underlying cause: This one's my fault, actually. I told Alblaka that EntityLiving.motionY was 0 for a player on the ground, and it is... in singleplayer. On a server, it rapidly switches between 0 and a small negative value (-0.0784000015258789, at least for my server). So half the time, the server thinks you're falling, and triggers the crop trampling chance.


    Fix: Change "((EntityLiving)entity).motionY < 0" to "((EntityLiving)entity).motionY < -0.1". I recommend testing on another server as well, to see if my observed value for motionY matches. (I suspect it's one tick of the gravity constant, and will be identical on every server.)


    Mea culpa.

  • Vanilla trampling uses a completely different hook, BlockFarmland.onFallenUpon, which is not affected by this issue. Indeed, the other solution (as I mentioned last time) is to just remove that check entirely and let the underlying farmland handle trampling due to falling/jumping. If the vanilla trampling code trips, the farmland will become dirt and break the crop block. Sprinting would still need to be handled by CropCard.

  • I had a similar problem when writing a mod which causes your character (others too, if you're playing SMP) to make noises when jumping (think Quake 2), though in this case, single player through the MCP test client gave me a constant motionY of -0.078(etc.) when standing still. Strange, that.

    GENERATION (Pineapple + i): The first pineapple you see, copy it into your sig on any forum and add sqrt(-1) to the generation. Pineapple experiment.