-
-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PlayerESP teammates marking #946
base: master
Are you sure you want to change the base?
Conversation
WalkthroughWalkthroughThe update introduces a feature that allows players to visually distinguish their teammates in-game through the use of dyed armor pieces. This is achieved by marking teammates with light blue colored armor, facilitated by a new checkbox setting for enabling or disabling this functionality. The change enhances team coordination by making it easier to identify allies during gameplay. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
armorColors.clear(); | ||
if(!markTeammates.isChecked()) | ||
return; | ||
|
||
for(ItemStack s : player.getArmorItems()) | ||
{ | ||
Item item = s.getItem(); | ||
if(item instanceof DyeableArmorItem) | ||
armorColors.add(((DyeableArmorItem)item).getColor(s)); | ||
} | ||
armorColors.remove(DyeableArmorItem.DEFAULT_COLOR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for populating armorColors
does not account for the possibility of a player not wearing any armor. This could lead to unnecessary execution of the loop. Consider adding a check to skip this process if the player is not wearing any armor.
else if(isInTeam(e)) | ||
RenderSystem.setShaderColor(0.4F, 0.7F, 1, 0.5F); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The color values used for marking teammates (0.4F, 0.7F, 1
) are hardcoded. For better maintainability and readability, define these as static final variables with descriptive names.
}else if(isInTeam(e)) | ||
{ | ||
r = 0.4F; | ||
g = 0.7F; | ||
b = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous comment, the color values used here are also hardcoded. Apply the same recommendation: define these as static final variables for improved code clarity and maintainability.
private boolean isInTeam(PlayerEntity otherPlayer) | ||
{ | ||
if(armorColors.isEmpty() || !markTeammates.isChecked()) | ||
return false; | ||
|
||
for(ItemStack s : otherPlayer.getArmorItems()) | ||
{ | ||
Item item = s.getItem(); | ||
if(item instanceof DyeableArmorItem | ||
&& armorColors.contains(((DyeableArmorItem)item).getColor(s))) | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The isInTeam
method performs its intended function but lacks efficiency in handling armor items. Consider streamlining the loop with Java Streams to improve readability and potentially enhance performance.
private boolean isInTeam(PlayerEntity otherPlayer) {
if(armorColors.isEmpty() || !markTeammates.isChecked())
return false;
return otherPlayer.getArmorItems().stream()
.map(ItemStack::getItem)
.filter(DyeableArmorItem.class::isInstance)
.anyMatch(item -> armorColors.contains(((DyeableArmorItem)item).getColor(item)));
}
You can also add a new hack named |
This is also a solution, but at at least for me, I would prefer to see a difference between manually added friends and teammates. I think a better solution would be to add a global list of teammates, separated from the friend list. It could have options to disable it or change the way teammates are predicted (e.g. based on the tab list color). |
This pull request has been open for a while with no recent activity. If you're still working on this or waiting for a review, please add a comment or commit within the next 7 days to keep it open. Otherwise, the pull request will be automatically closed to free up time for other tasks. Pull requests should be closed if:
|
This pull request has been open for a while with no recent activity. If you're still working on this or waiting for a review, please add a comment or commit within the next 7 days to keep it open. Otherwise, the pull request will be automatically closed to free up time for other tasks. Pull requests should be closed if:
|
Do I have to make these changes suggested by coderabbit? |
Description
Marking potential teammates with light blue PlayerESP line color, based on the color of dyed leather armor. If both players have at least one leather armor piece with the same color (excluding not dyed), the player is marked as a teammate.
It also adds checkbox to disable it.
Testing
Tested on a local server and on the bedwars match.
References