Package org.quiltmc.qsl.entity.multipart.api
package org.quiltmc.qsl.entity.multipart.api
The Multipart Entity API.
This API abstracts many of the previously EnderDragon
and EnderDragonPart
specific code so that modders can implement their own
MultipartEntities.
Creating a Multipart Entity
To create aMultipartEntity,
your Entity simply has to implement the interface and its one method,
getEntityParts(). Then, each of its
parts must be an instance of EntityPart.
This is made easy with the provided
AbstractEntityPart.
NOTE:
When instantiatingEntityParts, on the client,
make sure to call setId(int).
@Override
public void onSpawnPacket(EntitySpawnS2CPacket packet) {
super.onSpawnPacket(packet);
var entityParts = this.getEntityParts();
// We make sure not to override the base entity id
// Mojang did this on the ender dragon, and it caused very janky hitboxes
for(int i = 1; i <= entityParts.length; i++) {
entityParts[i].setId(i + packet.getId());
}
}
This API also fixes two vanilla bugs:
-
ClassDescriptionAbstractEntityPart<E extends net.minecraft.entity.Entity>A partial implementation of an
EntityPartwith the most common methods implemented.EntityPart<E extends net.minecraft.entity.Entity>Represents the sub-parts of aMultipartEntity.Represents an entity that contains multipleEntityParts.