Cancel block change packets for removed actions

This commit is contained in:
KennyTV 2020-06-08 17:46:18 +02:00
parent d58959fcca
commit 9c81ba368f
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -31,7 +31,17 @@ public class BlockRewriter {
map(Type.UNSIGNED_BYTE); // Action id
map(Type.UNSIGNED_BYTE); // Action param
map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE
handler(wrapper -> wrapper.set(Type.VAR_INT, 0, blockRewriter.rewrite(wrapper.get(Type.VAR_INT, 0))));
handler(wrapper -> {
int id = wrapper.get(Type.VAR_INT, 0);
int mappedId = blockRewriter.rewrite(id);
if (mappedId == -1) {
// Block (action) has been removed
wrapper.cancel();
return;
}
wrapper.set(Type.VAR_INT, 0, mappedId);
});
}
});
}