package net.shadowfacts.simplemultipart.multipart.entity; import net.minecraft.nbt.CompoundTag; import net.shadowfacts.simplemultipart.container.MultipartContainer; /** * An entity associated with multiparts placed in the world. An instance of the part's entity exists for every in-world * instance of the part. * * Can implement {@link net.minecraft.util.Tickable} to be updated on game ticks. * * Analogous to {@link net.minecraft.block.entity.BlockEntity}. * * @author shadowfacts * @since 0.1.0 */ public abstract class MultipartEntity { /** * The container holding this multipart entity. */ // TODO: change this to a view? public MultipartContainer container; public MultipartEntity(MultipartContainer container) { this.container = container; } /** * Calling this indicates that something about this entity has changed that necessitates saving it to disk. */ protected void scheduleSave() { container.schedulePartSave(); } /** * Converts this entity into an NBT tag that can be saved to disk or transferred over the network. * * @param tag The tag to save this entity to. * @return The modified tag. */ public CompoundTag toTag(CompoundTag tag) { return tag; } /** * Restores this entity from the given NBT tag. * * @param tag The tag generated by {@link MultipartEntity#toTag(CompoundTag)}. */ public void fromTag(CompoundTag tag) { } }