Advertisement
theosib

MC-2025 mojira comment

Jun 7th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. *The following is the most minimal fix we could come up with for MC-2025. I mean, it's painfully absolutely brainlessly simple, and it WORKS.*
  2.  
  3. There were rumors that MC-2025 had been fixed already, so I was comfortable tinkering with more complicated solutions. However, we can't find any evidence of a fix from decompiling 1.13-pre1, so I have decided to be practical here. So to begin with, disregard my last comment. The following solution should be used instead.
  4.  
  5. Along with plenty of other people, I, Xcom, and MrGrim (Michael Kreitzer), and Kademlia came up with basically the same solution independently. Xcom's has been in Carpet Mod for ages, and MrGrim has been using it in his own custom JAR for probably about as long. The really embarrassing thing is that Kademlia figured it out about two years ago, well before any of the rest of us (https://bugs.mojang.com/browse/MC-2025?focusedCommentId=317274&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-317274). A little over a year later, I found the underlying cause (https://bugs.mojang.com/browse/MC-2025?focusedCommentId=408078&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-408078). But everyone just argued for "better" solutions (including me), which was dumb.
  6.  
  7. There's no point in "correcting" the AABB. The drift is on the order of 2^(-46). Moreover, AABB inflation is statistically as likely as the shrinkage that causes the bug, so there should be no long-term cumulative drift, just random wobble in the size. So I think it's about time that this bug just got fixed once and for all.
  8.  
  9. Based on MCP symbols for 1.12.2, the following methods on Entity need to be modified:
  10.  
  11. * {{public NBTTagCompound writeToNBT(NBTTagCompound compound)}}
  12. * {{public void readFromNBT(NBTTagCompound compound)}}
  13.  
  14. h3. Saving the AABB on chunk unload
  15.  
  16. In {{writeToNBT}}, somewhere within the {{try}} block, do the following:
  17.  
  18. {code:java}
  19. AxisAlignedBB aabb = this.getEntityBoundingBox();
  20. compound.setTag("AABB", this.newDoubleNBTList(
  21. aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ));
  22. {code}
  23.  
  24. h3. Restoring the AABB after chunk reload
  25.  
  26. There are two places in {{readFromNBT}} that call {{setPosition}}, which resets the AABB based on entity width. It is *very important* that this new code be inserted *after* those calls. This needs to be the *very last thing* inside of the {{try}} block.
  27.  
  28. So right _after_ this:
  29.  
  30. {code:java}
  31. if (this.shouldSetPosAfterLoading())
  32. {
  33. this.setPosition(this.posX, this.posY, this.posZ);
  34. }
  35. {code}
  36.  
  37. Insert this code:
  38.  
  39. {code:java}
  40. if (compound.hasKey("AABB")) {
  41. NBTTagList aabb = compound.getTagList("AABB", 6);
  42. this.setEntityBoundingBox(new AxisAlignedBB(aabb.getDoubleAt(0), aabb.getDoubleAt(1),
  43. aabb.getDoubleAt(2), aabb.getDoubleAt(3),
  44. aabb.getDoubleAt(4), aabb.getDoubleAt(5)));
  45. }
  46. {code}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement