-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
base: dev/feature
Are you sure you want to change the base?
Add Collidable elements #6708
Conversation
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.
Test!!! Before the others appear
src/main/java/ch/njol/skript/expressions/ExprCollidableState.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCollidableState.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Fusezion <fusezionstream@gmail.com>
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. |
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.
aside from the collision exemption rules this is fine to me
@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; | ||
} | ||
} | ||
|
||
} |
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.
you should try to make it less repetitive
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.
Out of curiosity how would you propose it?
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.
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 🤷
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.
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 -> { |
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.
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
Description
I added CondIsCollidable, ExprCollidableState and ExprCollidableExemptions
Target Minecraft Versions: any
Requirements: none
Related Issues: none