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

Updates #7

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open

Updates #7

wants to merge 7 commits into from

Conversation

PizzaCrust
Copy link
Contributor

  • Add --recursive to arguments in README.md.
  • Update to the latest API changes in MixinEntity.

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);

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

Copy link
Contributor

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;

Copy link
Contributor

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);
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IDE errors.

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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)));
Copy link
Contributor

@jamierocks jamierocks Jun 21, 2016

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>

@jamierocks jamierocks self-assigned this Jun 21, 2016
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.*;
Copy link
Contributor

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 *.

@jamierocks
Copy link
Contributor

Status on this pr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants