Skip to content

Commit

Permalink
Added passengers (plural) mec & flag for 1.11.2
Browse files Browse the repository at this point in the history
In reference to my earlier feature request:
#1627

Made new mec & tag instead of editing old ones to preserve backwards compatibility, plus they work differently than the old ones. Tested both old and new features on 1.12, 1.11.2, and 1.10. All are working~
  • Loading branch information
mergu committed Jul 28, 2017
1 parent c7d7441 commit f429e42
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dEntity.java
Expand Up @@ -1970,6 +1970,24 @@ else if (mtr.angle == BlockFace.EAST) {
}
}

// <--[tag]
// @attribute <e@entity.passengers>
// @returns dList(dEntity)
// @group attributes
// @description
// Returns a list of the entity's passengers, if any.
// -->
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_11_R1) && (attribute.startsWith("passengers") || attribute.startsWith("get_passengers"))) {
if (!entity.isEmpty()) {
ArrayList<dEntity> passengers = new ArrayList<dEntity>();
for (Entity ent : entity.getPassengers()) {
passengers.add(new dEntity(ent));
}
return new dList(passengers)
.getAttribute(attribute.fulfill(1));
}
}

// <--[tag]
// @attribute <e@entity.passenger>
// @returns dEntity
Expand Down Expand Up @@ -2635,6 +2653,25 @@ public void adjust(Mechanism mechanism) {
NMSHandler.getInstance().getEntityHelper().setBreeding((Animals) getLivingEntity(), value.asBoolean());
}

// <--[mechanism]
// @object dEntity
// @name passengers
// @input dList(dEntity)
// @description
// Sets the passengers of this entity.
// @tags
// <e@entity.passengers>
// <e@entity.empty>
// -->
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_11_R1) && mechanism.matches("passengers")) {
entity.eject();
for (dEntity ent : value.asType(dList.class).filter(dEntity.class)) {
if (ent.isSpawned()) {
entity.addPassenger(ent.getBukkitEntity());
}
}
}

// <--[mechanism]
// @object dEntity
// @name passenger
Expand Down

0 comments on commit f429e42

Please sign in to comment.