Open
Conversation
This commit updates and implements the MixinEntity class (the implementation and the mixin).
| for (net.minecraft.entity.Entity entity : nmsEntities) { | ||
| apiEntities.add((Entity) entity); | ||
| } | ||
| return ImmutableList.copyOf(apiEntities); |
There was a problem hiding this comment.
Since Minecraft's Entity implements the interface you can directly do ImmutableList.copyOf on the nmsEntities for some performance boosts
This commit casts the list and removes adding all and casting all items in the list.
| public abstract class MixinEntity implements Entity, ICommandSender { | ||
|
|
||
| @Shadow public boolean onGround; | ||
|
|
| public abstract List<net.minecraft.entity.Entity> shadow$getPassengers(); | ||
|
|
||
| @Shadow | ||
| public abstract void shadow$addPassenger(net.minecraft.entity.Entity passenger); |
Contributor
There was a problem hiding this comment.
Why the shadow$ prefix?
| @Intrinsic | ||
| @Nonnull | ||
| public ImmutableList<Entity> entity$getPassengers() { | ||
| List entities = this.shadow$getPassengers(); |
Contributor
There was a problem hiding this comment.
Why the need for this field?
Member
There was a problem hiding this comment.
You sure get a lot of IDE errors.
Contributor
Author
There was a problem hiding this comment.
It doesn't work unless the shadow method has a List return type without a generic. Would Mixin register it correctly?
| @Override | ||
| public ImmutableCollection<Entity> getNearbyEntities(double distance) { | ||
| List<net.minecraft.entity.Entity> nmsEntities = this.getCommandSenderEntity().worldObj.getEntitiesWithinAABBExcludingEntity(this.getCommandSenderEntity(), this.getCommandSenderEntity().getEntityBoundingBox().expand(distance / 3, distance / 3, distance / 3)); | ||
| return ImmutableList.copyOf(((List<Entity>)((List) nmsEntities))); |
Contributor
There was a problem hiding this comment.
Don't bother casting to List<Entity>
| import org.fountainmc.api.world.World; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Shadow; | ||
| import org.spongepowered.asm.mixin.*; |
Contributor
There was a problem hiding this comment.
Don't collect imports using *.
Contributor
|
Status on this pr? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--recursiveto arguments in README.md.MixinEntity.