Skip to content

Updates#7

Open
PizzaCrust wants to merge 7 commits intoFountainMC:developfrom
PizzaCrust:develop
Open

Updates#7
PizzaCrust wants to merge 7 commits intoFountainMC:developfrom
PizzaCrust:develop

Conversation

@PizzaCrust
Copy link
Copy Markdown
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);
Copy link
Copy Markdown

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
Copy Markdown
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.
public abstract class MixinEntity implements Entity, ICommandSender {

@Shadow public boolean onGround;

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 org.fountainmc.api.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.*;
Copy link
Copy Markdown
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
Copy Markdown
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