Getting BlockPosition on block place in 1.14+?
MeGysssTaa opened this issue ยท 3 comments
Make sure you're doing the following
- You're using the latest build for your server version
- This isn't an issue caused by another plugin
- You've checked for duplicate issues
- You didn't use
/reload
Describe the question
In MC prior to 1.14x, I can listen for PacketType.Play.Client.USE_ITEM
packets to handle block placements. And I can use this to retrieve the position of the block placed:
BlockPosition pos = e.getPacket().getBlockPositionModifier().readSafely(0);
However, in MC 1.14 and newer pos
is always null
. Is there any alternative (whatever way to get the same functionality, with packets, without using Bukkit events)?
API method(s) used
onPacketReceiving
(USE_ITEM
)PacketContainer#getBlockPositionModifier
(works before 1.14,null
s in 1.14+)
Expected behavior
I'd like to get the coordinates of the block placed (behavior as in versions prior to 1.14, but in 1.14+).
Code
(above)
Additional context
ProtocolLib 4.6.1-SNAPSHOT-b498 (freshly downloaded version from Jenkins, tested right before opening this issue)
Thank you! I confirm this works on MC 1.14 and newer.
However, e.getPacket().getMovingBlockPositions().read(0)
is always null
in versions before 1.14 (tested 1.8.8, 1.9.4, and 1.13.2). Having some backwards compatibility in ProtocolLib would be nice, I think (just like in case with #1242)
@MeGysssTaa
try this on latest version of ProtocolLib
BlockPosition pos = e.getPacket().getMovingBlockPositions().read(0).getBlockPosition()