Skip to content

Conversation

@BlvckBytes
Copy link
Contributor

As I've already stated in the CraftBook Discord channel, the Gate mechanic often selects blocks which completely go against the intuition of the user, simply due to its search-algorithm, which doesn't consider distance at all. Expanding radially outwards from the point of the sign to me seems like the only right way of doing it.

Copy link
Member

@me4502 me4502 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Have you done any testing to assess how this performs to the old method? A simple loop was chosen here for speed, as some servers have tens of thousands of gates controlled by redstone/etc. My assumption would be that this will have substantially worse cache locality / predictions, but will likely find the gate block earlier than the previous one for most cases.

import org.enginehub.craftbook.util.EventUtil;
import org.enginehub.craftbook.util.ProtectionUtil;
import org.enginehub.craftbook.util.SignUtil;
import org.enginehub.craftbook.util.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to please make sure that import style is retained & follows our style guide?

enumerationLoop: while (!enumerationQueue.isEmpty()) {
Block currentOrigin = enumerationQueue.poll();

if (Math.abs(currentOrigin.getX() - sign.getX()) >= searchRadius)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please ensure that the if statements/etc here keep the braces and follow the style guide?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants