Skip to content
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 Collidable elements #6708

Open
wants to merge 7 commits into
base: dev/feature
Choose a base branch
from
Open

Conversation

aabssmc
Copy link

@aabssmc aabssmc commented May 19, 2024

Description

I added CondIsCollidable, ExprCollidableState and ExprCollidableExemptions

Target Minecraft Versions: any
Requirements: none
Related Issues: none

Copy link
Contributor

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

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

Test!!! Before the others appear

@cheeezburga
Copy link

Maybe also add collidable exemptions as part of this PR? Also I feel like an effect might work better than an expression seeing as it can only be set to true or false, similar to the invulnerable syntax.

Copy link
Contributor

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

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

aside from the collision exemption rules this is fine to me

Comment on lines +100 to +131
@Override
public void change(Event event, @Nullable Object[] delta, Changer.ChangeMode mode) {
List<UUID> uuidList = new ArrayList<>();
if (delta != null){
for (Object object : delta){
if (object instanceof LivingEntity)
uuidList.add(((LivingEntity) object).getUniqueId());
}
}
switch (mode) {
case SET:
case DELETE:
case RESET:
getExpr().stream(event).forEach(livingEntity -> {
livingEntity.getCollidableExemptions().clear();
if (!uuidList.isEmpty()) {
livingEntity.getCollidableExemptions().addAll(uuidList);
}
});
break;
case ADD:
getExpr().stream(event).forEach(livingEntity ->
livingEntity.getCollidableExemptions().addAll(uuidList));
break;
case REMOVE:
getExpr().stream(event).forEach(livingEntity ->
uuidList.forEach(livingEntity.getCollidableExemptions()::remove));
break;
}
}

}
Copy link
Contributor

Choose a reason for hiding this comment

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

you should try to make it less repetitive

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity how would you propose it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity how would you propose it?

so above the switch, you would do

 getExpr().stream(event).forEach(livingEntity -> {
        List<UUID> exemptions = livingEntity.getCollidableExemptions();

and then you could do exemptions.addAll(uuidlist) or exemptions.clear instead of redoing the stream everytime

my logic could also be completely wrong, but idk 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

This is indeed applicable, which all left is the unexpected unforeseen bump ahead 😬

protected LivingEntity[] get(Event event, LivingEntity[] source) {
List<LivingEntity> entities = new ArrayList<>();
for (LivingEntity livingEntity : source){
livingEntity.getCollidableExemptions().forEach(uuid -> {
Copy link
Member

Choose a reason for hiding this comment

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

Can't do a full review rn but this isn't reliable
This needs to return uuids, because the entities it returns will change based on loaded chunks

@sovdeeth sovdeeth added the feature Pull request adding a new feature. label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants