-
-
Notifications
You must be signed in to change notification settings - Fork 391
Properly Handle Blockdata in Click Event #7886
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
base: dev/patch
Are you sure you want to change the base?
Properly Handle Blockdata in Click Event #7886
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.
imo, kinda weird having the conditions go from
object instanceof
to entity != null
then to object instanceof
Also, maybe this can be a good opportunity for a JUnit test. |
it's either that or I check |
Why would you need to check it twice? I believe the only real fix was just adding the |
there would be one inside there and another outside (the one I moved) |
I just tested with this return type.check(event, (Predicate<Object>) object -> {
if (entity != null) {
if (object instanceof EntityData<?> entityData) {
return entityData.isInstance(entity);
} else if (object instanceof ItemType itemType) {
Relation compare = DefaultComparators.entityItemComparator.compare(EntityData.fromEntity(entity), itemType);
return Relation.EQUAL.isImpliedBy(compare);
}
} else if (object instanceof ItemType itemType) {
return itemType.isOfType(block);
} else if (blockDataCheck != null && object instanceof BlockData blockData) {
return blockDataCheck.matches(blockData);
}
return false;
}); You wouldnt need a
|
It might not hurt to have a comment there to clarify why a BlockData check isn't necessary (even though an ItemType check is present) |
its for comparing like a boat item to an entity boat if that's what you are asking |
He was saying to put a comment in the code |
language barrier :( |
Problem
If you use the
on right click on %blockdata%
pattern and click on an entity, it always assumes the object is either an entity or an item type, but not block data, which can cause the server to crash.Solution
Moved the blockdata check a bit earlier to fix the issue and added an
instanceof ItemType
check to prevent possible crashes in the future.Testing Completed
Tested
on right click on pig
,on right click on stone
,on right click on stone_button[]
andon right click on stone_button[powered=false]
to ensure nothing was broken with this fix.Completes: #7885
Related: none