-
Notifications
You must be signed in to change notification settings - Fork 3
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
Updates #7
base: develop
Are you sure you want to change the base?
Updates #7
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Minecraft's Entity
implements the interface you can directly do ImmutableList.copyOf
on the nmsEntities
for some performance boosts
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 commit casts the list and removes adding all and casting all items in the list.
@Mixin(net.minecraft.entity.Entity.class) | ||
public abstract class MixinEntity implements Entity { | ||
@Implements(@Interface(iface = Entity.class, prefix = "entity$")) | ||
public abstract class MixinEntity implements Entity, ICommandSender { | ||
|
||
@Shadow public boolean onGround; | ||
|
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.
No gaps between fields
public abstract List<net.minecraft.entity.Entity> shadow$getPassengers(); | ||
|
||
@Shadow | ||
public abstract void shadow$addPassenger(net.minecraft.entity.Entity passenger); |
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.
Why the shadow$ prefix?
@Intrinsic | ||
@Nonnull | ||
public ImmutableList<Entity> entity$getPassengers() { | ||
List entities = this.shadow$getPassengers(); |
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.
Why the need for this field?
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.
IDE errors.
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 sure get a lot of IDE errors.
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.
It doesn't work unless the shadow method has a List return type without a generic. Would Mixin register it correctly?
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.
Just cast to a List
@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))); |
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.
Don't bother casting to List<Entity>
import net.minecraft.util.math.BlockPos; | ||
import org.fountainmc.api.entity.Entity; | ||
import org.fountainmc.api.world.Location; | ||
import org.fountainmc.api.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.*; |
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.
Don't collect imports using *.
Status on this pr? |
--recursive
to arguments in README.md.MixinEntity
.