SimpleMultipart/src/main/java/net/shadowfacts/simplemultipart/multipart/entity/MultipartEntity.java

55 lines
1.4 KiB
Java
Raw Normal View History

2018-12-25 15:20:44 +00:00
package net.shadowfacts.simplemultipart.multipart.entity;
import net.minecraft.nbt.CompoundTag;
2018-12-28 02:55:51 +00:00
import net.shadowfacts.simplemultipart.container.MultipartContainer;
2018-12-25 15:20:44 +00:00
/**
2018-12-28 18:10:59 +00:00
* 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}.
*
2018-12-25 15:20:44 +00:00
* @author shadowfacts
2018-12-28 18:10:59 +00:00
* @since 0.1.0
2018-12-25 15:20:44 +00:00
*/
public abstract class MultipartEntity {
2018-12-28 18:10:59 +00:00
/**
* The container holding this multipart entity.
*/
// TODO: change this to a view?
2018-12-25 15:30:46 +00:00
public MultipartContainer container;
2018-12-25 15:20:44 +00:00
2018-12-25 15:30:46 +00:00
public MultipartEntity(MultipartContainer container) {
2018-12-25 15:20:44 +00:00
this.container = container;
}
2018-12-28 18:10:59 +00:00
/**
* Calling this indicates that something about this entity has changed that necessitates saving it to disk.
*/
2018-12-25 15:20:44 +00:00
protected void scheduleSave() {
2018-12-25 15:30:46 +00:00
container.schedulePartSave();
2018-12-25 15:20:44 +00:00
}
2018-12-28 18:10:59 +00:00
/**
* 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.
*/
2018-12-25 15:20:44 +00:00
public CompoundTag toTag(CompoundTag tag) {
return tag;
}
2018-12-28 18:10:59 +00:00
/**
* Restores this entity from the given NBT tag.
*
* @param tag The tag generated by {@link MultipartEntity#toTag(CompoundTag)}.
*/
2018-12-25 15:20:44 +00:00
public void fromTag(CompoundTag tag) {
}
}