Added generic multi part entity API (#7554)

This commit is contained in:
brandon3055 authored and GitHub committed 2021-02-09 12:53:25 -08:00
1 parent 84b7cdc1cd
commit 93a815957d
10 files changed
+185 -4

No files matched your search

@@ -20,6 +20,7 @@
package net.minecraftforge.common.extensions;
import java.util.Collection;
import java.util.Collections;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
@@ -40,6 +41,7 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.entity.PartEntity;
public interface IForgeEntity extends ICapabilitySerializable<CompoundNBT>
{
@@ -192,4 +194,34 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundNBT>
* the entity to react to being revived.
*/
void revive();
/**
* This is used to specify that your entity has multiple individual parts, such as the Vanilla Ender Dragon.
*
* See {@link net.minecraft.entity.boss.dragon.EnderDragonEntity} for an example implementation.
* @return true if this is a multipart entity.
*/
default boolean isMultipartEntity()
{
return false;
}
/**
* Gets the individual sub parts that make up this entity.
*
* The entities returned by this method are NOT saved to the world in nay way, they exist as an extension
* of their host entity. The child entity does not track its server-side(or client-side) counterpart, and
* the host entity is responsible for moving and managing these children.
*
* Only used if {@link #isMultipartEntity()} returns true.
*
* See {@link net.minecraft.entity.boss.dragon.EnderDragonEntity} for an example implementation.
* @return The child parts of this entity. The value to be returned here should be cached.
*/
@Nullable
default PartEntity<?>[] getParts()
{
return null;
}
}