51 lines
1.3 KiB
Java
51 lines
1.3 KiB
Java
package net.shadowfacts.simplemultipart.multipart.entity;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.shadowfacts.simplemultipart.container.MultipartContainer;
|
|
import net.shadowfacts.simplemultipart.multipart.MultipartView;
|
|
|
|
/**
|
|
* 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 view of this multipart.
|
|
*/
|
|
public MultipartView view;
|
|
|
|
/**
|
|
* Calling this indicates that something about this entity has changed that necessitates saving it to disk.
|
|
*/
|
|
protected void scheduleSave() {
|
|
view.getContainer().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) {
|
|
}
|
|
|
|
}
|