Search in sources :

Example 1 with LanternTileEntityType

use of org.lanternpowered.server.block.tile.LanternTileEntityType in project LanternServer by LanternPowered.

the class TileEntitySerializer method deserialize.

@Override
public LanternTileEntity deserialize(DataView dataView) throws InvalidDataException {
    final String id = fixTileId(dataView, dataView.getString(ID).get());
    dataView.remove(ID);
    final LanternTileEntityType tileEntityType = (LanternTileEntityType) Sponge.getRegistry().getType(TileEntityType.class, id).orElseThrow(() -> new InvalidDataException("Unknown tile entity id: " + id));
    // noinspection unchecked
    final ObjectStore<LanternTileEntity> store = (ObjectStore) ObjectStoreRegistry.get().get(tileEntityType.getTileEntityType()).get();
    // noinspection unchecked
    final LanternTileEntity entity = (LanternTileEntity) tileEntityType.getTileEntityConstructor().get();
    store.deserialize(entity, dataView);
    return entity;
}
Also used : ObjectStore(org.lanternpowered.server.data.io.store.ObjectStore) LanternTileEntityType(org.lanternpowered.server.block.tile.LanternTileEntityType) InvalidDataException(org.spongepowered.api.data.persistence.InvalidDataException) LanternTileEntity(org.lanternpowered.server.block.tile.LanternTileEntity)

Aggregations

LanternTileEntity (org.lanternpowered.server.block.tile.LanternTileEntity)1 LanternTileEntityType (org.lanternpowered.server.block.tile.LanternTileEntityType)1 ObjectStore (org.lanternpowered.server.data.io.store.ObjectStore)1 InvalidDataException (org.spongepowered.api.data.persistence.InvalidDataException)1